Skip to content

Unable to create status tray icon on Windows - v0.30.3 and v0.30.2 #2468

Closed

Description

@armaseg

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.

error-win7-2

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);

Activity

  1. armaseg commented on Aug 11, 2015

    @armaseg
    Author

    I got the same errors on v0.30.4

  2. mnemotiv commented on Aug 13, 2015

    @mnemotiv

    Same here. Bump.

  3. hankbao commented on Aug 16, 2015

    @hankbao
    Contributor

    Same here. 😨

  4. hfcorriez commented on Aug 16, 2015

    @hfcorriez

    Same here.

  5. armaseg commented on Aug 21, 2015

    @armaseg
    Author

    Is working again on v0.30.5
    Thank you!

  6. hankbao commented on Sep 17, 2015

    @hankbao
    Contributor

    This issue may need to be reopened.

  7. aik8 commented on Sep 23, 2015

    @aik8

    @hankbao, I agree...

  8. anaisbetts commented on Sep 23, 2015

    @anaisbetts
    Contributor

    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:

    https://gist.github.com/paulcbetts/c4e3412262324b551dda

    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.

  9. felipecrs commented on Feb 1, 2024

    @felipecrs

    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.

  10. felipecrs commented on Feb 1, 2024

    @felipecrs

    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.

  11. felipecrs commented on Mar 27, 2024

    @felipecrs

    Tested again with Electron 29.1.6. Same issue still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions