[webkit-changes] [WebKit/WebKit] 392584: Multiple in-flight CacheStorage.open calls create ...

bnham noreply at github.com
Wed Jul 19 21:15:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 392584f2a30c0055e53f5509bc3c2af2c9ac7c8c
      https://github.com/WebKit/WebKit/commit/392584f2a30c0055e53f5509bc3c2af2c9ac7c8c
  Author: Ben Nham <nham at apple.com>
  Date:   2023-07-19 (Wed, 19 Jul 2023)

  Changed paths:
    M Source/WebKit/NetworkProcess/storage/CacheStorageCache.cpp
    M Source/WebKit/NetworkProcess/storage/CacheStorageCache.h

  Log Message:
  -----------
  Multiple in-flight CacheStorage.open calls create duplicate responses in CacheStorageCache
https://bugs.webkit.org/show_bug.cgi?id=259348
rdar://112483324

Reviewed by Chris Dumez.

We've seen webpages that call `CacheStorage.open` with the same cache name hundreds of times in
quick succession.

This triggers a bug in `CacheStorageCache::open`. Each call to `CacheStorage::open` will enqueue a
block that essentially reads the entire contents of a directory into memory (via
`readAllRecordInfos`) until m_isInitialized is set. We then take the contents of that directory and
parse it into the `m_records` hash map, once for each time that block executes.

The end result is that `m_records` contains duplicate cached responses (one set of duplicate
responses each time `readAllRecordInfos` executes), which then makes all subsequent DOMCache use
much more memory than necessary.

To fix this, only execute the block in `CacheStorageCache::open` once. Subsequent calls to
`CacheStorageCache::open` now just append to a list of pending callbacks.

* Source/WebKit/NetworkProcess/storage/CacheStorageCache.cpp:
(WebKit::CacheStorageCache::~CacheStorageCache):
(WebKit::CacheStorageCache::open):
* Source/WebKit/NetworkProcess/storage/CacheStorageCache.h:

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




More information about the webkit-changes mailing list