-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
OnApplicationShutdown behaviour #2802
Comments
@imerr so if we use OnDestroy in NM and Transport, this is solved? so if OnAppQuit cancels the quit, ondestory is never called? |
Yes, thats what I'm doing for my things
Yes, and OnDestroy is also called when the application shuts down, not quite sure why OnApplicationQuit was used though unless it's ordering related (OnApplicationQuit -> OnDisable -> OnDestroy - see https://docs.unity3d.com/Manual/ExecutionOrder.html) |
Describe the bug
When unity receives a shutdown request, it forwards it to MonoBehaviour.OnApplicationShutdown and Application.wantsToQuit callback
This "request" can be cancelled by returning false in the Application.wantsToQuit callback.
Depending on the semi-random (?) ordering mirror may shut down the Transport/NetworkManager even if the request gets cancelled later on.
You may want to cancel the (immediate) shutdown to do a graceful shutdown. Especially for dedicated servers it might be a bit better to tell users the server is shutting down in x seconds, have them disconnect after finishing up and then flush any save state before finally quitting unity for real
[IMPORTANT] How can we reproduce the issue, step by step:
Expected behavior
Mirror should not shut down until the application really quits (via handling OnDestroy).
Additional context
See also #923
overriding the NetworkManager.OnApplicationQuit is easy enough, but since Transport.OnApplicationQuit is now added a user will have to subclass a Transport too to change the default behaviour.
The other question is, why not just use OnDestroy to handle cleanup? Is that too late in some cases?
The text was updated successfully, but these errors were encountered: