Prevent parallel asset loads/edits during save processing
Pathoschild opened this issue ยท 1 comments
Prevent IAssetEditor
and IAssetLoader
implementations from being called while the game is reading/writing a save (without preventing mods from editing or loading any assets).
Background
The game uses asynchronous logic to read/write the save file, so SMAPI blocks mod events until the asynchronous task is done to prevent errors with non-thread-safe data. However, IAssetEditor
/IAssetLoader
implementations still run during the async save/load. That can cause various cryptic errors (e.g. 'collection modified' or 'can't load PNG during draw loop' exceptions).
The attached mod and save files reproduces the issue. It has an IAssetEditor
to intercept tree images to patch in custom trees, which occasionally fails due to async race conditions.
Done with c8ae8c2 in SMAPI 2.6-beta.6.