increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 160 forks source link

saves being lost on itch.io embedded games with firefox / win 10 #436

Closed increpare closed 6 years ago

increpare commented 6 years ago

https://twitter.com/ElectronDance/status/978981399888834562

leafo commented 6 years ago

there are two ways to upload html games:

  1. upload directly single HTML file
  2. upload an index.html file in a zip file

For the first method, we generate a signed URL that expires. This means that each time the game is played a new URL is used to serve the file. The path component of the file does not change though, only the query parameters.

Example page: https://le-american.itch.io/lil-onion-detective Example embed url: https://talk.itch.zone/?expires=1522267493&id=739762&sig=3Rf9KeX5cQe4CuNDFScr1lLEvTc%3D (note this url is expired by now, so it will go back to the game page)

For the second method, we extract the zip to a new directory on our CDN, and a direct URL is used. These URLs are not protected in any way.

Example page: https://candle.itch.io/no-destination Example embed url: https://v6p9d9t4.ssl.hwcdn.net/html/606588/index.html


Both approaches have a domain that doesn't change, but I see that in the first method the same path is used for all games: /. The second approach uses a different path for each game's upload: /html/606588/index.html

I'm not familiar with how you're doing storage, but domains can have the same namespace for cookies/local storage. If you aren't prefixing the storage keys with an identifier then the game's data will conflict with other games.

It makes the most sense to use the path of the file as the key for the storage. The problem is that the talk.itch.zone urls all use the same path for every game! I think that we need to change this, and that could be the reason why saves aren't working?

starry-abyss commented 6 years ago

The progress is not saved for me on Newgrounds either: https://www.newgrounds.com/portal/view/710943

leafo commented 6 years ago

I've replaced how we handle single file .html games so that they work like games extracted from zip files. Each upload gets its own dedicated path, it should prevent collision of save data if it depends on the path.

Also, I added better autodetection of puzzlescript games, so you can find stuff to test easily :) https://itch.io/games/made-with-puzzlescript

increpare commented 6 years ago

To confirm (sorry I didn't do it earlier), I access

"localStorage[document.URL]"

or

"localStorage[document.URL+'_checkpoint']"

(in the case of a mid-game save), for save data.

2018-05-11 20:20 GMT+02:00 leaf notifications@github.com:

I've replaced how we handle single file .html games so that they work like games extracted from zip files. Each upload gets its own dedicated path, it should prevent collision of save data if it depends on the path.

Also, I added better autodetection of puzzlescript games, so you can find stuff to test easily :) https://itch.io/games/made-with-puzzlescript

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/increpare/PuzzleScript/issues/436#issuecomment-388445321, or mute the thread https://github.com/notifications/unsubscribe-auth/AAca4CTwtCWVJEHJ2ivI84znuobJsfs5ks5txdZogaJpZM4S-yPG .

increpare commented 6 years ago

Gonna close this issue. I think it's ok to have the save be url-dependent.

increpare commented 6 years ago

(if there's some other solution though that's not too site-specific, lemme know...)