np1810 / np1810.github.io

GitHub Webhost
MIT License
1 stars 1 forks source link

Saving move to storage exceeded quota #1

Open krishnans2006 opened 2 years ago

krishnans2006 commented 2 years ago

I have been playing the 2048 game here for the past few days, and have gotten a new high score in the process (thanks to the unlimited undo). However, as I was playing, the game suddenly stopped receiving input. By checking the console, I can see that it's because the local storage quota was exceeded.

I'd really love to continue this game, so I was wondering if it was possible to somehow handle this error - I'm not really sure how the storage quota works, but this could be as simple as removing really old moves from the storage (which would stop you from undo-ing infinitely, but I feel like after 9255 moves someone wouldn't want to go all the way back to move #1).

I've attached a video below showing the error and console - hope this helps! I've really loved unlimited undoing in 2048 with this site, and I really hope I can continue the game and get a personal best!

https://user-images.githubusercontent.com/62958782/180023654-30ba558a-5660-4dcc-8553-2152a20da0a6.mp4

np1810 commented 2 years ago

Wow, I never played this game so long, just until 2048 so I never thought anyone would encounter such storage exceeded issue. I'll look into this and put a fix soon enough to have a rolling window of 'n' depending on some computed value based on allowed storage).

Question for you: On page reload, does your game loads properly and you're able to undo 'x' moves and play again until you perform 'x' moves or is this not the case and all your progress has been unfortunately lost?

On Wed, 20 Jul, 2022, 9:13 pm Krishnan Shankar, @.***> wrote:

I have been playing the 2048 game here https://np1810.github.io/ for the past few days, and have gotten a new high score in the process (thanks to the unlimited undo). However, as I was playing, the game suddenly stopped receiving input. By checking the console, I can see that it's because the local storage quota was exceeded.

I'd really love to continue this game, so I was wondering if it was possible to somehow handle this error - I'm not really sure how the storage quota works, but this could be as simple as removing really old moves from the storage (which would stop you from undo-ing infinitely, but I feel like after 9255 moves someone wouldn't want to go all the way back to move #1 https://github.com/np1810/np1810.github.io/issues/1).

I've attached a video below showing the error and console - hope this helps! I've really loved unlimited undoing in 2048 with this site, and I really hope I can continue the game and get a personal best!

https://user-images.githubusercontent.com/62958782/180023654-30ba558a-5660-4dcc-8553-2152a20da0a6.mp4

— Reply to this email directly, view it on GitHub https://github.com/np1810/np1810.github.io/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBBJUMAQJ7VNOQSUVDNAHTVVANDPANCNFSM54EFMWZQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

krishnans2006 commented 2 years ago

Question for you: On page reload, does your game loads properly and you're able to undo 'x' moves and play again until you perform 'x' moves or is this not the case and all your progress has been unfortunately lost?

My game loads perfectly, and I'm able to undo as many moves as I want and keep playing until I reach the storage limit. I'm just not able to make a move after that point.

I really love this site, as it has no ads or unnecessary features and lets you simply practice playing the game. Thank You so much!

ogrotten commented 1 year ago

image

I just came across this as well. Well done that it errors nondestructively! Even if you didn't do it on purpose, it's clean enough code that it didn't fail catastrophically.

Suggestions

Quick Fix: looking at LocalStorage, looks like it's up over 9000! moves stored. I'll bet you could fix this by limiting it to 1000 or even 100. Personally, I never went back more than 20 moves AT THE VERY MOST. But having 1000 would be practically infinite.

Learner's Fix: You could switch over from LocalStorage to IndexedDB, which is the genetically superior offspring. It has practically universal support and no storage limit. DexieJS would be the library I would suggest for doing it like this. It behaves very much like a db/orm.

Last thing: I see you're storing grid.size. Had some big plans, eh? 🤣

Ok Good luck, and looking forward to being able to continue!