Skip to content

Ensure global leaderboard state matches beatmap when loading player #33878

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

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jun 25, 2025

Closes #33835.

I love fixing issues multiple times.

Notably the refetch is not forced so this should be a no-op if the global state is already correct.

#33835 (comment) says

but we should also consider adding a force RunTask of the pending debounce before entering gameplay, probably around here:

selectionDebounce?.Cancel();

but I am not confident in making that change as I have no idea whether it is correct or not.

bdach added 2 commits June 25, 2025 09:47
Closes ppy#33835.

I love fixing issues multiple times.

Notably the refetch is not forced so this should be a no-op if the
global state is already correct.

ppy#33835 (comment) says

> but we should also consider adding a force `RunTask` of the pending debounce before entering gameplay, probably around here:
>
> https://github.com/ppy/osu/blob/3192eaa2a20f20495db8431d3d6f35af7c705a94/osu.Game/Screens/SelectV2/SongSelect.cs#L420

but I am not confident in making that change as I have no idea whether
it is correct or not.
@peppy
Copy link
Member

peppy commented Jun 25, 2025

but I am not confident in making that change as I have no idea whether it is correct or not.

I'd be inclined to make the change as a "makes sense" thing. Basically means song select has the correct beatmap on suspending, rather than potentially on resuming to song select and having it suddenly change. Okay if I add that in this PR? Doesn't seem to break any tests.

diff --git a/osu.Game/Screens/SelectV2/SongSelect.cs b/osu.Game/Screens/SelectV2/SongSelect.cs
index 744c990317..d65a8a49dd 100644
--- a/osu.Game/Screens/SelectV2/SongSelect.cs
+++ b/osu.Game/Screens/SelectV2/SongSelect.cs
@@ -417,6 +417,8 @@ private void detachTrackDucking()
         /// <param name="startAction">The action to perform if conditions are met to be able to proceed. May not be invoked if in an invalid state.</param>
         public void SelectAndRun(BeatmapInfo beatmap, Action startAction)
         {
+            if (selectionDebounce?.State == ScheduledDelegate.RunState.Waiting)
+                selectionDebounce?.RunTask();
             selectionDebounce?.Cancel();
 
             if (!this.IsCurrentScreen())

(Notably, it doesn't fix the issue, likely due to the leaderboard not being in a good state at that point to refetch the scores.)

@bdach
Copy link
Collaborator Author

bdach commented Jun 25, 2025

I mean sure you can add it but I'm not sure I can make much sense of that debounce stuff at all at this stage.

  • Nitpick but in your patch, if you're going to run the debounce inline if it's waiting, then why cancel it immediately afterwards?

  • Then there's also the other inline debounce execution in ensureGlobalBeatmapValid() that you added yesterday (and which I "smiled and nodded" at as the commit message suggested):

    if (selectionDebounce?.State == ScheduledDelegate.RunState.Waiting)
    selectionDebounce?.RunTask();

All of this has me in a place where I'm no longer sure of what's going on, or why this is being flushed and where.

@peppy
Copy link
Member

peppy commented Jun 25, 2025

You say yesterday, but the only change I can see is last week

873d622

Is this the one you're referring to?

The debounce is only there to stop the statistics on song select from updating too often. The rationale behind forcing it is so things are in a good state before/when leaving the screen.

I'll address this in a separate PR and tidy things up.

@peppy peppy merged commit d3296e0 into ppy:master Jun 25, 2025
8 checks passed
@bdach bdach deleted the leaderboard-ensure-correct-beatmap branch June 25, 2025 08:40
@bdach
Copy link
Collaborator Author

bdach commented Jun 25, 2025

You say yesterday, but the only change I can see is last week

873d622

Yeah I guess that's my mistake, authored a week ago, but I reviewed it yesterday.

@peppy
Copy link
Member

peppy commented Jun 25, 2025

Scratch that thought completely.

cancel is correct in this usage due to the subsequent highlighted code, which does the same thing as the debounce would have.

JetBrains Rider-EAP 2025-06-25 at 08 42 47

I'm still going to try and refactor this because that was not immediately obvious (and should have been).

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.

In-game leaderboards are wrong if switching to another map/diff and entering play too fast
2 participants