-
Notifications
You must be signed in to change notification settings - Fork 287
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
[single-instance] doesn't shutdown immediately on Windows #1017
Comments
If we're talking about v1 this is exactly the same thing as app.exit(). https://docs.rs/tauri/1.6.1/src/tauri/app.rs.html#524-527 Anyway, i'm fairly sure that this has nothing to do with how the app is exited, but when. The .setup hook just feels too late for this though it's a bit weird that it's more of an issue on windows than linux 🤔 |
Oh, I wasn't aware of that, I just started to build a Tauri app a month ago with Tauri 2 beta
Yep, but that's the first chance a plugin can access app, if we want to do it earlier, we'll probably need an extra API from Tauri side
The implementation for Linux is Maybe changing both of them to this for now? app.cleanup_before_exit()
std::process::exit(0) |
This is probably the best approach, otherwise we cannot guarantee the time when this plugin runs. With how heavy v2 is on plugin use this could mean that 10 other plugins already ran their setup hook. |
FYI, We currently load setup functions in their added order, so as long as we register single instance plugin first, its setup function is guaranteed to run first
|
Which is not something we can rely on at all so it's still something we should think about. Anyway, the new Exit/ExitRequested sensitive app.exit() behavior indeed slows it down quite a bunch, way more than expected, so if you'd like to work on it we'd appreciate a PR (changing it to cleanup + exit as you showed above). |
I'll keep this issue open until Lucas had a chance to react to the order thingy. Worst case we just add documentation for this and wait and see if more plugins/users need some kind of priority thing. |
Since Lucas didn't react i marked this as an |
When using single instance plugin on Windows, the second instance doesn't shutdown immediately
Windows implementation uses
app.exit
while the Linux one usesstd::process::exit
,app.exit
only sends a shutdown signal, and the app will still be running through all the following setup functions, e.g. create the window, create the system tray...This was changed to this in 4d903f3 for cleaning up system tray, but currently it doesn't even trigger exit event for some reason (even if it actually triggers it, it's still problematic to have flashing windows)
In my opinion, we should just use
std::process::exit
here (maybe run withcleanup_before_exit
to clean up system tray) (simple fix but may not be perfect) or we'll need a way to shutdown the app cleanly in setup step from Tauriplugins-workspace/plugins/single-instance/src/platform_impl/windows.rs
Line 65 in 99bea25
plugins-workspace/plugins/single-instance/src/platform_impl/linux.rs
Line 73 in 99bea25
The text was updated successfully, but these errors were encountered: