Implement CodeCacheHost for inline script cache on Blink [chromium/src : main]

0 views
Skip to first unread message

Takashi Nakayama (Gerrit)

unread,
Mar 2, 2026, 6:20:31 AM (11 days ago) Mar 2
to Kouhei Ueno, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
Attention needed from Hiroshige Hayashizaki, Kouhei Ueno and Leszek Swirski

Takashi Nakayama voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
  • Kouhei Ueno
  • Leszek Swirski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4c319ba273e716e0703fc7e22becf4239c5558c2
Gerrit-Change-Number: 7621959
Gerrit-PatchSet: 7
Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Mon, 02 Mar 2026 11:19:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Greg Thompson (Gerrit)

unread,
Mar 3, 2026, 7:17:01 AM (10 days ago) Mar 3
to Takashi Nakayama, Kouhei Ueno, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
Attention needed from Hiroshige Hayashizaki, Kouhei Ueno, Leszek Swirski and Takashi Nakayama

Greg Thompson added 24 comments

Commit Message
Line 12, Patchset 9 (Latest):* Added a new method, `CodeCacheHost::FetchInlineScriptCacheSync()`, to comply with the HTML scripting specification. This function handles synchronous fetching of compiled code during the parsing phase. See crrev.com/c/7622052 for the usage.
Greg Thompson . unresolved

nit: wrap at 72 cols

File third_party/blink/renderer/platform/loader/fetch/code_cache_host.h
Line 36, Patchset 9 (Latest): // Fetch an inline script cache entry. `source_hash.size()` must equal to
Greg Thompson . unresolved
Line 26, Patchset 9 (Latest):// to the `mojo::Remote` and the data it holds reliy on the object being valid
Greg Thompson . unresolved

while you're here: "rely" :-)

File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
Line 120, Patchset 9 (Latest): DCHECK(inline_script_cache_fetch_state_);
Greg Thompson . unresolved

why this? the member is set in the ctor and never cleared. i don't find this check necessary. (`scoped_refptr<>::operator->()` will do its own `DCHECK`, too.)

if you do think it's necessary, please switch to `CHECK` as per https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c%2B%2B/c%2B%2B.md#check_dcheck_and-notreached

Line 121, Patchset 9 (Latest): CHECK(features::IsInlineScriptCacheEnabled());
Greg Thompson . unresolved

is it necessary to have this here? it just means one more thing that needs to be touched if/when the feature is removed.

Line 135, Patchset 9 (Latest): .WithArgs(cache_type, source_hash,
Greg Thompson . unresolved

if the timeout is reached before `FetchSourceKeyedCachedCode` finishes using `source_hash`, we'll have a UaF on this memory. i think you'll need something like `base::HeapArray::CopiedFrom(source_hash)` so that the callback owns a copy of the hash digest.

Line 143, Patchset 9 (Latest): if (!source_keyed_cache_result) {
return {};
} else {
return std::move(source_keyed_cache_result.value());
}
Greg Thompson . unresolved

`return std::move(source_keyed_cache_result).value_or({});`

or, equivalently, do away with the local:

```
return inline_script_cache_fetch_state_
->WaitForFetchResultSync(features::kInlineScriptCacheTimeout.Get())
.value_or({});
```
maybe you'll need to spell out `mojo_base::BigBuffer()` in place of `{}`.
Line 248, Patchset 9 (Latest): CHECK(features::IsInlineScriptCacheEnabled());
Greg Thompson . unresolved

remove this? (see comment above)

Line 278, Patchset 9 (Latest): case mojom::blink::CodeCacheType::kWebAssembly:
Greg Thompson . unresolved

is there such a thing as inline wasm? if not, shall we simplify and make this js-only?

Line 440, Patchset 9 (Latest): void HandleTransactionError(persistent_cache::TransactionError error) {
Greg Thompson . unresolved

`VALID_CONTEXT_REQUIRED(sequence_checker_)` up here in place of the DCHECK on line 441

Line 480, Patchset 9 (Latest): // Start connection to the backend to
Greg Thompson . unresolved

incomplete comment

Line 482, Patchset 9 (Latest): InitiateConnectionToBackend();
Greg Thompson . unresolved

Do you know what proportion of pages contain inline scripts? This will create a backend proactively, which will cause the browser to reach the PersistentCacheCollection's capacity sooner. This could lead to more cache misses for other renderers as their backends are abandoned.

Line 502, Patchset 9 (Latest): base::ScopedClosureRunner cleanup(base::BindOnce(
Greg Thompson . unresolved

as far as i can tell, this `cleanup` will never run the callback. wdyt of removing this and instead putting `CHECK(!callback);` at the end of the function? That won't catch early returns, but it's better than nothing if you're concerned about someone missing running the callback in the future.

Line 503, Patchset 9 (Latest): [](base::OnceCallback<void(mojo_base::BigBuffer)>* callback) {
Greg Thompson . unresolved

nit: pass by reference and use `std::ref(callback)` rather than `base::Unretained` below.

Line 510, Patchset 9 (Latest): DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Greg Thompson . unresolved

nit: move to the top of the function

Line 511, Patchset 9 (Latest): if (!features::IsInlineScriptCacheEnabled()) {
std::move(callback).Run({});
return;
}
Greg Thompson . unresolved

Doesn't the `CHECK` on line 121 mean that this could never happen? I don't think we need to check this here.

Line 589, Patchset 9 (Latest): void InitiateConnectionToBackend() {
Greg Thompson . unresolved

`VALID_CONTEXT_REQUIRED(...)` here, too

Line 599, Patchset 9 (Latest): void HandleTransactionError(persistent_cache::TransactionError error) {
Greg Thompson . unresolved

`VALID_CONTEXT_REQUIRED(...)` here, too

Line 663, Patchset 9 (Latest): // Advance the current nonce and prepare for the next cache lookup. This
Greg Thompson . unresolved

nit: "Advances... and prepares..." as per style guide

Line 669, Patchset 9 (Latest): ++current_nonce_;
Greg Thompson . unresolved

`CHECK_NE(++current_nonce_, 0ULL);`

Line 669, Patchset 9 (Latest): ++current_nonce_;
Greg Thompson . unresolved

consider: `result_ = mojo_base::BigBuffer();` to clear a value left behind by a previous fetch for which the requestor timed out.

Line 690, Patchset 9 (Latest): }
Greg Thompson . unresolved

consider `result_ = mojo_base::BigBuffer();` as above

Line 709, Patchset 9 (Latest): bool GUARDED_BY(lock_) is_destroyed_ = false;
Greg Thompson . unresolved

consider removing `is_destroyed_`:

  • initialize `current_nonce_` to `1` below
  • set `current_nonce_` to `0` in `OnMainThreadDestroyed`
  • change `!is_destroyed_` checks to `current_nonce_ != 0`
Line 709, Patchset 9 (Latest): bool GUARDED_BY(lock_) is_destroyed_ = false;
Greg Thompson . unresolved

very optional nit: i'm not sure that it matters, but i usually see this after the member name; see https://source.chromium.org/search?q=GUARDED_BY%20f:%5Ebase%20f:%5C.h

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
  • Kouhei Ueno
  • Leszek Swirski
  • Takashi Nakayama
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c319ba273e716e0703fc7e22becf4239c5558c2
    Gerrit-Change-Number: 7621959
    Gerrit-PatchSet: 9
    Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
    Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Tue, 03 Mar 2026 12:16:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hiroshige Hayashizaki (Gerrit)

    unread,
    Mar 3, 2026, 7:35:07 PM (9 days ago) Mar 3
    to Takashi Nakayama, Greg Thompson, Kouhei Ueno, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Kouhei Ueno, Leszek Swirski and Takashi Nakayama

    Hiroshige Hayashizaki added 2 comments

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 120, Patchset 9 (Latest): DCHECK(inline_script_cache_fetch_state_);
    Greg Thompson . unresolved

    why this? the member is set in the ctor and never cleared. i don't find this check necessary. (`scoped_refptr<>::operator->()` will do its own `DCHECK`, too.)

    if you do think it's necessary, please switch to `CHECK` as per https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c%2B%2B/c%2B%2B.md#check_dcheck_and-notreached

    Hiroshige Hayashizaki

    nit: making `inline_script_cache_fetch_state_` const (`const scoped_refptr<HostStateForInlineScriptCacheLookup>`) would clarify this.

    Line 121, Patchset 9 (Latest): CHECK(features::IsInlineScriptCacheEnabled());
    Greg Thompson . unresolved

    is it necessary to have this here? it just means one more thing that needs to be touched if/when the feature is removed.

    Hiroshige Hayashizaki

    I weakly prefer adding this kind of `CHECK()` to clarify which parts of code are behind the flag, but I defer to Greg and tnak@.

    Open in Gerrit

    Related details

    Attention is currently required from:
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Wed, 04 Mar 2026 00:34:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hiroshige Hayashizaki (Gerrit)

    unread,
    Mar 3, 2026, 7:40:19 PM (9 days ago) Mar 3
    to Takashi Nakayama, Greg Thompson, Kouhei Ueno, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Kouhei Ueno, Leszek Swirski and Takashi Nakayama

    Hiroshige Hayashizaki added 1 comment

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 278, Patchset 9 (Latest): case mojom::blink::CodeCacheType::kWebAssembly:
    Greg Thompson . unresolved

    is there such a thing as inline wasm? if not, shall we simplify and make this js-only?

    Hiroshige Hayashizaki

    +1

    Gerrit-Comment-Date: Wed, 04 Mar 2026 00:40:10 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Takashi Nakayama (Gerrit)

    unread,
    4:14 AM (18 hours ago) 4:14 AM
    to Greg Thompson, Kouhei Ueno, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Greg Thompson, Hiroshige Hayashizaki, Kouhei Ueno and Leszek Swirski

    Takashi Nakayama voted and added 23 comments

    Votes added by Takashi Nakayama

    Commit-Queue+1

    23 comments

    Commit Message
    Line 12, Patchset 9:* Added a new method, `CodeCacheHost::FetchInlineScriptCacheSync()`, to comply with the HTML scripting specification. This function handles synchronous fetching of compiled code during the parsing phase. See crrev.com/c/7622052 for the usage.
    Greg Thompson . resolved

    nit: wrap at 72 cols

    Takashi Nakayama

    Done

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.h
    Line 36, Patchset 9: // Fetch an inline script cache entry. `source_hash.size()` must equal to
    Greg Thompson . resolved
    Takashi Nakayama

    Done

    Line 26, Patchset 9:// to the `mojo::Remote` and the data it holds reliy on the object being valid
    Greg Thompson . resolved

    while you're here: "rely" :-)

    Takashi Nakayama

    Done

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 120, Patchset 9: DCHECK(inline_script_cache_fetch_state_);
    Greg Thompson . resolved

    why this? the member is set in the ctor and never cleared. i don't find this check necessary. (`scoped_refptr<>::operator->()` will do its own `DCHECK`, too.)

    if you do think it's necessary, please switch to `CHECK` as per https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c%2B%2B/c%2B%2B.md#check_dcheck_and-notreached

    Hiroshige Hayashizaki

    nit: making `inline_script_cache_fetch_state_` const (`const scoped_refptr<HostStateForInlineScriptCacheLookup>`) would clarify this.

    Takashi Nakayama

    Removed `DCHECK` and made `inline_script_cache_fetch_state_` const.

    Line 121, Patchset 9: CHECK(features::IsInlineScriptCacheEnabled());
    Greg Thompson . resolved

    is it necessary to have this here? it just means one more thing that needs to be touched if/when the feature is removed.

    Hiroshige Hayashizaki

    I weakly prefer adding this kind of `CHECK()` to clarify which parts of code are behind the flag, but I defer to Greg and tnak@.

    Takashi Nakayama

    Not necessary, but I would prefer these kind of `CHECK()` to prevent the feature is incorrectly used when the flag is disabled.

    Line 135, Patchset 9: .WithArgs(cache_type, source_hash,
    Greg Thompson . unresolved

    if the timeout is reached before `FetchSourceKeyedCachedCode` finishes using `source_hash`, we'll have a UaF on this memory. i think you'll need something like `base::HeapArray::CopiedFrom(source_hash)` so that the callback owns a copy of the hash digest.

    Takashi Nakayama

    I hadn't noticed that. Thank you for pointing that out! Changed the second argument type of `AsyncCodeCacheHost::FetchSourceKeyedCachedCode` to `base::HeapArray<uint8_t>` and changed the caller code accordingly. PTAL.

    Line 143, Patchset 9: if (!source_keyed_cache_result) {

    return {};
    } else {
    return std::move(source_keyed_cache_result.value());
    }
    Greg Thompson . resolved

    `return std::move(source_keyed_cache_result).value_or({});`

    or, equivalently, do away with the local:

    ```
    return inline_script_cache_fetch_state_
    ->WaitForFetchResultSync(features::kInlineScriptCacheTimeout.Get())
    .value_or({});
    ```
    maybe you'll need to spell out `mojo_base::BigBuffer()` in place of `{}`.
    Takashi Nakayama

    Removed this code by changing the return type of `FetchInlineScriptCacheSync()` to `std::optional<...>`.

    Line 248, Patchset 9: CHECK(features::IsInlineScriptCacheEnabled());
    Greg Thompson . resolved

    remove this? (see comment above)

    Takashi Nakayama

    ditto

    Line 278, Patchset 9: case mojom::blink::CodeCacheType::kWebAssembly:
    Greg Thompson . unresolved

    is there such a thing as inline wasm? if not, shall we simplify and make this js-only?

    Hiroshige Hayashizaki

    +1

    Takashi Nakayama

    Removed the support for WASM. PTAL

    Line 440, Patchset 9: void HandleTransactionError(persistent_cache::TransactionError error) {
    Greg Thompson . resolved

    `VALID_CONTEXT_REQUIRED(sequence_checker_)` up here in place of the DCHECK on line 441

    Takashi Nakayama

    Done

    Line 480, Patchset 9: // Start connection to the backend to
    Greg Thompson . unresolved

    incomplete comment

    Takashi Nakayama

    Updated (and moved to `RemoteCache::RemoteCache()`). PTAL

    Line 502, Patchset 9: base::ScopedClosureRunner cleanup(base::BindOnce(
    Greg Thompson . resolved

    as far as i can tell, this `cleanup` will never run the callback. wdyt of removing this and instead putting `CHECK(!callback);` at the end of the function? That won't catch early returns, but it's better than nothing if you're concerned about someone missing running the callback in the future.

    Takashi Nakayama

    Removed `cleanup` as you suggested. I added this to prevent unintentional stuck of the main thread before implementing the safety timeout on the main thread. It is safe to remove the code now. Thanks!

    Line 503, Patchset 9: [](base::OnceCallback<void(mojo_base::BigBuffer)>* callback) {
    Greg Thompson . resolved

    nit: pass by reference and use `std::ref(callback)` rather than `base::Unretained` below.

    Takashi Nakayama

    Acknowledged

    Line 510, Patchset 9: DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    Greg Thompson . resolved

    nit: move to the top of the function

    Takashi Nakayama

    Done

    Line 511, Patchset 9: if (!features::IsInlineScriptCacheEnabled()) {
    std::move(callback).Run({});
    return;
    }
    Greg Thompson . resolved

    Doesn't the `CHECK` on line 121 mean that this could never happen? I don't think we need to check this here.

    Takashi Nakayama

    ditto. (There is a slight difference. The `CHECK` in `FetchInlineScriptCacheSync()` runs in the main thread while this is `CHECK` running in the worker thread.)

    Line 589, Patchset 9: void InitiateConnectionToBackend() {
    Greg Thompson . resolved

    `VALID_CONTEXT_REQUIRED(...)` here, too

    Takashi Nakayama

    Done

    Line 599, Patchset 9: void HandleTransactionError(persistent_cache::TransactionError error) {
    Greg Thompson . resolved

    `VALID_CONTEXT_REQUIRED(...)` here, too

    Takashi Nakayama

    Done

    Line 663, Patchset 9: // Advance the current nonce and prepare for the next cache lookup. This
    Greg Thompson . resolved

    nit: "Advances... and prepares..." as per style guide

    Takashi Nakayama

    Done

    Line 669, Patchset 9: ++current_nonce_;
    Greg Thompson . resolved

    `CHECK_NE(++current_nonce_, 0ULL);`

    Takashi Nakayama

    As my comment in crrev.com/c/7621959/comment/4e757857_cadf9930/, I don't think this is necessary. Please feel free to reopen this thread if necessary.

    Line 669, Patchset 9: ++current_nonce_;
    Greg Thompson . resolved

    consider: `result_ = mojo_base::BigBuffer();` to clear a value left behind by a previous fetch for which the requestor timed out.

    Takashi Nakayama

    Done

    Greg Thompson . unresolved

    consider `result_ = mojo_base::BigBuffer();` as above

    Takashi Nakayama

    I understand your concern, but I want to keep this function as simple as possible because this is called in the destructor. WDYT?

    Line 709, Patchset 9: bool GUARDED_BY(lock_) is_destroyed_ = false;
    Greg Thompson . resolved

    very optional nit: i'm not sure that it matters, but i usually see this after the member name; see https://source.chromium.org/search?q=GUARDED_BY%20f:%5Ebase%20f:%5C.h

    Takashi Nakayama

    Done

    Line 709, Patchset 9: bool GUARDED_BY(lock_) is_destroyed_ = false;
    Greg Thompson . unresolved

    consider removing `is_destroyed_`:

    • initialize `current_nonce_` to `1` below
    • set `current_nonce_` to `0` in `OnMainThreadDestroyed`
    • change `!is_destroyed_` checks to `current_nonce_ != 0`
    Takashi Nakayama

    I don't think one variable having two meaning is a good way if there are no performance issues. WDYT?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Greg Thompson
    • Hiroshige Hayashizaki
    • Kouhei Ueno
    • Leszek Swirski
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c319ba273e716e0703fc7e22becf4239c5558c2
    Gerrit-Change-Number: 7621959
    Gerrit-PatchSet: 13
    Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
    Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Greg Thompson <g...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Thu, 12 Mar 2026 08:13:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Hiroshige Hayashizaki <hiro...@chromium.org>
    Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Greg Thompson (Gerrit)

    unread,
    6:22 AM (16 hours ago) 6:22 AM
    to Takashi Nakayama, Kouhei Ueno, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Hiroshige Hayashizaki, Kouhei Ueno, Leszek Swirski and Takashi Nakayama

    Greg Thompson added 8 comments

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 119, Patchset 13 (Latest): CHECK_EQ(source_hash.size(), kSha256Bytes);
    Greg Thompson . unresolved

    `source_hash` is now a fixed-extent span, so this `CHECK` is no longer needed, no?

    Line 135, Patchset 9: .WithArgs(cache_type, source_hash,
    Greg Thompson . resolved

    if the timeout is reached before `FetchSourceKeyedCachedCode` finishes using `source_hash`, we'll have a UaF on this memory. i think you'll need something like `base::HeapArray::CopiedFrom(source_hash)` so that the callback owns a copy of the hash digest.

    Takashi Nakayama

    I hadn't noticed that. Thank you for pointing that out! Changed the second argument type of `AsyncCodeCacheHost::FetchSourceKeyedCachedCode` to `base::HeapArray<uint8_t>` and changed the caller code accordingly. PTAL.

    Greg Thompson

    great!

    Line 161, Patchset 13 (Latest): mojom::blink::CodeCacheType cache_type,
    Greg Thompson . unresolved

    can we remove this from the mojom interface since we only support JS?

    Line 278, Patchset 9: case mojom::blink::CodeCacheType::kWebAssembly:
    Greg Thompson . resolved

    is there such a thing as inline wasm? if not, shall we simplify and make this js-only?

    Hiroshige Hayashizaki

    +1

    Takashi Nakayama

    Removed the support for WASM. PTAL

    Greg Thompson

    ty!

    Line 480, Patchset 9: // Start connection to the backend to
    Greg Thompson . resolved

    incomplete comment

    Takashi Nakayama

    Updated (and moved to `RemoteCache::RemoteCache()`). PTAL

    Greg Thompson

    Acknowledged

    Line 495, Patchset 13 (Latest): void HandleTransactionError(persistent_cache::TransactionError error)
    Greg Thompson . unresolved

    nit: blank line before this

    Greg Thompson . unresolved

    consider `result_ = mojo_base::BigBuffer();` as above

    Takashi Nakayama

    I understand your concern, but I want to keep this function as simple as possible because this is called in the destructor. WDYT?

    Greg Thompson

    my observation is that it's called from `~CodeCacheWithPersistentCacheHostImpl`, but `HostStateForInlineScriptCacheLookup` itself is a refcounted object so it could live longer. if it happens that `OnMainThreadDestroyed` is called while `result_` holds a hunk of memory, we may as well release the memory now. i don't think it's a big deal either way...

    Line 709, Patchset 9: bool GUARDED_BY(lock_) is_destroyed_ = false;
    Greg Thompson . resolved

    consider removing `is_destroyed_`:

    • initialize `current_nonce_` to `1` below
    • set `current_nonce_` to `0` in `OnMainThreadDestroyed`
    • change `!is_destroyed_` checks to `current_nonce_ != 0`
    Takashi Nakayama

    I don't think one variable having two meaning is a good way if there are no performance issues. WDYT?

    Greg Thompson

    certainly not a big deal. :-)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Hiroshige Hayashizaki
    • Kouhei Ueno
    • Leszek Swirski
    • Takashi Nakayama
    Gerrit-Attention: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Thu, 12 Mar 2026 10:21:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Takashi Nakayama <tn...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Takashi Nakayama (Gerrit)

    unread,
    2:10 PM (8 hours ago) 2:10 PM
    to Greg Thompson, Kouhei Ueno, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Greg Thompson, Hiroshige Hayashizaki, Kouhei Ueno and Leszek Swirski

    Takashi Nakayama added 4 comments

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 119, Patchset 13: CHECK_EQ(source_hash.size(), kSha256Bytes);
    Greg Thompson . resolved

    `source_hash` is now a fixed-extent span, so this `CHECK` is no longer needed, no?

    Takashi Nakayama

    Done

    Line 161, Patchset 13: mojom::blink::CodeCacheType cache_type,
    Greg Thompson . resolved

    can we remove this from the mojom interface since we only support JS?

    Takashi Nakayama

    Done

    Line 495, Patchset 13: void HandleTransactionError(persistent_cache::TransactionError error)
    Greg Thompson . resolved

    nit: blank line before this

    Takashi Nakayama

    Done

    Line 690, Patchset 9: }
    Greg Thompson . resolved

    consider `result_ = mojo_base::BigBuffer();` as above

    Takashi Nakayama

    I understand your concern, but I want to keep this function as simple as possible because this is called in the destructor. WDYT?

    Greg Thompson

    my observation is that it's called from `~CodeCacheWithPersistentCacheHostImpl`, but `HostStateForInlineScriptCacheLookup` itself is a refcounted object so it could live longer. if it happens that `OnMainThreadDestroyed` is called while `result_` holds a hunk of memory, we may as well release the memory now. i don't think it's a big deal either way...

    Takashi Nakayama

    Acknowledged. Thanks for sharing your thoughts. I added `result_ = {};`.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Greg Thompson
    • Hiroshige Hayashizaki
    • Kouhei Ueno
    • Leszek Swirski
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c319ba273e716e0703fc7e22becf4239c5558c2
    Gerrit-Change-Number: 7621959
    Gerrit-PatchSet: 14
    Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
    Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Greg Thompson <g...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Thu, 12 Mar 2026 18:10:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Takashi Nakayama <tn...@chromium.org>
    Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kouhei Ueno (Gerrit)

    unread,
    10:04 PM (3 minutes ago) 10:04 PM
    to Takashi Nakayama, Greg Thompson, Hiroshige Hayashizaki, Leszek Swirski, Takashi Toyoshima, chromium...@chromium.org, Chromium LUCI CQ, Nate Chapin, AyeAye, shimazu...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, blink-...@chromium.org, horo+...@chromium.org, blink-work...@chromium.org, gavinp...@chromium.org, loading...@chromium.org, blink-re...@chromium.org, kinuko...@chromium.org
    Attention needed from Greg Thompson, Hiroshige Hayashizaki, Leszek Swirski and Takashi Nakayama

    Kouhei Ueno added 5 comments

    File third_party/blink/renderer/platform/loader/fetch/code_cache_host.cc
    Line 482, Patchset 9: InitiateConnectionToBackend();
    Greg Thompson . unresolved

    Do you know what proportion of pages contain inline scripts? This will create a backend proactively, which will cause the browser to reach the PersistentCacheCollection's capacity sooner. This could lead to more cache misses for other renderers as their backends are abandoned.

    Kouhei Ueno

    I can imagine that to be pretty close to 100%? I believe almost every website would contain at least one inline script. Since the backend creation is gated by the feature flag, let's check the overhead via UMA/Finch.

    Line 549, Patchset 14 (Latest): // main thread.
    Kouhei Ueno . unresolved

    Would you add trace events to aid debugging?

    Line 579, Patchset 14 (Latest): if (!waiter_.TimedWait(timeout)) {
    Kouhei Ueno . unresolved

    Would you add histograms to measure how long we blocked the main thread?

    Line 579, Patchset 14 (Latest): if (!waiter_.TimedWait(timeout)) {
    Kouhei Ueno . unresolved

    Would you reference the param here if WaitForFetchResultSync is always called with the same param?

    Line 609, Patchset 14 (Latest): base::WaitableEvent waiter_;
    Kouhei Ueno . unresolved

    As discussed offline, we should be using ConditionVariable instead of WaitableEvent.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Greg Thompson
    • Hiroshige Hayashizaki
    • Leszek Swirski
    • Takashi Nakayama
    Gerrit-Attention: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Attention: Greg Thompson <g...@chromium.org>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Fri, 13 Mar 2026 02:03:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages