nw.js: Custom icon in taskbar not showing with 0.73.0 - grey default icon only

The custom icon in the windows 11’s taskbar is a grey default icon, with 0.73.0-sdk (or ‘normal’ non-sdk). It works flawlessly with 0.72.0 (and previous).

The odd thing with 0.73.0 is that the icon in the top-left corner (favico equivalent?) is there. The icon also is present in Task Manager (for the binary and all sub-processes spawned by nwjs too). And the icon also is fine with the Tray. But not on the main taskbar.

FYI: Disabling/enabling nw2 doesnt change the icon issue.

Attached: a printscreen of the nwjs icon (right) and the devtools icon (left). They used to both be my custom icon. WId9322LtC

  • Operating System: Windows 11 x64
  • NW.js Version: 0.73.0 (sdk/normal)
  • Code snippet: In package.json :
  "window": {
    "width": 1024,
    "height": 654,
    "title": "My App",
    "icon": "foo/bar.png",
    "min_width": 885,
    "min_height": 518,
    "show": false
  },

in the js files after some background checks for the app to prepare to strat:

require('nw.gui').Window.get().show(true)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 42 (11 by maintainers)

Commits related to this issue

Most upvoted comments

It’s obviously not ideal and hopefully the issue can be addressed soon, but the workaround does work for me.

old

  "window": {
    "icon": "./build/my-icon.png"
  },

new

  "window": {
    "icon": "./build/my-icon.png"
  },
  "icons": {
    "256": "./build/my-icon.png"
  },

I started digging into this and I noticed that the .ico file that you see is located here: %UserProfile%\AppData\Local\<app-name>\User Data\Default\Web Applications\_nwjs_<jibberish>\<app-name>.ico

You can find the Windows .lnk file that points to this icon by:

  1. Right-click the taskbar icon
  2. On the pop-up menu, right-click on the name of the application
  3. Select Properties
  4. You’ll see in the Shortcut file’s (.lnk file) properties window, the .lnk file is located in %UserProfile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts\<some hex id>\<app-name>.lnk
  5. If you navigate to the Shortut tab, and click the Change Icon button you’ll see the above-mentioned .ico file.

I’m guessing it has something to do with which Chromium version we’re using?

I found some other interesting things in the Chromium source code, talking about these ImplicitAppShortcuts here: https://chromium.googlesource.com/chromium/src/+/main/docs/windows_shortcut_and_taskbar_handling.md

UPDATE: I dug through the Chromium source, and it looks like Chromium manages its own icon and “Relaunch details” See Chromium source here

The problem is GetIconFilePath() tries to find an icon by looking at the icons property in the chrome extension’s manifest. If there is nothing there, then Chromium will use the default icon. The nw.js code supposedly populates the manifest by copying the icon path from the package.json’s, but for some reason, in v0.73.0 and above, it seems this property doesn’t end up in the nw.js-constructed manifest. I found that if force it by putting this in package.json, then Chromium will copy the icon to the AppData path as expected:

"icons": {
  "256": "path/to/icon.png"
}

@rogerwang : I believe I have a fix for this issue: in nw::LoadNWAppAsExtensionHook(), the call to:

manifest->FindString("window.icon");

should actually be:

manifest->FindStringByDottedPath("window.icon");

I confirmed this by actually getting the source to compile on Windows (no easy feat!), and checking that we are getting an empty icon_path, but if we use FindStringByDottedPath, then we get the expected value from the manifest, and NW.js will tell Chromium what to do with the icon.

https://github.com/nwjs/nw.js/blob/25f89d17a8886776e3de62ae2f4a931ed13bf2de/src/browser/nw_extensions_browser_hooks.cc#L289

Would you like me to create a pull request with the changes?

At this point it should be obvious that he doesn’t care. The PR is open for 2 months, it’s one short line of code, but I don’t think it will ever be merged.

@rogerwang please provide an update. This prevents us from updating NW.js in our applications.

This is now officially resolved with release 0.79.1.

0.78 the same bug. 🤬 WTF?!

0.77 the same bug. 🤬

Although the PR was merged, this is still broken with 0.78.1. 😦

@rogerwang : Can you please merge my pull request? Thank you!

0.75 the same bug. Seems nobody cares… ☹️

Hi! I’d like to work on this issue

0.74 the same bug.