From ff108416d86a920dbe9f652898c59b263f2379a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 May 2024 00:05:14 +0800 Subject: [PATCH] Fix incorrect background being loaded due to async race If the API login (and thus user set) completed between `load` and `LoadComplete`, the re-fetch on user change would not yet be hooked up, causing an incorrect default background to be used instead. Of note, moving this out of async load doesn't really affect load performance as the bulk of the load operation is already scheduled and `LoadComponentAsync`ed anyway --- osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index a552b22c11..090e006671 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -56,10 +56,6 @@ namespace osu.Game.Screens.Backgrounds introSequence = config.GetBindable(OsuSetting.IntroSequence); AddInternal(seasonalBackgroundLoader); - - // Load first background asynchronously as part of BDL load. - currentDisplay = RNG.Next(0, background_count); - Next(); } protected override void LoadComplete() @@ -73,6 +69,9 @@ namespace osu.Game.Screens.Backgrounds introSequence.ValueChanged += _ => Scheduler.AddOnce(next); seasonalBackgroundLoader.SeasonalBackgroundChanged += () => Scheduler.AddOnce(next); + currentDisplay = RNG.Next(0, background_count); + Next(); + // helper function required for AddOnce usage. void next() => Next(); }