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

Fix Game.Dispose potentially ending before children have been (async) disposed #3860

Merged
merged 7 commits into from Sep 3, 2020

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Sep 2, 2020

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:

  • Enqueue an item
  • Processing begins on that item
  • New item enqueued before processing ends. Task isn't started because one is already running, but that task will not process any newly added items.

I've fixed this by making the task loop until the queue empties, and also locking over these checks to ensure safety.

@peppy peppy marked this pull request as ready for review September 2, 2020 10:19
@peppy
Copy link
Sponsor Member Author

peppy commented Sep 2, 2020

Actually I can probably make a test to cover that failure case of the queue itself if that's seen as important. Involves smashing the queue with new items for a good few seconds then ensuring the processed count is 100% of queued items. I'd guess a few would be missed with the old logic.

@peppy
Copy link
Sponsor Member Author

peppy commented Sep 2, 2020

On writing a test I realise the original logic actually works correctly. Misread the task state check condition, which is explicitly checking Not Running. I'll revert the changes for now I think.

Copy link
Contributor

@smoogipoo smoogipoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! 👍

@smoogipoo smoogipoo merged commit 3f74a7a into ppy:master Sep 3, 2020
@peppy peppy deleted the fix-game-disposal-order branch October 18, 2020 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants