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.
Prevent
IAssetEditor
andIAssetLoader
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.