You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to create status tray icon on Windows - v0.30.3 and v0.30.2 #2468
I've been trying to use a tray icon on Windows with v0.30.3 and v0.30.2 and I get the following errors: Unable to create status tray icon.
Error setting status tray icon image.
However, using v0.30.1 it works.
var appIcon = null;
var iconPlain = path.join(__dirname, 'image.png');
app.on('ready',function(){
appIcon = new Tray(iconPlain);
So, after a lot of suffering, we've figured out that the advice we were given that culminated in #2328 (from a lead Windows OS developer!) was actually really bad for apps that use Squirrel.
How we thought it works
When Windows creates a Tray icon preference for your app, they use your EXE's full path as the "key" to that preference. However, when Squirrel for Windows moves the EXE's location, that key no longer matches, even though it's the same App. The solution to this is (we thought!) the GUID parameter, which we initially thought would be used in place of the key. Use the same GUID for every version of the app, and you're all set. To automate this, #2328 tried to take your app's App Model ID (a similar concept of being able to group different EXEs into one "App") and blit it into a GUID.
How it actually works
When you use a GUID along with the Tray icon, it still records the EXE's full path, but then proceeds to disallow anyone else from using that GUID. This means that as you ship updates, eventually nobody will be able to see your tray icon, because IconStreams will have marked your GUID as belonging to an old version of the app.
All of this information is stored in the Obfuscated, Binary blob inside the IconStreams key in HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify. As far as we can tell, there is no way to remove this corrupt information using public APIs, or even undocumented APIs.
What Slack does about it
We found about this problem way too late to be able to fix it via Electron, so we worked around it. On every startup, we run this block of code:
This parses IconStreams directly, looking for an entry that would break our tray icon. If it's found, we rewrite IconStreams, then kill Explorer.exe because there's no way to get it to reread this information.
What you should do about it
This is obviously a bad approach. I'm going to remove the GUID code from Electron entirely, which will bring back the original bug (multiple entries in the tray preferences). We'll then use the C# code above to filter IconStreams on startup, but not kill Explorer, so while users might see one or two duplicate entries, they'll eventually clear out.
I know this issue is almost 10 years old, but I am facing this exact same problem after upgrading my application from Electron from 26 to 28.
[13988:0201/145554.280:WARNING:notify_icon.cc(62)] Unable to create status tray icon.[13988:0201/145554.289:WARNING:notify_icon.cc(143)] Error setting status tray icon image[13988:0201/145554.296:WARNING:notify_icon.cc(159)] Unable to set tooltip for status tray icon
And, as suggested by @anaisbetts, removing GUID from the tray icon indeed brings the tray icon back.
Note however I can only reproduce this bug in Windows 10, not Windows 11.
I found out that if I change the GUID to something else than a previously used one by my application also soves the issue. So, I'm going to do that for now (felipecrs/clipboard-sync#38).
EDIT: never mind, that only works until updating the app again. For now, only solution is to remove the GUID indeed.
Activity
armaseg commentedon Aug 11, 2015
I got the same errors on v0.30.4
mnemotiv commentedon Aug 13, 2015
Same here. Bump.
hankbao commentedon Aug 16, 2015
Same here. 😨
hfcorriez commentedon Aug 16, 2015
Same here.
armaseg commentedon Aug 21, 2015
Is working again on v0.30.5
Thank you!
hankbao commentedon Sep 17, 2015
This issue may need to be reopened.
aik8 commentedon Sep 23, 2015
@hankbao, I agree...
anaisbetts commentedon Sep 23, 2015
So, after a lot of suffering, we've figured out that the advice we were given that culminated in #2328 (from a lead Windows OS developer!) was actually really bad for apps that use Squirrel.
How we thought it works
When Windows creates a Tray icon preference for your app, they use your EXE's full path as the "key" to that preference. However, when Squirrel for Windows moves the EXE's location, that key no longer matches, even though it's the same App. The solution to this is (we thought!) the GUID parameter, which we initially thought would be used in place of the key. Use the same GUID for every version of the app, and you're all set. To automate this, #2328 tried to take your app's App Model ID (a similar concept of being able to group different EXEs into one "App") and blit it into a GUID.
How it actually works
When you use a GUID along with the Tray icon, it still records the EXE's full path, but then proceeds to disallow anyone else from using that GUID. This means that as you ship updates, eventually nobody will be able to see your tray icon, because IconStreams will have marked your GUID as belonging to an old version of the app.
All of this information is stored in the Obfuscated, Binary blob inside the
IconStreamskey inHKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify. As far as we can tell, there is no way to remove this corrupt information using public APIs, or even undocumented APIs.What Slack does about it
We found about this problem way too late to be able to fix it via Electron, so we worked around it. On every startup, we run this block of code:
https://gist.github.com/paulcbetts/c4e3412262324b551dda
This parses
IconStreamsdirectly, looking for an entry that would break our tray icon. If it's found, we rewrite IconStreams, then kill Explorer.exe because there's no way to get it to reread this information.What you should do about it
This is obviously a bad approach. I'm going to remove the GUID code from Electron entirely, which will bring back the original bug (multiple entries in the tray preferences). We'll then use the C# code above to filter IconStreams on startup, but not kill Explorer, so while users might see one or two duplicate entries, they'll eventually clear out.
Remove GUID from Shell_NotifyIcon calls
felipecrs commentedon Feb 1, 2024
I know this issue is almost 10 years old, but I am facing this exact same problem after upgrading my application from Electron from 26 to 28.
And, as suggested by @anaisbetts, removing GUID from the tray icon indeed brings the tray icon back.
Note however I can only reproduce this bug in Windows 10, not Windows 11.
felipecrs commentedon Feb 1, 2024
I found out that if I change the GUID to something else than a previously used one by my application also soves the issue. So, I'm going to do that for now (felipecrs/clipboard-sync#38).
EDIT: never mind, that only works until updating the app again. For now, only solution is to remove the GUID indeed.
Remove tray icon GUID to fix mysterious issue with Windows 10
felipecrs commentedon Mar 27, 2024
Tested again with Electron 29.1.6. Same issue still.