RESOLVED FIXED 245479
REGRESSION (iOS 16): LocalStorage is cleared after quota error
https://bugs.webkit.org/show_bug.cgi?id=245479
Summary REGRESSION (iOS 16): LocalStorage is cleared after quota error
Olexiy
Reported 2022-09-21 08:12:41 PDT
Created attachment 462504 [details] test script that is shown the problem IOS16 Safari: LocalStorage is cleared after writing data of more than ~2.5MB. After upgrading on IOS 16 we were faced the problem clearing data in localStorage.When we try to write data that size is more than ~2.5MB or all amount of data more than ~2.5MB the LocalStorage is being cleared without any errors and warnings in Safari. I could not reproduce the problem in other browsers or platforms. Step to reproduce: - Go to IOS 16 Safari - Open any website - try to write data more than ~2.5MB (the attached test script helps you to display the problem) - check your localStorage Actial result: your localStorage is empty Expected result: your localStorage should be filled your data or it should be thrown an exception if quota is exceeded Please consider the problem ASAP. Thank you in advance!
Attachments
test script that is shown the problem (832 bytes, text/javascript)
2022-09-21 08:12 PDT, Olexiy
no flags
Radar WebKit Bug Importer
Comment 1 2022-09-21 19:25:43 PDT
Sihui Liu
Comment 2 2022-09-27 10:43:55 PDT
EWS
Comment 3 2022-09-30 13:37:11 PDT
Committed 255044@main (0297f1253a4f): <https://commits.webkit.org/255044@main> Reviewed commits have been landed. Closing PR #4758 and removing active labels.
Olexiy
Comment 4 2022-10-03 00:45:03 PDT
Can you share the IOS version where the issue will be fixed? thank you in advance!
Ben Nham
Comment 5 2022-11-11 17:25:02 PST
I don't think this test script is correct. It measures the string length of all values in LocalStorage. But LocalStorage is persisted, and it's the size of the persisted string that matters for quota computations. Currently in WebKit, LocalStorage string values are persisted as UTF-16 (2 bytes per character)--see the call to SQLiteStatement::bindBlob(StringView) in SQLiteStorageArea::setItem. So I would expect that you could only store 2.5 million characters before exceeding your quota on disk.
Ben Nham
Comment 6 2022-11-11 21:15:57 PST
Note that Chrome implements LocalStorage in the exact same manner: string values are persisted as UTF-16, so they use 2 bytes per character. However, their quota for LocalStorage is 10 MB (https://chromiumcodereview.appspot.com/21680002), so when you run your test case, you can store 5 million characters. We could possibly address this by discussing whether it's a good idea to bump up our quota as well. However, given the current 5 MB quota, the fact that you can only store 2.5 million characters in your test case is intended and things are working as expected.
Sihui Liu
Comment 7 2022-11-14 09:46:44 PST
Reopened as 255044@main is reverted in https://bugs.webkit.org/show_bug.cgi?id=247767. As Ben mentioned, WebKit stores string in LocalStorage as UTF-16, so it is expected that 5MB quota only allows about 2.5 million characters. The was implemented way before iOS 16, so likely not a regression. However, this could still be a compatibility issue as Safari has different behavior than Chrome and Firefox, so we should keep this bug and figure out how to solve it.
Olexiy
Comment 8 2022-11-15 05:46:38 PST
This issue is a regression because localStorage is cleared when the amount of storage is reached more than 2.5 million characters. It could not be reproduced before ios16.
Sihui Liu
Comment 9 2022-11-15 10:18:50 PST
(In reply to Olexiy from comment #8) > This issue is a regression because localStorage is cleared when the amount > of storage is reached more than 2.5 million characters. It could not be > reproduced before ios16. Oh so the regression is "LocalStorage is cleared after quota error", not "LocalStorage throws quota error after writing 2.5 million characters". Updated title to reflect that.
Sihui Liu
Comment 10 2022-11-17 11:17:44 PST
EWS
Comment 11 2022-11-18 17:23:57 PST
Committed 256863@main (5bc131992783): <https://commits.webkit.org/256863@main> Reviewed commits have been landed. Closing PR #6597 and removing active labels.
Akif
Comment 12 2023-02-21 05:33:17 PST
It's even more broken in Safari Tech Preview https://bugs.webkit.org/show_bug.cgi?id=252661
Note You need to log in before you can comment on or make changes to this bug.