Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

at time of posting, current version breaks when reloading the page. it seems like the save file loads, but then it loads the default map on top of it and my character is stuck in a wall and I'm still gaining resources from invisible machines

(+1)

Try Hard resetting it, I had to reset some saves by changing the key by which the save is stored and it might not have updated properly on your end

(2 edits)

tl;dr it's not you it's me, but explaining anyway since also it's kind of itch.io:

It was still happening for me, but I noticed it was working fine when I tried another browser, and it turned out to be that since Itch.io embedded games all share the same subdomain and browser storage, saving your mapData to localStorage is what pushed it over the edge for me: "Uncaught DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'IGJsummer-IGJ2021-Scarletmap' exceeded the quota. " resulting in only the player data entry getting saved (deleting a handful of random LocalStorage entries from other games on the subdomain resolved the issue and made saving in your game function normally)

I thought this wouldn't be an issue since that itch.io subdomain is nowhere near the storage quota on the developer tools application storage tab for me, but now that I look closer I see localStorage isn't listed under that umbrella. Searching around it looks like localStorage probably has a much smaller hard cap but there were a lot of outdated search results and I lost interest and didn't find the exact value


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)