curiousdannii / parchment

The Interactive Fiction web app
https://iplayif.com
MIT License
421 stars 60 forks source link

Dialog stores data very inefficiently in localStorage #131

Open curiousdannii opened 1 year ago

curiousdannii commented 1 year ago

It was reported here that Counterfeit Monkey can have trouble saving/restoring save files, but it can happen to any storyfile: https://github.com/i7/counterfeit-monkey/issues/191. More discussion on the forum.

The issue is that the localStorage is getting too full to store the save file, which is about 150KB, out of the total 5MB that the browser can store. If you've been playing lots of things in Parchment then even if you haven't been making lots of save files there could be lots of autosaves taking up space. Then when you try to restore, it fails because the save file is empty.

Parchment/Dialog could be storing data in localStorage much more efficiently, and it could be using IndexedDB, which has much bigger limits (over a GB I think), and it could also be evicting autosaves to make space. I have plans to make those sorts of changes (#11), but they're not short term plans, it will take a lot of work to get everything ready.

What can we do about this?

curiousdannii commented 1 year ago

Here are all the calls to file_write and file_read:

This is a good sign: aside from emglkenfs.js, raw mode is only ever used to set an empty file. So I'm thinking I'll consider uses of file_write that write a raw text other than "" to be deprecated.