tauri: [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.rswith the code below - Run the app via either via
yarn tauri devoryarn tauri buildand 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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 20 (7 by maintainers)
Commits related to this issue
- fix(tauri-runtime-wry): ensure tray is created when event loop ready closes #9480 see https://github.com/tauri-apps/tray-icon/pull/122 — committed to tauri-apps/tauri by lucasfernog 2 years ago
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.
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.
@kurdin That worked perfect. Thank you so much for the clear followup.
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 😃
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.
Ok np. I have an easy repro case and happy to help test any PRs.
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.