Fix Game.Dispose potentially ending before children have been (async) disposed #3860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Wait for global async disposal queue to empty before disposing the game itself, as the components within may be relying on game/host access in their ongoing background functions (ie. if they are still in an async load cancelling state).
Fixes test failures seen in ppy/osu#10026, that started to show up from various usage of
DelayedLoadUnloadWrapper
(which is using the async disposal queue in a slightly different way since https://github.com/ppy/osu-framework/pull/3825/files).I also fixed an edge case in
AsyncDisposalQueue
which can't be easily tested but should be easy enough to understand:I've fixed this by making the task loop until the queue empties, and also locking over these checks to ensure safety.