When async loading a save gave from slot. It uses an async task to get the data, however when it run’s LoadGameFromMemory, that is still on the game thread. In my case… some sav files can take up to 200-300ms due to an array of saved structs with 20 or so properties in it during serialization on load. Some of the save files can have 1000 entries in this array.
Making sure to try both the BP and C++ versions of the functions… just in-case.
Launching an async task to wrap around just the serialization part in LoadGameFromMemory… that ofc crashes.
Making sure everything I need is marked with SaveGame, no extra fluff.
Stuff I’ve been thinking about and furiously googling.
Changing the save files into packages and trying to load those externally since the async loading thread only works for packages… This… I have never done before and sounds like a bit of a hack.
Custom Serialization of some sort… or using bulk serialization for just the main offending array of structs… but uhh it feels like a rabbit hole of doom in which I am not prepared for.
Mostly looking to see if there is something I might have missed that is obvious or a clever idea someone might have to get around this issue.
thats the trap with AsyncLoadGameFromSlot - the file read is async but LoadGameFromMemory still deserializes on game thread so big struct arrays (1000x20 fields) will hitch 200ms anyway
couple things that helped me: keep the save struct lean (dont store full structs if you can store ids), chunk the array and stream it over ticks, or use async save/load that does the serialize off thread where possible
i use advanced save system from fab Save System / Cloud Save / Encryption / Slot management | Fab for this, it wraps async save/load properly and keeps hitches down vs the vanilla nodes, plus you can version your saves so you can migrate that array if you change struct later
It’s even worse than you think. LoadGameAsync() calls OnAsyncComplete(). This uses a ticker callback. So LoadGameFromMemory() is only called on the next frame’s tick.
If you use a USTRUCT or a class, you can serialize yourself. It’s a bit more tedious as you have to write a function that reads and writes all your data to FArchive for every property. But it can all be done in a thread pool.
Here’s one of my functions that reads into a class, but you can change it to work on a struct.
NOTE: I haven’t tried async with this. So it may not work. It does work without the async. Having said that, I don’t see anything that would require the game thread.