fix: Moves snapshot request synchronously (#2105)

This commit is contained in:
Kamron Batman 2025-02-02 13:07:28 -08:00 committed by GitHub
parent 717a1a062e
commit e64a632998
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View file

@ -517,11 +517,10 @@ public static class Core
DoKill(_restartOnKill);
}
// This is generally called from background threads during Preserialize
internal static void RequestSnapshot(string snapshotPath)
{
_snapshotPath = snapshotPath;
_performSnapshot = true; // Set this after the path so race conditions do not occur
_performSnapshot = true;
}
public static void VerifySerialization()

View file

@ -279,8 +279,6 @@ public static class World
private static void Preserialize(object state)
{
var tempPath = PathUtility.EnsureRandomPath(_tempSavePath);
try
{
// Allocate the heaps for the GC
@ -290,7 +288,9 @@ public static class World
}
WakeSerializationThreads();
Core.RequestSnapshot(tempPath);
// Execute this synchronously so we don't have a race condition
Core.LoopContext.Post(() => Core.RequestSnapshot(PathUtility.EnsureRandomPath(_tempSavePath)));
}
catch (Exception ex)
{