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] System tray icon on taskbar disappears when explorer restarts #476

Closed
WilfredC64 opened this issue Jul 16, 2022 · 2 comments · Fixed by #462
Closed

[bug] System tray icon on taskbar disappears when explorer restarts #476

WilfredC64 opened this issue Jul 16, 2022 · 2 comments · Fixed by #462

Comments

@WilfredC64
Copy link

Describe the bug

On Windows when you create an app with Tauri with a system tray icon and run it, the icon is visible on the system tray in the taskbar. When you restart explorer, the system tray icon disappears. This is problematic when your app runs in the background with no visible window and where the window can only be made visible via the system tray menu. So when explorer restarts, the app is still running but you cannot access it anymore.

The problem is probably caused by Tauri not handling the TaskbarCreated event to register the icon again for the new task bar.

More info about the event can be found here:

https://docs.microsoft.com/en-us/windows/win32/shell/taskbar#taskbar-creation-notification

Another problem related to restarting explorer is when you have set skip_taskbar to true and then restart explorer, suddenly the Tauri app is visible on the taskbar.

On Windows, some applications restart explorer when an update is installed in the background. Therefore it is necessary that Tauri supports this and re-registers the system tray icon when this happens and also handles the skip_taskbar properly.

Reproduction

Create a simple Tauri app with one window with a system tray icon and with a system tray menu where you can close the app and set skip_taskbar to true on the window.

Run the app and notice the system tray icon.

Now restart explorer.exe. You can do this via Task Manager. Run Task Manager, search for "Windows Explorer", select it, and press the restart button at the bottom right.

Notice that Windows Explorer restarts and there is no system tray icon of the Tauri app anymore. Also notice that the app is visible again on the task bar.

Expected behavior

When you have a Tauri app with a system tray icon and where skip_taskbar is set to true, restarting explorer.exe should still show the system tray icon and also it should not make the app visible on the taskbar.

Platform and versions

Environment
  › OS: Windows 10.0.19044 X64
  › Webview2: 103.0.1264.49
  › MSVC: 
      - Visual Studio Build Tools 2022
  › Node.js: 16.14.2
  › npm: 8.5.0
  › pnpm: Not installed!
  › yarn: 1.19.1
  › rustup: 1.24.3
  › rustc: 1.62.0
  › cargo: 1.62.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc 

Packages
  › @tauri-apps/cli [NPM]: 1.0.4
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.4,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: default-src 'self'
  › distDir: ../dist
  › devPath: http://localhost:5173/
  › framework: Vue.js

App directory structure
  ├─ .idea
  ├─ .vscode
  ├─ dist
  ├─ node_modules
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

No response

@WilfredC64 WilfredC64 added status: needs triage This issue or pull request needs to be investigated type: bug labels Jul 16, 2022
@amrbashir amrbashir added platform: Windows status: needs triage This issue or pull request needs to be investigated and removed status: needs triage This issue or pull request needs to be investigated labels Jul 16, 2022
@amrbashir
Copy link
Member

amrbashir commented Jul 16, 2022

Thank you for the detailed bug report and the relevant docs.

@amrbashir amrbashir transferred this issue from tauri-apps/tauri Jul 16, 2022
@amrbashir amrbashir self-assigned this Jul 16, 2022
@amrbashir amrbashir removed the status: needs triage This issue or pull request needs to be investigated label Jul 16, 2022
@amrbashir
Copy link
Member

amrbashir commented Jul 19, 2022

PR is up #487
try it out by applying this patch to your tauri app

[patch.crates-io]
tao = { git = "https://github.com/tauri-apps/tao", branch = "taskbar-restart" }

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

Successfully merging a pull request may close this issue.

2 participants