Skip to content

Commit

Permalink
Merge pull request #24548 from peppy/fix-score-copy-instability
Browse files Browse the repository at this point in the history
Fix score being cloned in async method causing random crashes
  • Loading branch information
bdach authored Aug 15, 2023
2 parents 526a145 + e8bde65 commit 4e96853
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,13 @@ private Task<ScoreInfo> prepareAndImportScoreAsync(bool forceImport = false)
if (!canShowResults && !forceImport)
return Task.FromResult<ScoreInfo>(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);
Expand Down

0 comments on commit 4e96853

Please sign in to comment.