My games are using file system to save game progress (using FileUtils::getInstance()->getWritablePath(); and FileUtils::getInstance()->writeDataToFile). The savegames uses about 100k space.
On most devices everything is fine, but it appears on about 1/1000 devices that it does not work (Android only). I did a lot of debugging and what happens is that sometimes, the file end up 0 bytes. Sometimes, only half the save game was saved and so ending up with a corrupted savegame. Sometimes, it just does not save at all. It seems that it is related to either no space left (or out of inodes, but it is the same error message). Sometimes it is “no permission” (even though I am using internal data storage which I do have permission of course). Also, sometimes after a min or 2, the game suddenly start being able to save the game progress or can do it intermittently.
So the end result is some people will not notice it because it can start working again a bit later, some other less fortunate end up losing their game when they come back.
I tried a lot of different way to make it work, I tried doing a fflush before fclose, tried multiple retries, increasing buffer, nothing worked. I also keep 3 save games. So if one becomes corrupted, I have the previous one. But when the device cannot save at all, it does not help. I ended up showing a big warning message to the users when I cannot save the game asking them to cleanup some space.
So my questions are:
1: Is this normal behavior? Am I the only one facing this?
2: What do other games do when they cannot save the progress of the game? What is the best practice?
3: Would saving on game center/cloud remove this issue and make it more reliable? What if I face the same issue with game center, what should I do?
4: Any other best way to save progress that will ALWAYS work?
Thanks a lot.