Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

quota exceeded error for android deployment

doranikofu

Villager
Xy$
0.00
I have players telling me that when they play my android game they sometimes got this error when they have large numbers of save files:

QuotaExceededError
Failed to execute 'setItem' on 'Storage':
Setting the value of "RPG File 1' exceeded the quota.


I allowed the user to save 99 files. They said they start to see this error when saving. I also used autosave plugin (autosave when transferring to new map by Hudell), so sometimes it even crashes the game during autosave.

I looked up online and some posts are saying that there is a quota for all apps in android in internal storage. I wonder if there is a way to change the quota allowed for MV games when I deploy the game?
I also tried to look into ways to put save files in external storage, but I was told that this is impossible with the way MV is coded.

Not sure if anyone else had the same issue. If there is no other solution I will probably just need to restrict how many save slots the players can have in the future.
Thanks.
 

Xilefian

Adventurer
Xy$
0.00
I wrote a bit about the save data technique of MV here: RPG Maker MV: Android update deletes savegames!

You can, theoretically, change the save system to save to local storage for Android, but it requires majorly breaking Plugin compatibility. Alternatively, you could create a new Plugin that safely uses Android-specific methods for saving data to local storage, but of course you'll need to write some Android Java code for this.

What method did you use for creating your Android APK? If you used my Android MV Client then you'll have a few more options and flexibility to explore solving this issue. It's something I'd like to see someone resolve. I'm actually very tempted to add in Android local storage Javascript bindings so - if people wanted to - they can directly use Android local storage with the MV Android Client (and thus make a new save-data Plugin that changes to use this storage).

Sorry for all the waffling. I'm pretty much writing out my thoughts on this, as I have been thinking about it. Again, tell us what method you used for creating your Android app and we can better describe your options.

EDIT: To clarify potential issues, this QuotaExceededError happens in Javascript due to WebStorage limitations, so this issue will also happen for Web deployment and iOS deployment, it's not Android specific, however there are potential solutions for Android (and separately, iOS).
 
Last edited:

doranikofu

Villager
Xy$
0.00
I wrote a bit about the save data technique of MV here: RPG Maker MV: Android update deletes savegames!

You can, theoretically, change the save system to save to local storage for Android, but it requires majorly breaking Plugin compatibility. Alternatively, you could create a new Plugin that safely uses Android-specific methods for saving data to local storage, but of course you'll need to write some Android Java code for this.

What method did you use for creating your Android APK? If you used my Android MV Client then you'll have a few more options and flexibility to explore solving this issue. It's something I'd like to see someone resolve. I'm actually very tempted to add in Android local storage Javascript bindings so - if people wanted to - they can directly use Android local storage with the MV Android Client (and thus make a new save-data Plugin that changes to use this storage).

Sorry for all the waffling. I'm pretty much writing out my thoughts on this, as I have been thinking about it. Again, tell us what method you used for creating your Android app and we can better describe your options.

EDIT: To clarify potential issues, this QuotaExceededError happens in Javascript due to WebStorage limitations, so this issue will also happen for Web deployment and iOS deployment, it's not Android specific, however there are potential solutions for Android (and separately, iOS).
thanks for the reply. I indeed used your template and built apk in latest android studio. it is the best method i have seen and thanks again for that.

do you mean making a mv plugin to save to external storage? i am quite naive to the hard core of the code but i was told by my friend that the html code does not have permission to save to external storage. i also saw posts indicating that changing the file save functions is not trivial. So do you think there is option in android studio to change this?
 

Xilefian

Adventurer
Xy$
0.00
do you mean making a mv plugin to save to external storage?
I mean modifying the MV Android Client to allow saving to storage so then a Plugin can be made that adds the feature.

Permissions aren't a problem. You don't actually want to save to external storage, what you want is to save to internal storage, but not the web database (which is limited and can get trashed).

The file save functions are really simple and basic, whoever told you they're not trivial probably has very little experience with any code at all.

---

So what I've gone and done (because it's so easy) is make an experimental version of the MV Android Client that aims to add special Android features into Javascript. The experiment is a success, and I've actually gone and made a new save-file Plugin that uses the internal app storage for save-files, however Android's performance with one of the file handling functions is incredibly bad, so whilst the experiment proves the idea is good and will work (with additional Plugins, hopefully that's not a problem for you) it shows that there's a little more work required.

To give you an idea of how bad the performance is for this particular function; it takes 45 seconds for an MV game to load up on my Nexus 5X, previously it would be instant.

EDIT: And if you have 100 save files it would probably take 5 times longer than even 45 seconds. The bad performances hits every time the save screen is viewed too.
 

doranikofu

Villager
Xy$
0.00
that sounds very promising, thanks. So I assume the save files will be accessible to players without rooting? I see many other apps have such folders. I had many players complaining that they want to copy their save from pc version but cannot get to the save folder on Android.

For the lagging issue, I don't know if it is similar but I had issue loading save files when I pack my PC version into single exe files (for encryption). There are a few lines of codes that keep checking saving files. I commented them out and it sped up the loading. Maybe it can be helpful here:

Code:
//optimize loading, reduce file checking
DataManager.loadGlobalInfo = function() {
    var json;
    try {
        json = StorageManager.load(0);
    } catch (e) {
        console.error(e);
        return [];
    }
    if (json) {
        var globalInfo = JSON.parse(json);
     //   for (var i = 1; i <= this.maxSavefiles(); i++) {
    //        if (!StorageManager.exists(i)) {
    //            delete globalInfo[i];
    //        }
   //     }
        return globalInfo;
    } else {
        return [];
    }
};

//new function to remove bad saves only load at creation
DataManager.checkGlobalInfo = function() {
    var json;
    try {
        json = StorageManager.load(0);
    } catch (e) {
        console.error(e);
        return [];
    }
    if (json) {
        var globalInfo = JSON.parse(json);
        for (var i = 1; i <= this.maxSavefiles(); i++) {
            if (!StorageManager.exists(i)) {
                delete globalInfo[i];
            }
        }
        return globalInfo;
    } else {
        return [];
    }
};
//only check global save at start
Scene_File.prototype.start = function() {
    Scene_MenuBase.prototype.start.call(this);
    DataManager.checkGlobalInfo();
    this._listWindow.refresh();
};
 

Xilefian

Adventurer
Xy$
0.00
It is internal storage, so having direct access to save files is a difficult thing. You will need a rooted phone or you need advanced knowledge of Android ADB's APK backup feature.

I don't see why you need access to the save files themselves. If you want to test out your game, test it as normal, don't try to copy a save file from one system to another, that sounds like a recipe for a bad test to begin with.

What I can do is improve the debugging features; add the ability to set a "debug mode" flag so you can use a Bluetooth keyboard to walk-through-walls and access the normal debugging features. If people are really, really desperate for external save files then I can add that as a debugging switch too.

---

Yes those are the exact lines of code causing the bad performance. Nice find, I'm impressed.

I'd rather make a solution that works with the badly optimised original MV code, rather than rely on people modifying this part of the code - so it's up to you if you want to keep those "exists" checks or not.
 

doranikofu

Villager
Xy$
0.00
I released the pc version of my game first. Many players have save files from pc and they want to copy to android version.
Also some people want to use other people's save, or use cheats by editing save. I see how putting save in internal storage protects game but I don't need that because it is a standalone game anyways.

The save file check function can be useful for security reasons but I don't see it being that important for users who are just making games for fun (and for free).

Thanks again for the reply and looking forward to the new improvements.
 
Top