[webkit-changes] [WebKit/WebKit] 24e3d3: [ WK2 macOS ] http/wpt/cache-storage/cache-quota-a...

Sihui noreply at github.com
Thu Sep 7 14:02:24 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 24e3d351a10001635c28cceecdd6084942bc74e6
      https://github.com/WebKit/WebKit/commit/24e3d351a10001635c28cceecdd6084942bc74e6
  Author: Sihui Liu <sihui_liu at apple.com>
  Date:   2023-09-07 (Thu, 07 Sep 2023)

  Changed paths:
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
    M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp
    M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in
    M Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp

  Log Message:
  -----------
  [ WK2 macOS ] http/wpt/cache-storage/cache-quota-after-restart.any.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=259677
rdar://113189461

Reviewed by Youenn Fablet.

Web process sends NetworkConnectionToWebProcess::UpdateQuotaBasedOnSpaceUsageForTesting to network process to reset
quota based on usage. In the test, this happens before cache put operation (i.e. web process sends
NetworkStorageManager::CacheStoragePutRecords to network process), and it expects quota resetting to happen before put
operation.

However, NetworkConnectionToWebProcess messages are dispatched to the main thread of network process from IPC
thread, and NetworkStorageManager messages are dispatched to storage queue, which means put operation can happen
before quota is reset. In the failure case, here is what happens:
1. Network process main thread handles UpdateQuotaBasedOnSpaceUsageForTesting message, and dispatch a task to storage
queue.
2. Network process storage queue handles CacheStoragePutRecords messsage, starts put operation, performs quota check and
decides to ask UI process for a quota increase (with existing quota, e.g. 810KB).
3. Network process storage queue performs dipatched task , resetting usage to null and quota to initialQuoata
(e.g. 400KB), so that next quota check will fetch usage and update quota based on usage.
4. Network process receives new quota from UI process, updates its quota using new quota, and performs quota check again.
Since the test disallows quota increase, new quota will be the same as quota passed to UI process (i.e. 810KB). Then in
quota check, network process updates quota based on usage and defaultQuotaStep, which is 10% of current quota, i.e. 81KB.
However, the tests expects the defaultQuotaStep to be 40KB based on initialQuota.

To fix this issue, the patch moves the message to quota resetting message to NetworkStorageManager to ensure the
ordering of tasks. Now the quota resetting will always happen in the first quota check of put operation, and it uses
initialQuota for defaultQuotaStep.

* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::updateQuotaBasedOnSpaceUsageForTesting): Deleted.
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::resetQuotaUpdatedBasedOnUsageForTesting):
* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in:
* Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::updateQuotaBasedOnSpaceUsage):

Canonical link: https://commits.webkit.org/267748@main




More information about the webkit-changes mailing list