Load From/Save To Memory not using ArIsSaveGame flag

Hello,

We are implementing a save system to our game. I order to minimize memory impact we manually compress our actual save file “UOurSave” into another class “USaveContainer”. The container is then written to the disk.

See below:

UCLASS()
class UOurSaveGame: public USaveGame
{
};

UCLASS()
class USaveContainer: public USaveGame
{
UPROPERTY(SaveGame)
TArray<uint8> CompressedSave; // Contain a compressed version of UOurSaveGame. Will be loaded into the "SaveGame" field below

UPROPERTY()
TObjectPtr<UOurSaveGame> SaveGame;
};

The issue is that when the game start we do a “save discovery” process in the background, to find all the saves. But this causing a warning “The current loader ‘ZenLoader’ is unable to FlushAsyncLoading from the current thread ‘XXX’. Flush will be ignored.”

This is caused by the serialization of USaveContainer, triggering a LoadObject to load the UOurSaveGame class, that flush the async loads. But this class should not be included in the save file, as it is not flagged with the SaveGame UProperty.

Also note that we block Garbage Collection every time “LoadGameFromSlot / FromMemory” is called with FGCScopeGuard, and manually clear the Async flag from the returning UObject when we’re done, so that it can be collected afterward.

Adding the missing flag “Ar.ArIsSaveGame = true” in UGameplayStatics::LoadGameFromMemory() & UGameplayStatics::SaveGameToMemory() fixes the issue and prevent the log from occuring.

What is the reasoning behind not having the ArIsSaveGame flag in those function ?

Steps to Reproduce
Create a project with a UClass containing two UPROPERTY() field. One is a UObject not marked with the SaveGame attribute, the other is a uint32, marked with the SaveGame attribute.

Use `UGameplayStatics::SaveGameToSlot(“whatever”, 0)` to save it to disk.

Open the save file in a text editor, notice that both field, even the UObject not marked with SaveGame is present in the save file.

Use `UGameplayStatics::LoadGameFromSlot` on a background thread to reload the save, notice the red text in the console about an async flush occuring on the wrong thread

Hi,

ArIsSaveGame (along with the “SaveGame” property specifier) is intended to be used only by game-specific archive implementations, so the engine’s built-in save/load methods don’t use it. I believe the intention was to ensure the default methods provide as generic of an implementation as possible, while allowing projects to implement their own save systems better suited to their specific needs.

This related thread has some more info you may find helpful: [Content removed]

Thanks,

Alex