Skip to content

Conversation

@itsdaliia
Copy link

@itsdaliia itsdaliia commented Dec 22, 2025

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.

When clicking the osu! cookie (play button) before a newly selected beatmap finishes loading, the previous beatmap would be played instead of the currently selected one. 

This was caused by the cookie reading from the global beatmap state which is debounced by 150ms, while the Enter key correctly used the carousel's current selection.

The fix makes the cookie use the same beatmap source as Enter - the carousel's current selection - which is always up-to-date regardless of debounce timing.

Closes ppy#36074
@itsdaliia itsdaliia marked this pull request as draft December 23, 2025 10:58
@itsdaliia
Copy link
Author

working on requested changes + attempting test coverage

Tests the fix for issue ppy#36074 where clicking the play button immediately after selecting a different difficulty would start the wrong beatmap due to the 150ms selection debounce.
@peppy
Copy link
Member

peppy commented Dec 26, 2025

Any reason this is draft? Also if you're happy with the new approach, please updated / empty the OP to match.

@itsdaliia itsdaliia marked this pull request as ready for review December 26, 2025 10:24
@itsdaliia
Copy link
Author

sorry @peppy, thought draft was appropriate since i was still updating it with the requested changes. marked it ready for review now and updated the description to match the new approach...

@itsdaliia itsdaliia requested a review from bdach December 26, 2025 10:28
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.

Selected beatmap doesn't switch when clicking osu! cookie before beatmap loads

3 participants