Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initialising tray icons on the macos desktop platform #3533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PhilTaken
Copy link

Depending on multiple versions of the muda crate - one directly and one via a transitive dependency in the tray-icon crate - leads to the following error when attempting to initialize a tray icon on the desktop platform, specifically on MacOS:

   6.858s  INFO Build completed successfully in 2882ms, launching app! 💫   7.871s  INFO [macos]: 2025-01-10 00:16:01.736 dimsum[19111:45581742] +[IMKClient subclass]: chose IMKClient_Modern
   7.876s  INFO [macos]:   7.876s  INFO [macos]: thread 'main' panicked at /Users/philippherzog/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/muda-0.15.3/src/platform_impl/macos/mod.rs:934:1:
   7.876s  INFO [macos]: could not create new class MudaMenuItem. Perhaps a class with that name already exists?

Without any prior knowledge on how the muda crate or MacOS tray icons work, it appears that muda generates some sort of class definition for MacOS whose identifier needs to be unique. Multiple versions of the crate will then lead to duplicate definitions and thereby the above crash at runtime.

Since this only breaks at runtime and only on the MacOS target it's far from trivial to add a test to ensure this doesn't break again on the next cargo update. I'll open a related ticket in the muda repository, maybe they can think of a more robust solution.

@PhilTaken PhilTaken changed the title Fix tray icons for the macos desktop platform Fix initialising tray icons on the macos desktop platform Jan 9, 2025
@jkelleyrtp
Copy link
Member

jkelleyrtp commented Jan 10, 2025

Unfortunately I don't think we can bump muda in this minor version (0.6.x). Muda is exported from our public API via dioxus::desktop::muda so if you want to use muda in your crate I recommend using the one we re-export. Adding muda to your cargo.toml will cause the issue which is unfortunate but probably not something we can address.

Is there an issue with the 0.14.x series of muda that we need to upgrade to?

I'm going to close this for now but please feel free to make a new PR if there's an issue with how dioxus is using and re-exporting muda that we can fix!

@jkelleyrtp jkelleyrtp closed this Jan 10, 2025
@PhilTaken
Copy link
Author

PhilTaken commented Jan 10, 2025

Adding muda to your cargo.toml will cause the issue which is unfortunate but probably not something we can address.

that is not the case, dioxus and dioxus-desktop requiring different versions of the muda crate is the issue here

since tray-icon 0.19 requires a newer version of muda than dioxus and tray-icon 0.19 is a dependency of dioxus-desktop

@jkelleyrtp jkelleyrtp reopened this Jan 13, 2025
@PhilTaken
Copy link
Author

PhilTaken commented Jan 14, 2025

Another option here might be downgrading tray-icon to a version that depends on the same version of muda as dioxus such that the exported version of muda remains the same but neither solution is great and neither can be kept in sync easily aside from maybe parsing cargo tree (or Cargo.lock) in CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants