Fix play button starting wrong beatmap before selection loads #36104
+47
−0
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.
Closes #36074
Fixes an issue where clicking the osu! cookie (play button) would start the wrong beatmap if clicked before the newly selected beatmap finishes loading (within 150ms of selection).
The song select screen uses a 150ms debounce when changing beatmap selection to avoid performance issues during rapid keyboard navigation. However, this created a race condition where the global Beatmap.Value wouldn't update immediately, causing the play button to start the old beatmap while pressing Enter would correctly play the new one.
Solution:
Added ensureGlobalBeatmapValid() calls before starting gameplay for both the logo click and Enter key handlers. This forces the debounced selection to flush immediately, ensuring both input methods read the correct beatmap.
Also includes test coverage that reproduces the race condition by selecting a different difficulty and immediately clicking the logo before the debounce completes.