Skip to content

Changes to storage in emulator get lost on tab reload / browser crash #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ticalc-travis opened this issue Apr 13, 2025 · 2 comments
Open

Comments

@ticalc-travis
Copy link
Contributor

ticalc-travis commented Apr 13, 2025

I use the IDE with Chromium on Ubuntu (whichever version that is, but it should be reasonably up to date) and on two computers regularly have issues with the storage in the emulated Bangle getting reverted to its state days or even weeks earlier whenever I close the emulator window, disconnect from it, restart the browser, or have it crash. Only rarely does it seem to actually save the changes made in a working session, apparently at random.

I suspect an issue with the emulator flash not getting saved back to browser localStorage when it should. Looking at the code, it only seems to happen with window.onUnload, and apparently I guess this doesn't work reliably in Chromium. Probably better to also save it back every X minutes, or say, a few seconds after the last change to emulated storage was made.

Edit: For what it's worth, Chromium does give a warning that onUnload is deprecated.

@gfwilliams
Copy link
Member

Thanks for letting us know. It's an odd one as I've never really noticed it causing issues for me.

I think it should be reasonably easy to detect if storage has been changed so I guess you don't have to save it every few minutes unless it changed

Do you think you'd be able to attempt a fix? You should be able to just fork this repo and enable GitHub pages to self-host?

@ticalc-travis
Copy link
Contributor Author

I started to work on this and ran into an even bigger problem. Trying to save the flash storage gives the following exception from the browser:

Uncaught QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'BANGLE_STORAGE' exceeded the quota.
    at saveFlashIfChanged (common.js:27:20)
saveFlashIfChanged	@	common.js:27

Did some research and am hearing that there is a hardcoded limit of 5 MB for localStorage in Chrome/Chromium. And I think Bangle.js 2 is something like 8MB?

This doesn't seem trivially fixable. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants