Skip to content

[Bug]: tray icon will eventually disappear when packed in asar archive #30911

Closed as not planned

Description

@deermichel

Preflight Checklist

Electron Version

12.1.0 (though same on current master)

What operating system are you using?

Windows

Operating System Version

Windows 10 2004

What arch are you using?

x64

Last Known Working Electron version

n/a

Expected Behavior

On Windows, we load an *.ico image for Tray via:

new Tray(nativeImage.createFromPath('someIcon.ico'))

After the %temp% folder on Windows got cleared (let's suppose some internal housekeeping), the tray icon remains unchanged.

Actual Behavior

After clearing %temp%, the tray looses its image. A transparent placeholder remains and other tray actions (e.g. opening a context menu) still work.

Testcase Gist URL

No response

Additional Information

This is only the case when loading the icon from an asar archive. The reason is that ReadICOFromPath will extract the icon to a temp file using the Archive::CopyFileOut method.

While this is useful in the usual case (temporary extracted files should be deleted at one point), it's not viable for tray icons as the image will disappear when the file gets removed - at least on Windows.

Possible solutions:

  • add note to Tray docs (or nativeImage) to exclude tray images when using asar archives (e.g. via --unpack-dir)
  • or: for the explicit case of tray icons, extract these images to a "persistent" path - however, cleanup needs to be provided in some way

cc @zarubond

Activity

  1. github-actions commented on Oct 5, 2022

    @github-actions
    Contributor

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  2. github-actions commented on Nov 6, 2022

    @github-actions
    Contributor

    This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

  3. Zen33 commented on May 5, 2023

    @Zen33

    same issue for now

  4. Nantris commented on Nov 22, 2024

    @Nantris
    Contributor

    This no longer appears to be an issue. Every time the app is started the .ico is written to a new temporary path now.

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