Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hmm I see, maybe I'll make it not save in that case then

(1 edit)

I find IndexedDB much more cumbersome to work with than LocalStorage, but for itch.io that's a "safer" place to save user data, with lower risk of key conflicts with other games (though the way you handled saving with a unique identifier here works fine of course) and gigabytes of shared storage instead of apparently megabytes


A much simpler solution would be to try/catch when saving to localStorage, and replace "game saved" notification with a "failed to save, check console for error", but "fixing" it at all is probably unnecessary, I don't know how much of an edge case "hitting max localstorage" is for people that play web games on itch

edit:
sorry, was curious so I investigated further, you can ignore this but thought I'd share if anyone was interested

tested a bit, and the total combined LocalStorage size, on both Firefox and Chrome, is 5 MB (can be a single entry that's 5 MB, or many smaller entries with some overhead for keys)

right now my "IGJsummer-IGJ2021-Scarletmap" string is 565,581 characters (566kb), using over 10% of the total combined LocalStorage that all itch.io games have to share. So it might be less of an edge case than I thought. I iterated over my LocalStorage to see what the biggest individual entries were. This is after I deleted a bunch of random entries to make room for yours (%s expressed as % of current total, not of max), but some stats:

  • Total # of LocalStorage entries: 539
  • Total combined charcount: 4,459,088
  • 81% of that was taken up by the top 12 biggest alone:
    • 1st: castle-builders (21.1% / 943k characters)
    • 2nd: IGJsummer-IGJ2021-Scarletmap (12.7% / 566k)
    • 3rd: json eventlog from an unknown game (storage key is just a UUID) (12.2% / 545k)
    • 4th-12th: a tie: various B64_SRAM_<gamename> entries (like B64_SRAM_YURIVANIA) from games made in gbstudio (3.92% / 175k each) (35.3% all 9 combined)

the real answer is itch.io needs to figure out their subdomains and sandbox each game creator's web games, somehow

 (still enjoying playing btw, about to get to 3rd building)