html5 exporting/importing save data

KeenWolf

Amateur Game Creator
Member
Joined
Mar 14, 2014
Messages
18
Reaction score
0
First Language
English
Primarily Uses
I have posted an experimental build of my game on itch.io to play in the browser, but for some odd reason some people cannot save their games if they are using iOS. This issue is not universal for a couple of my testers have iOS and can save just fine. I was working on a fix, but no luck so far until I came upon the idea of exporting and importing the save file from the browser. I like this idea, however I have been unsuccessful in getting it to work.

I followed this thread:
https://forums.rpgmakerweb.com/index.php?threads/html5-export-import-save-data.60506/
to get ideas, however the save and download function works fine, but what I am having issues with is getting the url since when it calls for the url it stops when it hits the period in itch.io which causes the error "itch is not defined".

I have not dealt much with JavaScript myself so I am not sure what I am doing wrong, but if anyone has any idea as to how to get this script to work or a better option for export/importing saves from html5 I would much appreciate the advise.

(Sidenote: I know almost nothing about iOS devices for I have never owned one.)
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,071
First Language
English
Primarily Uses
RMMV
The thread you've linked is about creating a way to download the save data from the browser as a file.

but for some odd reason some people cannot save their games if they are using iOS. This issue is not universal for a couple of my testers have iOS and can save just fine.
This seems different - if they can't save at all, then it won't help to download a save file (since they can't save... )

Here's some tips to troubleshoot them not being able to save.

1. Are these testers using Safari or Chrome?

You need to get the console log from them, search the Google for their specific browser / device. Example:
https://9to5google.com/2019/03/25/chrome-ios-debugging-tool/

2. It could be that itch puts the game in an IFrame which some browsers might block access to localStorage
 

KeenWolf

Amateur Game Creator
Member
Joined
Mar 14, 2014
Messages
18
Reaction score
0
First Language
English
Primarily Uses
I must apologize I just reread my post and appear to have been quite vague, for I was very tired last night.

It isn't that their game isn't saving at all, the for when they save if they use the menus to load/save game the save file is there, however the moment the browser is closed, refreshed, or the phone goes into sleep mode it will wipe the data.

Each person except 1 has attempted both chrome and safari and the issue happens on both browsers. For some it appears their site data and cookies are being cleared automatically, because everytime they go to play it asks for the password again, which shouldn't happen. however for a small few the password issue doesn't happen, but they still have no save data.

I searched all day yesterday for ways to prevent the auto clearing of data, but found that safari doesn't really have a way to do that through the options menu, only block cookies entirely.

The person who is able to save their game is also using safari, however I don't know if it means anything, but they are the only tester currently with an iPhone 7. The others have either the iPhone 6 or 8.

I will ask them to try and produce a console log next time I get a hold of them either tonight or tomorrow and post it here.
And thank you for the response, I've been banging my head off the wall trying to find a way for them to play the game without having to start over everytime.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,071
First Language
English
Primarily Uses
RMMV
Let's verify this to eliminate the possibility, so we can focus on the other possibilities.
It isn't that their game isn't saving at all, the for when they save if they use the menus to load/save game the save file is there
If they save, return to title menu, and load without closing the page -- does it load the save file correctly?


Other than that, the console log will probably be the most helpful.

To aid with your research, note that the RMMV save files are not stored in cookies, they are stored in localStorage. I don't think the phone version or browser version should be an issue, that feature has been supported by browsers for a long time.

All of this is assuming, of course, that your game uses the standard save functionality and you don't have any plugins that change how the games are saved.
 

KeenWolf

Amateur Game Creator
Member
Joined
Mar 14, 2014
Messages
18
Reaction score
0
First Language
English
Primarily Uses
Ok so I had 1 guy test this. Here are the steps he did:
1. He starts the game then goes to the menu to save.
2. Saves game then opens menu again to hit game end which takes him to the title screen.
3. He does have the continue option and is able to load the save correctly.
4. He refreshes the page, isn't asked to reenter the password, but the save file is gone and continue is grayed out on the title screen.

Now as far as the debugger goes, since I am ignorant to anything iOS and trying to get my tester to get me these things over the phone, I want to confirm the steps to get the log.
I have him open a page on chrome with chrome://inspect as the url, then have him follow the save steps again. After that I have him save/screenshot the log and send it to me to post here?

Regarding the plugin I am using Yanfly's Save Core:
http://yanfly.moe/2016/05/13/yep-100-save-core/
which to my knowledge doesn't change where the saves are done.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,071
First Language
English
Primarily Uses
RMMV
Yanfly plugins usually do more than you think, which is sometimes good and sometimes bad. Here's an excerpt from the Save Core that modifies how saves are created and where they are saved to.

Code:
//=============================================================================
// StorageManager
//=============================================================================

Yanfly.Save.StorageManager_isLocalMode = StorageManager.isLocalMode;
StorageManager.isLocalMode = function() {
  if (Yanfly.Param.SaveTechSaveMode === 'local') {
    if (!Utils.isNwjs()) return false;
    return true;
  } else if (Yanfly.Param.SaveTechSaveMode === 'web') {
    return false;
  } else {
    return Yanfly.Save.StorageManager_isLocalMode.call(this);
  }
};

StorageManager.localFilePath = function(savefileId) {
  var name;
  if (savefileId < 0) {
    name = Yanfly.Param.SaveTechLocalConfig;
  } else if (savefileId === 0) {
    name = Yanfly.Param.SaveTechLocalGlobal;
  } else {
    name = Yanfly.Param.SaveTechLocalSave.format(savefileId);
  }
  return this.localFileDirectoryPath() + name;
};

Yanfly.Save.StorageManager_webStorageKey = StorageManager.webStorageKey;
StorageManager.webStorageKey = function(savefileId) {
  if (!$dataSystem) return Yanfly.Save.StorageManager_webStorageKey.call(this);
  var title = $dataSystem.gameTitle;
  this.loadConfig();
  if (savefileId < 0) {
    return Yanfly.Param.SaveTechWebConfig.format(title);
  } else if (savefileId === 0) {
    return Yanfly.Param.SaveTechWebGlobal.format(title);
  } else {
    return Yanfly.Param.SaveTechWebSave.format(title, savefileId);
  }
};

StorageManager.loadConfig = function() {
  if (this._configLoaded) return;
  this._configLoaded = true;
  ConfigManager.load();
};

I don't use the Save Core personally so I can't comment on it, but I see that code is referencing the Plugin Parameters, so you'll want to check on those.

I also don't use iOS (I have Android) so I can't confirm the debugging steps.

Besides all this, your initial instinct that the localStorage is getting cleared by the browser is still a likely possibility, don't forget to follow-up on that.
To summarize, the current possibilities we've talked about are:
  1. Browser can't even save to localStorage in the first place (basically certain this is false due to your research)
  2. Browser is clearing localStorage (strange that it's not clearing cookies always too, those usually are cleared together)
  3. Yanfly plugin is changing where it's saved to
  4. itch.io specifically is doing something to block or clear access to localStorage (new possibility I just thought of)
 

KeenWolf

Amateur Game Creator
Member
Joined
Mar 14, 2014
Messages
18
Reaction score
0
First Language
English
Primarily Uses
Interesting, I never really dug into the code behind yanfly's plugins. I do see here that there are plugins allowing the change of web saves.

save core 1.png save core 2.png save core 3.png save core 4.png

I will play around with these settings to see if I can find a better way of saving for the iOS version of the game or just remove the plugin entirely to see if it will fix the issue, for I honestly do not need this one it just makes the save menu more aesthetically pleasing to look at.

Also I have given all the info you gave me to one of my testers to try and collect those logs from his browser and will post them when he sends them to me, which may be a bit since he is at work atm.

If I do find a fix then I will be sure to post it here and thanks again for all the help with this issue so far.
 

KeenWolf

Amateur Game Creator
Member
Joined
Mar 14, 2014
Messages
18
Reaction score
0
First Language
English
Primarily Uses
Alright, so testing different variables within the save_core plugin had no effect and taking the plugin out completely did nothing.

Here are the logs that debugger was able to collect as well as the site referenced within the log:
received_603963110090427.jpeg received_883868698640007.jpeg

It looks as though the path is being blocked, which is strnge that it only happens on some iPhones yet doesn't happen to the person using safari on the iPhone 7 nor any of the android users.

Edit: I was playing around in my chrome settings and found this following this path:
Settings> Site settings> Storage> https://v6p9d9t4.ssl.hwcdn.net

When I hit clear & reset on this it deletes only my save file but none of the assets that normally I have to sit and wait for to load from the .zip I put on itch.io are forced to reload. AKA the only thing deleted is my save.

With this knowledge I asked my friend to try and find the same thing, but found that chrome on iOS does not allow you to access the site data like the chrome on android. He could not find where that data is, but that data was in fact being referenced in the log he collected. Not sure how helpful this is, but it piqued my interest.
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,071
First Language
English
Primarily Uses
RMMV
PIXI.js is the library that renders the game assets in MV, so it is expected to see that (open the console in a test play and you will see that also). I was hoping to see some error messages, but it doesn't look like there were any.

One thing you could try is not having a space in your game name i.e. "Return Gate" --> "ReturnGate". The browser replaces spaces with "%20" which should work (yes, should), but there's a possibility that the space is messing up file paths if not all browsers handle it the same way. Best to at least eliminate that possibility.

Another option that could be a lot of work is try to publish the game somewhere besides itch.io. If I recall correctly, itch.io places the game inside an IFrame which may or may not have access to the browser localStorage.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Well, looks like I need to build myself a quest system. Or really just a system for "Helpful voices" to talk to the player. I'm sure nothing will go wrong listening to them.... They're "helpful". :LZSwink:

Should be pretty easy with PIXI just letting me write all over the screen. :LZSexcite:
I'm starting to think I just dont like anime since the last one I enjoyed was none of them.
Hi guys, Im new here. Im using RPGMMV. In this community i would like to learn more and become better rpg developer.
The main character for the first game was originally going to become a member of the party in the third game but I'm probably changing him to an important NPC instead. That brings the third game's total ensemble roster down to nine with one optional secret character.

Forum statistics

Threads
95,593
Messages
930,306
Members
125,896
Latest member
Yilou
Top