LocalStorage or WebSQL unexpectedly cleared
bugs.chromium.org
bugs.chromium.org
It took them 6 weeks to push a fix. I used the opportunity to switch to Sqlite and can only recommend others the same.
Instead I had an import/export for manual backups and assumed that the data inside indexedDb wouldn't be dropped.
Bad assumption.
Btw. the same is true of older iOS devices. They are constantly almost out of space and there is not enough free space to update to the most recent iOS version. It'd probably work with iTunes, but many people don't install iTunes. So they're stuck with iOS 10, although their device would still be capable of running iOS 13, simply because they don't have enough free space.
But this behavior is within the range of spec compliance: "User agents may, possibly in a manner configured by the user, automatically delete stored data after a period of time." https://www.w3.org/TR/webdatabase/#privacy https://www.w3.org/TR/webstorage/#user-tracking
So these browser storage mechanisms must be considered cache, not primary storage of important data.
Maybe I’m an exception, but I’ve always viewed these storage mechanisms as unreliable. I primarily use them for storing things like user filter settings on a list view. It never even occurred to me to use them for anything critical.
Also note that this bug only affected WebViews and not Chrome. Not sure how testing of migrations compares between the two.
I would advise others to do the something similar since unless you are packaging the browser too (like crosswalk did), then that piece is really out of your control and you shouldn't expect it to be retained.
A similar issue can be seen on iOS under low storage conditions where the operating system will clear the browser cache to reclaim space.
https://github.com/TheCocoaProject/cordova-plugin-nativestor...
If I understand correctly, the scenario is that saved data in localStorage is lost, so that won't help.
> It causes such a big problem for our products!!!! Who is in charge?
I'd have expected more from a tech focused company like pocketpos.
To any app developers reading this, caring enough to read HN or similar puts you leagues above the kind of people I'm talking about.
i see a lot of mentions of cordova apps. are people publishing apps without a backend (and save everything in localstorage)?
i've worked on pwa's in the past but server sync was always a priority in my algorithms.
does anyone have any realistic use cases where localstorage is so essential that clearing it would somehow lose tons of data?
Always ways of working around it, like saving to files or whatever, but localStorage is a nice interface that works both for Cordova and client-side web apps.
but as you said, it could be overcome by using native apis that store state. it's even imperative in case of secrets, like access tokens and the like.
for client side web apps there's a bigger problem with localstorage. from my experience end users switch browsers and platforms. and they expect consistency from their web sites/apps. this expectation is much more intense than for native apps. so, while practical for developers, i'm not sure it's that welcomed in web land except for always having a local backup or as a temporary storage to alleviate network issues.
Yes. Why not? You can write a Cordova app that doesn't even have a backend.
but since every device is as persistent as its weakest point (e.g. physical damage, loss/theft, etc) shouldn't apps that need to save essential/important data basically give up the argument of persistence because of using localstorage in the first place? your data is one breakdown/loss away from permanent destruction when using localstorage exclusively.
that is why, from my experience, you always rely on the server and only use localstorage as a backup in case the server is down, there's no internet, etc.
claiming massive loss of data because localstorage got emptied is basically saying "our app wasn't designed correctly".
what am i missing?
localstorage disappearing overnight IS a bug. If I put stuff in My Documents folder on Windows and Windows decides to delete it, that IS a bug too. You could argue that I should have backups, and you would be right, but that's no reason for Windows to delete my files, and that is no reason for me to never use my hard disk.
regarding your comparison between a windows folder and localstorage feels a bit exaggerated.
yes, the Chrome team really fumbled it. and yes localstorage and important data should be mutually exclusive.
Local storage and/or SQL DB were touted as features for exactly this use case. That Google did not consider their persistence as that important for the release is perhaps not surprising for a company used to storing all your data in their cloud (not claiming they did so knowingly, just that it's probably in their culture, just as in your comments above).
but unfortunately i don't think your average user has any idea about what you wrote.
It seems like we could say "don't trust this" about any aspect of any platform. Categorizing every application as "really important, don't update the UI until securely written to three AZs" and "totally ephemeral purge every minute" excludes a lot of stuff in the middle. Sure, nothing made by humans is perfect, but many things could be improved. One improvement to localstorage would be to simply not delete all the data.
Saving stuff locally is good for privacy, for performance, for offline-capabilities. You can back up your entire phone LOCALLY, to have a solution of your stated problems (theft, physical damage).
never save important data on a single device. you simply delay the inevitable "i lost my data" scenario.
non-important data on the other hand should have no problems living on a single device. or even localstorage.
and as i said before, i don't think your average user has any ideas about backing up. that's why it almost always comes back to the developers to implement it.
I stored the data on the client using indexedDB, offering an export/import option for manual backups.
I wasn't interested in the data and it's simpler to just store it on the client rather than setting up the infrastructure required to centrally persist this information.
It's really unfortunate that it's not a reliable storage medium.
That's not what it's for, you're just misusing the tool for something it isn't meant to be. It's not a database, it's a cache.
If their app can avoid sending any data to a server and run fully in a web browser offline, they'll do that.
https://www.reddit.com/r/androiddev/comments/ea86jt/users_re...
From comment #26:
> why it was missed: test apps that don't happen to use local storage will not have a file created :(
Sounds like a case of "who's testing the tests".
>I heard from a company that uses localstorage for offline no-connection available that had local record of animals getting vaccionation. The update "erased" all the data. They don't know which animals got vaccine and can't repeat on all of them. Serious stuff.
https://bugs.chromium.org/p/chromium/issues/detail?id=103365...
3 copies of the data
2 copies on different storage mediums
1 backup in a separate location.
Ideally, a backup solution on the OS would target the browser profile itself at regular intervals, and you could allow the user to export the data into a file that can be downloaded by the browser (or copy/pasted).
It should be obvious that any form of browser storage is unreliable, and MUST be treated as such, and it should be EXPECTED to be deleted at a moments notice - setting such expectations encourages good practice at backing up your data incase of a failure.
Don't rely on others to ensure business critical data is stored and accessible - that's partially on the users/application to offer what they can.
Probably the veterinary work is not taking place at Starbucks...
That people are storing/losing:
- years of financial data
- animal vaccination records
- etc.
because of this is so weird.
Now, as for years of data, I mostly agree, this should absolutely be backed up and/or synced more regularly.
For something as critical as financial records or vaccine records, the sensible thing might be to not work in offline mode, or to persist to native storage.
I think it's fine as a cache for offline data for a lot of use cases (i.e. task trackers, note apps, shopping lists, etc). But it creates an unacceptable risk for business critical data, imo.
Much later a user (or less aware developer) finds the thing and starts using it.
Maybe software needs GHS labels like chemicals have.
Hell, people get broken by OSS ecosystem libraries a lot.
PS: google employee, used to work with torne every now and then, but no stake in the conversation anymore.
Browsers are platforms that are as complex as OSes these days. And any bugs or changes in how they work will affect you app if your app is PWA.
- It could be Chrome breaking audio: https://danshumway.com/blog/chrome-autoplay/
- It could be Chrome breaking LocalStorage: this discussion
- It could be Chrome removing support for a web standard that was implemented and shipped: https://www.chromestatus.com/feature/4642138092470272
I'm linking Chrome issues here because Chrome is the most visible of all browsers with the largest marketshare, but other browsers have their issues, too.
There are several polyfills available. Several Polymer versions targeted v0. Etc. etc.
It's not specifically Google's fault that they are removing support for these, but, once again, that's the state of the world: browsers are lrage complex platforms that may and will break your app.
While it's true that browser updates may break your app, it's also true that there are ways to write the app so as to minimize the risk of such breakage. Using Custom Elements V0 was _not_ a good way to avoid potential breakage...
That's why offsite data backups are a really good thing.
On most consumer OSes I honestly would trust the chrome developers to be more well behaved.