Hi,
I've noticed that on occasion, specifically when I've left my game in the background for a while then return to it, data I've written to local storage isn't restored.
I'm pretty sure my code's correct - when one of the variables I store in local storage changes, I call a "save" function that writes all the variables I want to save to a dictionary, then saves that dictionary to local storage. When the game starts, I read the dictionary back from local storage, parse it, then update all the variables ready for the game to start.
If I just put the game into the background, then resume, all is fine (the game's still running, all the variables have their correct value and nothing is read back from local storage).
If I force quit the app and restart it, all is fine too. The game restarts and loads all the values correctly.
If I put the app into the background, then start load of other apps, come back to my game it restarts (as opposed to resuming) - this also works without issue.
It's almost as if iOS is caching the storage but if the app is left in the background for too long, it never actually gets written. I thought the last two scenarios above would replicate the issue, but they don't - it seems to only happen when the app has been in the background for a long time AND several apps have been opened in the mean time (presumably eating up all the RAM forcing my game to shutdown without saving the local storage).
This is on a 6th Gen iPad with iOS 17.5.1