Nw.js: nwjs taskbar icon on Windows for NW.js is a red square, can't set icon in package.json

Created on 23 Nov 2019  路  21Comments  路  Source: nwjs/nw.js

NWJS Version : 0.42.5 SDK version
Operating System : Windows 10 (x64)

Expected behavior

You should be able to set the icon associated with NW.js using the provided method of setting "icon" in the "window" section of the package.json file.

Actual behavior

The icon associated with the NW.js application is a red square and cannot be set using the provided methods in the package.json. See screenshot in the comments below.

How to reproduce

Download 0.42.5 SDK for Windows x64 and set your package.json to be like:

NOTE: This is not a path problem as it works fine in 0.40.

{
  "name": "app-name-here"
  "main": "index.html",
  "window": {
    "icon": "image.png"
  }
}

Most helpful comment

I managed to reproduce it in another system. This is now fixed in git and will be available in the next nightly build.

All 21 comments

Could you provide a sample of the icon? It works for me.

@rogerwang
Not sure what is going on but I get the same thing - I tried the app on #7221 (transparency issue) and the icon is red square with nw2 (see attached graphic on #7221). I also tried one of my apps which works ok on OSX (apart from the shadow issue) and it also fails on nw2 - I get the red icon. All is OK if nw2 is disabled in the manifest.
I think that #7222 is the same issue also.
I was using Win 10 Pro 64bit (1803) in Parallels 13 VM on OSX 10.13.6.

I don't think a sample is really needed of my icon because the same icon works fine in NW.js 0.40.0 and in much older releases. I've been using the same icon for my app for a lot of years.

Here is my icon:

toby

Just running NW.js demonstrates the behavior. Here is a screenshot of it. Notice that the task bar icon is a red square. When you attempt to set the icon in the package.json it doesn't work.

image

the same to me

Same here
image

I can confirm this issue

I have this problem too

interesting ... it works for me with win10 and the default app. Could you try to clear the icon cache?
https://www.winhelponline.com/blog/how-to-rebuild-the-icon-cache-in-windows/#script

iconscreenshot

it works with latest (v0.43.0), but not with v0.42.5

interesting ... it works for me with win10 and the default app. Could you try to clear the icon cache?
https://www.winhelponline.com/blog/how-to-rebuild-the-icon-cache-in-windows/#script

If I switch between 0.42.3 and 0.42.5, icon work in 0.42.3 and doesn't work in 0.42.5, so it's not icon cache (and users won't clear it)

Same just now with clean base, only extracted.
I tested both 32 and 64 bit version and both SDK and non-SDK versions with same results.

Windows 10 Pro, version 1903, build 18362.476

image

image

I just tested clean cache script and it still not working
I still see a big red square

Does --disable-features=nw2 make any difference there?

yes,

standard run (0.42.5, 32b)
image

disable nw2 (0.42.5, 32b)
image

It's possible setting this flag in package.json? Or it's only command line argument?

Yes it differs
with --disable-features=nw2
image

normal
image

Yes. It can be used in package.json for now as a workaround.

If I added --disable-features=nw2 to package.json, everything seems fine, but I can't open downloaded files - #7234

I managed to reproduce it in another system. This is now fixed in git and will be available in the next nightly build.

Thank you to everyone on this issue. You guys rock!

I am still facing this issue while developing my application.

Scenario: My application launches multiple new windows depending on the condition set by the users. I used "window.open(url, '_blank');" which is an existing logic that I can't change.

To set the common height, width and icon for all windows I used the below logic:

currWin.on('new-win-policy', function(frame, url, policy) {
policy.setNewWindowManifest({
'icon': '../assets/app.png',
'frame': true,
'width': 1300,
'height': 900,
'position': 'center',
});
});

The above is working fine on OSX, but when runs on Windows 10 I am still getting a red icon for the newly open window. Please refer to the below screenshot.
Screenshot 2020-12-03 at 6 17 36 PM

When I use --disable-features=nw2 it works.

Using: nw.js v0.50.1
Screenshot 2020-12-03 at 6 17 16 PM

Hi All

Tray icon is not visible as well. Below is the logic that I have used:

var trayObject = new gui.Tray({
title: 'MyApp',
tooltip: 'MyApp is running',
icon: '../../assets/myApp.png',
});

My code structure is :
assets -> myApp.png (1024 x 1024) tried myApp.ico (256 x 256) as well but didn't worked.
src -> js -> index.js (creating tray object here. Refer above code)

Yes, I'm having the same issue.
image
It doesn't happen in my main window, but since it uses an