Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e9650775a43554b06d3406b3a9a750451fbdc4a5
https://github.com/WebKit/WebKit/commit/e9650775a43554b06d3406b3a9a750451fbdc4a5
Author: Sihui Liu <[email protected]>
Date: 2023-02-07 (Tue, 07 Feb 2023)
Changed paths:
M Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp
M Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.h
Log Message:
-----------
Keep track of LocalStorage size in memory for quota computation
https://bugs.webkit.org/show_bug.cgi?id=251800
rdar://problem/105085248
Reviewed by Chris Dumez.
As stated in 259571@main, StorageAreaMap in web process performs quota check
differently from SQLiteStorageArea in
network process. StorageAreaMap uses item (Strings) size and compares size with
quota before write operation, while
SQLiteStorageArea sets size limit of database, and relies on SQLite to perform
check of database size on write
operation. Also, SQLiteStorageArea stores item value (String) as blob in
database, so characters will be upconverted and
take more space. Because of this difference, the two processes can have
different result on quota check. For example,
web process might think a write operation passes quota check and sends request
to network process, and network process
thinks it fails quota check.
The problem is SQLiteStorageArea currently tries to batch write operations in
transaction for performance and SQLite
could roll back transaction automatically when there is a quota error (see
https://www.sqlite.org/lang_transaction.html
and SQLITE_FULL). This means when quota error occurs, we might lose all changes
in the same transaction and will need to
read all items from database again (to sync cache in SQLiteStorageArea amd
StorageAreaMap), which can be costly and lead
to flakiness in tests like
imported/w3c/web-platform-tests/webstorage/storage_local_setitem_quotaexceedederr.window.html.
Therefore, this patch makes makes SQLiteStorageArea perform quota check the
same way as StorageAreaMap by keeping track
of items size and use it for quota computation. This will make write request
that passes quota check in web process less
likely to fail due to quota error and thus makes transaction less likely to be
rolled back.
* Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp:
(WebKit::SQLiteStorageArea::close):
(WebKit::SQLiteStorageArea::prepareDatabase):
(WebKit::SQLiteStorageArea::getItem):
(WebKit::SQLiteStorageArea::allItems):
(WebKit::SQLiteStorageArea::setItem):
(WebKit::SQLiteStorageArea::removeItem):
(WebKit::SQLiteStorageArea::clear):
(WebKit::SQLiteStorageArea::handleDatabaseCorruptionIfNeeded):
(WebKit::SQLiteStorageArea::updateCacheIfNeeded):
(WebKit::SQLiteStorageArea::requestSpace):
* Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.h:
Canonical link: https://commits.webkit.org/259995@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes