Merge pull request #24548 from peppy/fix-score-copy-instability

Fix score being cloned in async method causing random crashes
This commit is contained in:
Bartłomiej Dach 2023-08-15 09:38:38 +02:00 committed by GitHub
commit 4e96853c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -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);