From e8bde6504a176c2cd138d721e267fa97db079520 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 Aug 2023 16:08:11 +0900 Subject: [PATCH] Fix score being cloned in async method causing random crashes Closes https://github.com/ppy/osu/issues/24445. --- osu.Game/Screens/Play/Player.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 5f8e061d89..8c5828fc92 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -810,10 +810,13 @@ namespace osu.Game.Screens.Play if (!canShowResults && !forceImport) return Task.FromResult(null); + // Clone score before beginning any async processing. + // - Must be run synchronously as the score may potentially be mutated in the background. + // - Must be cloned for the same reason. + Score scoreCopy = Score.DeepClone(); + return prepareScoreForDisplayTask = Task.Run(async () => { - var scoreCopy = Score.DeepClone(); - try { await PrepareScoreForResultsAsync(scoreCopy).ConfigureAwait(false);