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

Daily Challenge Leaderboard starts from #0 after PB #31434

Open
424ever opened this issue Jan 6, 2025 · 2 comments
Open

Daily Challenge Leaderboard starts from #0 after PB #31434

424ever opened this issue Jan 6, 2025 · 2 comments

Comments

@424ever
Copy link
Contributor

424ever commented Jan 6, 2025

Type

Game behaviour

Bug description

After achieving a new personal best score on the Daily Challenge and scrolling the leaderboard to the left, it starts at #0.

Screenshots or videos

After PB score
pb_424ever

After non-PB score
nonpb_424ever

After first submitted score
image

Version

2025.101.0

Logs

compressed-logs.zip

@bdach
Copy link
Collaborator

bdach commented Jan 7, 2025

I can maybe see how this can happen, but it should have nothing to do with whether the score is the user best or not, and I'm not sure how to fix it.

The general gist of it is that the client only receives the leaderboard position of the score that was just set, and assigns positions to surrounding score by working backwards from the positions that it knows:

protected override APIRequest? FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback)
{
Debug.Assert(direction == 1 || direction == -1);
MultiplayerScores? pivot = direction == -1 ? higherScores : lowerScores;
if (pivot?.Cursor == null)
return null;
if (pivot == higherScores)
LeftSpinner.Show();
else
RightSpinner.Show();
return createIndexRequest(scoresCallback, pivot);
}
/// <summary>
/// Creates a <see cref="IndexPlaylistScoresRequest"/> with an optional score pivot.
/// </summary>
/// <remarks>Does not queue the request.</remarks>
/// <param name="scoresCallback">The callback to perform with the resulting scores.</param>
/// <param name="pivot">An optional score pivot to retrieve scores around. Can be null to retrieve scores from the highest score.</param>
/// <returns>The indexing <see cref="APIRequest"/>.</returns>
private APIRequest createIndexRequest(Action<IEnumerable<ScoreInfo>> scoresCallback, MultiplayerScores? pivot = null)
{
var indexReq = pivot != null
? new IndexPlaylistScoresRequest(RoomId, PlaylistItem.ID, pivot.Cursor, pivot.Params)
: new IndexPlaylistScoresRequest(RoomId, PlaylistItem.ID);
indexReq.Success += r =>
{
if (pivot == lowerScores)
{
lowerScores = r;
setPositions(r, pivot, 1);
}
else
{
higherScores = r;
setPositions(r, pivot, -1);
}
Schedule(() =>
{
PerformSuccessCallback(scoresCallback, r.Scores, r);
hideLoadingSpinners(r);
});
};
indexReq.Failure += _ => hideLoadingSpinners(pivot);
return indexReq;
}

Failure scenario I'm thinking of would go something like

  1. User sets a score ranked 102th and starts scrolling towards rank 1. The first page of results is fetched, where ranks are correct.
  2. In the mean time, someone sets a score at, say, rank 13. This means that the user's original score is now really ranked 103th.
  3. As the user scrolls towards rank 1, the client fetches the next page of scores, and at that point ranks are off by one because the original user score's rank is now stale and there's one more score to go through as the user scrolls backwards.

@ppy/team-web do you have any ideas on how we could make this not happen? I know from past discussions that position is rather expensive to include for every score. Maybe we can put one position marker in like the cursor response or something, so that the client can at least detect that this happened and attempt to course-correct?

@bdach bdach removed their assignment Jan 7, 2025
@nanaya
Copy link

nanaya commented Jan 7, 2025

technically the user's own score position is always included in the response...

(also if it's me I wouldn't worry about it and just renumber once the top score has been fetched)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants