1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-21 00:20:25 +08:00

Slightly delay retrieval of working beatmaps in song select panels

Beatmap panels can be visible for very brief instants.
`PanelSetBackground` has a backstop to prevent expensive background
loads which is based on the position of the panel relative to centre of
screen.

However, retrieving the working beatmap that *precedes* any of that
expensive background load logic, is *also* expensive, and *always* runs
even if a panel is visible on screen for only a brief second. Therefore,
by moving some of that background load delay towards delaying retrieving
the working beatmap, we can save on doing even more work, which has
beneficial implications for performance.
This commit is contained in:
Bartłomiej Dach
2025-10-21 14:51:21 +02:00
Unverified
parent dcb30ed5b3
commit 4ebd97b804
3 changed files with 11 additions and 3 deletions
+5 -1
View File
@@ -14,6 +14,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Collections;
@@ -38,6 +39,7 @@ namespace osu.Game.Screens.SelectV2
private Box chevronBackground = null!;
private PanelSetBackground setBackground = null!;
private ScheduledDelegate? scheduledBackgroundRetrieval;
private OsuSpriteText titleText = null!;
private OsuSpriteText artistText = null!;
@@ -191,7 +193,7 @@ namespace osu.Game.Screens.SelectV2
var beatmapSet = groupedBeatmapSet.BeatmapSet;
// Choice of background image matches BSS implementation (always uses the lowest `beatmap_id` from the set).
setBackground.Beatmap = beatmaps.GetWorkingBeatmap(beatmapSet.Beatmaps.MinBy(b => b.OnlineID));
scheduledBackgroundRetrieval = Scheduler.AddDelayed(s => setBackground.Beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.MinBy(b => b.OnlineID)), beatmapSet, 50);
titleText.Text = new RomanisableString(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title);
artistText.Text = new RomanisableString(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist);
@@ -204,6 +206,8 @@ namespace osu.Game.Screens.SelectV2
{
base.FreeAfterUse();
scheduledBackgroundRetrieval?.Cancel();
scheduledBackgroundRetrieval = null;
setBackground.Beatmap = null;
updateButton.BeatmapSet = null;
difficultiesDisplay.BeatmapSet = null;
@@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
@@ -55,6 +56,7 @@ namespace osu.Game.Screens.SelectV2
private CancellationTokenSource? starDifficultyCancellationSource;
private PanelSetBackground beatmapBackground = null!;
private ScheduledDelegate? scheduledBackgroundRetrieval;
private OsuSpriteText titleText = null!;
private OsuSpriteText artistText = null!;
@@ -222,7 +224,7 @@ namespace osu.Game.Screens.SelectV2
var beatmapSet = beatmap.BeatmapSet!;
beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(beatmap);
scheduledBackgroundRetrieval = Scheduler.AddDelayed(b => beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(b), beatmap, 50);
titleText.Text = new RomanisableString(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title);
artistText.Text = new RomanisableString(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist);
@@ -244,6 +246,8 @@ namespace osu.Game.Screens.SelectV2
{
base.FreeAfterUse();
scheduledBackgroundRetrieval?.Cancel();
scheduledBackgroundRetrieval = null;
beatmapBackground.Beatmap = null;
updateButton.BeatmapSet = null;
localRank.Beatmap = null;
@@ -149,7 +149,7 @@ namespace osu.Game.Screens.SelectV2
// - By using a slightly customised formula to decide when to start the load, we can coerce the loading of backgrounds into an order that
// prioritises panels which are closest to the centre of the screen. Basically, we want to load backgrounds "outwards" from the visual
// centre to give the user the best experience possible.
float timeUpdatingBeforeLoad = 50 + Math.Abs(containingSsdq.Centre.Y - ScreenSpaceDrawQuad.Centre.Y) / containingSsdq.Height * 100;
float timeUpdatingBeforeLoad = Math.Abs(containingSsdq.Centre.Y - ScreenSpaceDrawQuad.Centre.Y) / containingSsdq.Height * 100;
timeSinceUnpool += Time.Elapsed;