
LocalStorage or WebSQL unexpectedly cleared - ssddanbrown
https://bugs.chromium.org/p/chromium/issues/detail?id=1033655
======
WA
Chrome had a similar fuckup in April 2018. They changed the minimum granted
quota for IndexedDb. Suddenly, all Android devices with low free storage space
(< 1GB roughly) had a granted quota of 0. This of course led to all Android
WebView apps relying on IndexedDb to have no access to existing stored items
and no way to save new data.

It took them 6 weeks to push a fix. I used the opportunity to switch to Sqlite
and can only recommend others the same.

~~~
apatheticonion
This actually hit me really hard. I made a PWA I used to track certain stats
but the data wasn't so important that it needed to be stored in a database.

Instead I had an import/export for manual backups and assumed that the data
inside indexedDb wouldn't be dropped.

Bad assumption.

~~~
WA
Yes, same for me. Also a bad assumption I made: People probably have enough
storage space. The number of people running around with older devices that
have 16 GB of internal storage is still like 5% or so. Add 32 GB devices,
probably 10%. And most of them are constantly full.

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.

~~~
jessaustin
I'm trying to figure out if they deserve the punishment they get from Apple
for not installing itunes...

------
kbutler
Apple taught this lesson a few years ago, when iOS 5.1 changed the local
storage location: [https://phonegap.com/blog/2012/04/18/ios-5-1-and-the-
embedde...](https://phonegap.com/blog/2012/04/18/ios-5-1-and-the-embedded-
uiwebview-with-cordova/)

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/webdatabase/#privacy)
[https://www.w3.org/TR/webstorage/#user-
tracking](https://www.w3.org/TR/webstorage/#user-tracking)

So these browser storage mechanisms must be considered cache, not primary
storage of important data.

~~~
finaliteration
> 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.

------
webappguy
Blaming people for not using beta version for six weeks to test and inform
them prior of the issue. Rich. Millions of apps affected.

~~~
swsieber
That seems like an uncharitbale reading. A manager let people know that
they'll be able to tell if a new chrome release will affect them by testing
with beta. The overwhelming sentiment was "we're sorry".

~~~
ken
When Google introduced Chrome in 2008 (via comic!), they claimed that within
20-30 minutes of a beta build, it was automatically tested on tens of
thousands of the most popular webpages. Is that no longer true? Does that not
include any which use local storage?

~~~
gsnedders
AFAIK it is still true, but this bug is specifically with upgrading. Basically
all the testing occurs with an empty profile; migrations are specifically
undertested.

Also note that this bug only affected WebViews and not Chrome. Not sure how
testing of migrations compares between the two.

------
low_key
I was bit by this in a cordova app on a past update. After that I backed up
api keys, etc to native storage using a cordova plugin and added a wrapper
that will fall back to it if localstorage lookups fail.

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.

~~~
webappguy
Which plugin?

~~~
low_key
This plugin has worked reliably on both Android and iOS and has a simple api:

[https://github.com/TheCocoaProject/cordova-plugin-
nativestor...](https://github.com/TheCocoaProject/cordova-plugin-
nativestorage)

------
orf
Not to downplay the issue, but what a ridiculous bug report:

> 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.

~~~
beart
This could be an exhausted Customer Service manager. They tend to be a lot
less technical.

------
kmlx
i still don't understand the core issue: why is anyone saving essential data
to localstorage? isn't that supposed to be a state-related, somewhat temporary
(due to its nature) storage in-between the UI and the API/database? don't you
lose all your data when you use a different pc or smartphone?

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?

~~~
capableweb
Depends on the context. I've built Cordova/Phonegap apps in the past where you
want things to work offline and sync once the user goes online. If the time
from user going offline to online again is too long / device storage too
little, that data that would eventually need to be synced, would be lost.

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.

~~~
kmlx
agree. for the use case that you mentioned there would be a problem.

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.

------
McDev
Ouch! A recent Reddit post immediately came to mind:

[https://www.reddit.com/r/androiddev/comments/ea86jt/users_re...](https://www.reddit.com/r/androiddev/comments/ea86jt/users_reporting_wiped_data/)

------
Lex-2008
looks like a big f_ckup...

From comment #26:

> why it was missed: test apps that don't happen to use local storage will not
> _have_ a file created :(

~~~
C14L
Shouldn't test apps test _all_ possible files?

Sounds like a case of "who's testing the tests".

~~~
Thorrez
I think in this case the test coverage metric would have been handy to find
things that aren't being tested.

------
jsnell
Just how fast are Chrome rollouts on Android? Given how destructive this
appears to have been, it seems amazing that they got to a 50% rollout before
the first bug report.

------
r721
Real life consequences (from comment #63):

>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...](https://bugs.chromium.org/p/chromium/issues/detail?id=1033655#c63)

~~~
the_gipsy
Sounds like it's their fault for not backing up such important information.

~~~
jessaustin
"offline no-connection available"

Probably the veterinary work is not taking place at Starbucks...

------
erikrothoff
This has been happening in Chrome extensions for years now. I’ve tried
reporting it so many times. In our case it happens randomly so it’s impossible
to reproduce, which inevitably leads to ”issue closed - couldn’t reproduce”.

------
megous
Who uses localStorage for more than a local cache, or a short lived log of
records to be synced somewhere into some serious database asap?

That people are storing/losing:

\- years of financial data

\- animal vaccination records

\- etc.

because of this is so weird.

~~~
tracker1
Even then, it can still be used for offline data... you collect/perform tasks
without an internet connection and it syncs later. Chrome updates before data
sync, boom, all your data is gone.

Now, as for years of data, I mostly agree, this should absolutely be backed up
and/or synced more regularly.

~~~
curryst
That still seems like a poor design. This would also happen if you cleared
localStorage before the data is synced. If, for example, when you came back
online and were trying to do something on an unrelated site, hit a bug and
tech support asked you to clear your browser.

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.

------
dmitriid
This also servers as a warning for PWAs: despite all the hype and virtues
(real or perceived), your are at the hands of very fickle gods

~~~
cromwellian
Don't you have the same problems with native? It's like like no OS update ever
broke apps, or that Apple doesn't capriciously remove APIs, or reject you from
the app store sometimes for unexplained reasons.

Hell, people get broken by OSS ecosystem libraries a lot.

~~~
tsimionescu
True to some extent, though I don't think there have been many OS updates
which deleted all storage for all apps (well, moved to an inaccessible
place)... This really is a massive failure of QA and dev.

~~~
wbl
A friend of mine made a backup disk for her mac case sensitive. It backed up
fine, but refuses to restore.

