tauri
tauri copied to clipboard
[bug] Second "ghost" menu bar icon on Sonoma
Describe the bug
After upgrading to Sonoma 14.4.1, my menu bar app started showing a strange second icon near the apple icon. It only happens on an external monitor with mirroring enabled.
Reproduction
NOTE: this only repros sporadically. See comment below for details.
- Run MacOS Sonoma 14.4.1
- Plug-in an external monitor (27")
- Enable mirroring
- Create two virtual desktops
-
yarn create tauri-app
- Update
main.rs
with the code below - Run the app via either via
yarn tauri dev
oryarn tauri build
and install the application from the DMG
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::SystemTray;
use tauri::{CustomMenuItem, SystemTrayMenu, SystemTrayMenuItem};
fn main() {
let quit = CustomMenuItem::new("quit".to_string(), "Quit");
let hide = CustomMenuItem::new("hide".to_string(), "Hide");
let tray_menu = SystemTrayMenu::new()
.add_item(quit)
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(hide);
let system_tray = SystemTray::new()
.with_menu(tray_menu);
tauri::Builder::default()
.system_tray(system_tray)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Expected behavior
No ghost icon as shown in the screenshot
Full tauri info
output
yarn run v1.22.19
$ tauri info
[✔] Environment
- OS: Mac OS 14.4.1 X64
✔ Xcode Command Line Tools: installed
✔ rustc: 1.75.0 (82e1608df 2023-12-21)
✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 18.16.0
- pnpm: 8.8.0
- yarn: 1.22.19
- npm: 9.5.1
[-] Packages
- tauri [RUST]: 1.5.4
- tauri-build [RUST]: 1.5.1
- wry [RUST]: 0.24.7
- tao [RUST]: 0.16.5
- @tauri-apps/api [NPM]: 1.5.3
- @tauri-apps/cli [NPM]: 1.5.11
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
✨ Done in 3.36s.
Stack trace
N/A
Additional context
No response
https://github.com/tauri-apps/tray-icon/issues/90 / https://github.com/tauri-apps/tray-icon/pull/122
Oh sorry, I missed these issues in my search since I they are in a different repo.
No no, it's alright, we didn't adapt Tauri to the findings there. I just linked them for visiblity (so we know what to do when fixing it). Should have included that in the comment, apologies.
Ok np. I have an easy repro case and happy to help test any PRs.
I updated the repro steps to note that I have two virtual desktops defined. I cannot repro if I remove one of the virtual desktops and only have a single virtual desktop active.
When the ghost icon does appear with multiple virtual desktops, it disappears after switching to a different virtual desktop, and doesn't reappear even when switching back to the original.
FYI it appears to be a bit of "Heisenbug", because after deleting one of my virtual desktops and recreating it, I can no longer repro the issue, even with two virtual desktops.
Yeah, it's quite weird. Took me months to be able to repro it (and only with this https://github.com/tauri-apps/tray-icon/issues/90#issuecomment-1947441354) and it seems to be different for every user somehow...
I just hope that the solution that worked for me will work for the others too, because if not then i have no idea how to further investigate this.
I just had my app rejected from Mac App Store submission because of this issue. I have updated Tauri to the latest 1.7 version but still see a system menu double icon appearing on the Mac's menubar, but only if the macOS theme is set to Dark. In Light theme, there's no issue with the icon.
So if I switch from dark to light in the system's preferences, the double icon disappears and everything goes back to normal.
Switching back to Dark from Light did not bring the double icon back.
Screenshot from the Apple Store review team.
Please help. This seems to be a critical issue for apps with system-tray menus. 🆘 @FabianLars 🙏
Update: After the third try, my app was accepted by the Apple Mac Store. I did not change much in the code, but it could be just luck that on the third run, the app was tested in light theme mode on macOS, so this icon ghost issue was not detected. The issue still persists in some cases on my local machine. I could not find a workaround to fix it.
Does anyone have a solution for this bug?
Only got a workaround for v2: Remove the tray config from tauri.conf.json (if any) and from wherever you currently have it and init the tray later in RunEvent::Ready. General RunEvent example: https://github.com/tauri-apps/tauri/blob/dev/examples/api/src-tauri/src/lib.rs#L152
For v1 i'm still currently looking into a solution on our side, but i'll be busy over the weekend so no ETA. It's pretty high prio though due to the reports about the app store rejection.
@FabianLars Thank you for looking into a solution for Tauri 1.x. Let me know if I can help/test anything. Currently I don't see this bug on my local dev, but I am sure it will comeback sooner or later. As it was mentioned in other issue, this has something to do with some apps opened in full screen while you opening Tauri App. I see this bug disappears when switching between light / dark theme in Mac OS.
Yeah thanks, I did quite a bit of testing for the same issue in the tray-icon repo and can reproduce it consistently (though I'll have to look up my notes to remember how 😂). Just a bit tricky to apply the fix in tauri's codebase especially in v1 and it doesn't help that I didn't look at that part of the project for ages...
Will reach out again if I have something for you to test :)
@lucasfernog @FabianLars Sorry to reopen but I have submitted update for my app to App Store and it has been rejected again for the same problem.
I am using the latest version of Tauri 1.7.1 and tauri-runtime-wry 0.14.10.
tauri-runtime-wry = "0.14.10"
tauri = { version = "1.7.2", features = [ "api-all", "system-tray", "icon-png", "clipboard", "updater" ]}
if I understand this correctly, this issue has been marked as fixed and it appears to be not https://github.com/tauri-apps/tauri/pull/10220
App Store branch for PasteBar app is here https://github.com/PasteBar/PasteBarApp/tree/macstoresubmit
Thank you for looking for solution.
Just got back from vacation so i never tested the changes. I'll do so later today but i have a feeling that it works for my reproduction/research and that there's some other trigger...
Okay so my reproduction from back then doesn't work anymore so at least that was fixed by Lucas' changes. I'm not sure what else could trigger this now...
Your branch also works fine for me as far as i can see.
p.s. i am using light mode
After the third try, my updated app has been accepted by the App Store. I did not change anything, just removed the Cargo.lock file and did a clean cargo build.
Currently, I can't reproduce this issue on my local machine, and I don't have a single user report on that problem either. So hopefully this problem is fixed.
I think we can close this issue, and if I see that problem again. I'll reopen.
@FabianLars Thank you again for all your help and time.
https://github.com/user-attachments/assets/dccd25df-a6e3-40b7-b92a-58d3e0852c40
I have a user who has been able to reproduce the error and it seems to be related to macOS spaces. When they switch spaces it resolves.
@adamplouff It was related to use of multi screens in my case. Did you try the latest version of tauri ?
I use this in Cargo.toml tauri-runtime-wry = "0.14.10" tauri = { version = "1.7.2", features = [ "api-all", "system-tray", "icon-png", "clipboard", "updater" ]}
Just in case, I would do a clean cargo build after update to tauri 1.7.2.
@kurdin That worked perfect. Thank you so much for the clear followup.