This is an RPG Maker MV plugin that uses a web worker to asynchronously compress data in a background thread. The data is then asynchronously saved to disk or browser storage. Link to the plugin & sample project on Github Is this a port of MZ's async code to MV? No! This code uses the same open-source external libraries as MZ (localforage and pako) so it is able to accomplish some of the same things. However the code is very clearly just MV with some "async" and "await" keywords thrown...
This is an RPG Maker MV plugin that uses a web worker to asynchronously compress data in a background thread. The data is then asynchronously saved to disk or browser storage.
Link to the plugin & sample project on Github
Is this a port of MZ's async code to MV?
No! This code uses the same open-source external libraries as MZ (localforage and pako) so it is able to accomplish some of the same things. However the code is very clearly just MV with some "async" and "await" keywords thrown in. No code was copy+pasted from MZ.
MZ's code does this:
- Saving is asynchronous
- Compressing save data is asynchronous, but uses the main thread
- Loading is asynchronous
Whereas this plugin does this:
- Saving is asynchronous
- Compressing save data is asynchronous AND uses a dedicated thread via a web worker
- Loading is synchronous like default MV
Is this code ready for production?
Probably not! I'm really only releasing it to inspire more talented people than me. Someone in the community must be a pro at using web workers, and I'd love to see them take this technology and really make it polished and stable.
UPDATE:
I've tested in these environments and it's been working fine:
- Windows, deployment
- Windows, latest Firefox
- Windows, latest Edge
- Mac, latest Safari
- Android, latest Chrome
How to use in your own project
- Copy js/libs/localforage.min.js and js/libs/pako.min.js into your own js/libs
Add script tags for localforage and pako into your index.html file
- Copy the files from js/plugins into your own project's plugins folder.
- Delete N_BloatSave if you don't want it. It's just for testing.
- Activate N_SaveManager in your plugin manager.
Changelog
- v1.0.6 Merged extra file into main plugin file (again).
- v1.0.5 Simplified backup so it doesn't decompress and then re-compress data unnecessarily.
- v1.0.4
- Simplified: Removed unneeded methods.
- Performance: Made creation of backups asynchronous.
- Performance: Moved coding and decoding data into worker.
- v1.0.3 Merged extra file into main plugin file.
- v1.0.2 Threads are now terminated immediately after they deliver their payload, preventing a memory leak.
- v1.0.1 Removed an unneeded function.
- v1.0.0 release.