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

[bug] Second "ghost" menu bar icon on Sonoma #9480

Closed
tleyden opened this issue Apr 16, 2024 · 20 comments
Closed

[bug] Second "ghost" menu bar icon on Sonoma #9480

tleyden opened this issue Apr 16, 2024 · 20 comments
Assignees
Labels
platform: macOS priority: 1 high status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@tleyden
Copy link

tleyden commented Apr 16, 2024

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.

Screenshot 2024-04-16 at 1 10 50 PM

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 or yarn 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");

}

Screenshot 2024-04-16 at 1 38 58 PM

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

@tleyden tleyden added status: needs triage This issue needs to triage, applied to new issues type: bug labels Apr 16, 2024
@FabianLars
Copy link
Member

@tleyden
Copy link
Author

tleyden commented Apr 16, 2024

Oh sorry, I missed these issues in my search since I they are in a different repo.

@tleyden tleyden closed this as completed Apr 16, 2024
@FabianLars FabianLars reopened this Apr 16, 2024
@FabianLars
Copy link
Member

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.

@tleyden
Copy link
Author

tleyden commented Apr 16, 2024

Ok np. I have an easy repro case and happy to help test any PRs.

@tleyden
Copy link
Author

tleyden commented Apr 16, 2024

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.

@tleyden
Copy link
Author

tleyden commented Apr 16, 2024

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.

@FabianLars
Copy link
Member

Yeah, it's quite weird. Took me months to be able to repro it (and only with this tauri-apps/tray-icon#90 (comment)) 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
Copy link

kurdin commented Jul 23, 2024

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.

image

So if I switch from dark to light in the system's preferences, the double icon disappears and everything goes back to normal.

image

Switching back to Dark from Light did not bring the double icon back.

image

Screenshot from the Apple Store review team.

Screenshot-0723-101145

Please help. This seems to be a critical issue for apps with system-tray menus. 🆘 @FabianLars 🙏

@kurdin
Copy link

kurdin commented Jul 23, 2024

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.

@k13w
Copy link

k13w commented Jul 25, 2024

Does anyone have a solution for this bug?

@FabianLars
Copy link
Member

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.

@kurdin
Copy link

kurdin commented Jul 25, 2024

@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.

@FabianLars
Copy link
Member

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

@kurdin
Copy link

kurdin commented Sep 4, 2024

@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.

Screenshot-0904-101305

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
#10220

App Store branch for PasteBar app is here
https://github.com/PasteBar/PasteBarApp/tree/macstoresubmit

Thank you for looking for solution.

@FabianLars
Copy link
Member

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...

@FabianLars FabianLars reopened this Sep 4, 2024
@FabianLars
Copy link
Member

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

@kurdin
Copy link

kurdin commented Sep 4, 2024

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.

@adamplouff
Copy link

CleanShot.2024-08-15.at.12.46.06.mp4

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.

@kurdin
Copy link

kurdin commented Sep 4, 2024

@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.

@adamplouff
Copy link

@kurdin That worked perfect. Thank you so much for the clear followup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS priority: 1 high status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
No open projects
Status: Done
Development

No branches or pull requests

7 participants