-
Notifications
You must be signed in to change notification settings - Fork 826
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
Unity SDK: Delay dispose of CancellationTokenSource when quitting #4075
base: main
Are you sure you want to change the base?
Unity SDK: Delay dispose of CancellationTokenSource when quitting #4075
Conversation
Quitting in Unity fires a number of events and callbacks. `MonoBehaviour.OnApplicationQuit` is called before `Application.wantsToQuit` which leads to undesired behaviour. `Application.wantsToQuit` can be used to interrupt a quit process, so you can shut down gracefully. If this is utilized, the AgonesSDK has already dispose the cancellation token and future calls will fail. Reference: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Application-wantsToQuit.html Same solution as in UniRX: neuecc/UniRx#463
/gcbrun |
Build Succeeded 🥳 Build Id: 80def32a-2120-4a72-9f4d-2e45d0648ef0 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Calling our most recent Unity experts for review please: @ZeroParticle , @aallbrig, @kingshijie, @MaxHayman, @mollstam - does this change look good to you? 👋🏻 |
Hello all, a bit surprised by this ping (haven't used Agones since '21) but looking at the code I do have some concerns. I think this change per se is OK, as it does indeed address undesired behaviour when application quit is aborted / handled gracefully, but I think the code would benefit from us zooming out a notch. I would only ever create a This leads me to another very important point:
So If that is true I don't think the changes proposed in this PR are necessarily the fix called for. If it is as that comment in Sorry for a long reponse, let me know what your thoughts are. Gotta run. |
@mollstam's comments seem reasonable to me. I do have some concern that the async request handler setup we have in that file does not have any cancellation implementation. It seems reasonable to attempt to cancel any inflight requests when the game object is destroyed. |
@mollstam Makes sense, good observation.
|
The HealthCheck shows signs of the ObjectDisposedException https://github.com/googleforgames/agones/blob/main/sdks/unity/AgonesSdk.cs#L269-L284 |
What type of PR is this?
/kind bug
What this PR does / Why we need it:
Quitting in Unity fires a number of events and callbacks.
MonoBehaviour.OnApplicationQuit
is called beforeApplication.wantsToQuit
which leads to undesired behaviour.Application.wantsToQuit
can be used to interrupt a quit process, so you can shut down gracefully. If this is utilized, the AgonesSDK has already disposed the cancellation token and future calls will fail.We use this when controlling disruption https://agones.dev/site/docs/advanced/controlling-disruption/
Reference: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Application-wantsToQuit.html
Same solution as in UniRX: neuecc/UniRx#463
Which issue(s) this PR fixes:
Closes #
Special notes for your reviewer: