[webgpu] Make DawnWireServices optionally thread-safe. [chromium/src : main]

0 views
Skip to first unread message

Loko Kung (Gerrit)

unread,
Nov 18, 2025, 5:51:56 PMNov 18
to Stephen Chenney, chromium...@chromium.org, Dirk Schulze, kinuko...@chromium.org, jmedle...@chromium.org, drott+bl...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, cwalle...@chromium.org, kainin...@chromium.org, blink-reviews-p...@chromium.org

Loko Kung has uploaded the change for review

Commit message

[webgpu] Make DawnWireServices optionally thread-safe.

- This change adds an optional lock in DawnWireServices to
make it thread-safe in the case where we want the wire client
to handle GPU return data on a separate thread.
Change-Id: I5f176b0132a2ed94f832a2a8261594da6d4b67b5

Change diff


Change information

Files:
  • M gpu/command_buffer/client/webgpu_implementation.cc
  • M gpu/command_buffer/client/webgpu_implementation.h
Change size: M
Delta: 2 files changed, 90 insertions(+), 56 deletions(-)
Open in Gerrit

Related details

Attention set is empty
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: newchange
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
Gerrit-Change-Number: 7170840
Gerrit-PatchSet: 1
Gerrit-Owner: Loko Kung <loko...@google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Loko Kung (Gerrit)

unread,
Dec 2, 2025, 2:53:10 AMDec 2
to Corentin Wallez, Sunny Sachanandani, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
Attention needed from Corentin Wallez and Sunny Sachanandani

Loko Kung voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Corentin Wallez
  • Sunny Sachanandani
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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
Gerrit-Change-Number: 7170840
Gerrit-PatchSet: 5
Gerrit-Owner: Loko Kung <loko...@google.com>
Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
Gerrit-Reviewer: Loko Kung <loko...@google.com>
Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Sunny Sachanandani <sun...@chromium.org>
Gerrit-Attention: Corentin Wallez <cwa...@chromium.org>
Gerrit-Comment-Date: Tue, 02 Dec 2025 07:52:59 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Corentin Wallez (Gerrit)

unread,
Dec 2, 2025, 8:24:39 AMDec 2
to Loko Kung, Sunny Sachanandani, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
Attention needed from Loko Kung and Sunny Sachanandani

Corentin Wallez added 5 comments

File gpu/command_buffer/client/webgpu_implementation.h
Line 173, Patchset 5 (Latest): scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
Corentin Wallez . unresolved

This comment seems to only explain part of the story. What I understand that happens is that we want to receive commands out of order, such that `OnGpuControlReturnData` will be called in a different `SequencedTaskRunner`. This means that we want the wire to process the return commands immediately, in parallel of whatever the user of WebGPU hosted on that `dawn::wire` is doing. However to avoid races, we will only trigger the spontaneous callbacks on the same sequence to avoid issues.

Later in the CL chain, `WaitAny` is used that will be able to wait and synchronously trigger the callback that's marked complete in parallel to the `WaitAny`. There is additional complexity to make all the Blink callbacks use `AllowProcessEvents` vs. `AllowSpontaneous` because we want to control when the callbacks happen in multithreaded mode.

How about instead adding an option to dawn::wire::client to "downgrade" all callbacks to `AllowProcessEvents`? This is transparent for whoever calls dawn::wire, but it groups more of the logic for multithreading in `webgpu_implementation` so we don't have to require that all the code adapts to using `AllowProcessEvents`.

TBH there's enough moving parts that a design doc that explains the layering, the mojo filtering etc would be useful. I had to dig into the whole CL chain and recall previous CLs in Dawn to have an idea of the direction we're going. (maybe I missed the DD for this)

File gpu/command_buffer/client/webgpu_implementation.cc
Line 70, Patchset 5 (Latest):void DawnWireServices::ClientHandleCommands(
Corentin Wallez . unresolved

```suggestion
void DawnWireServices::HandleClientCommands(
```

Line 82, Patchset 5 (Latest): // TODO(enga): Instead of a CHECK, this could generate a device lost
Corentin Wallez . unresolved

This seems to want to harden the renderer from malformed commands coming from the GPU process. IMHO we should remove this TODO and comment that we expect commands from the GPU process to be well-formed.

Line 107, Patchset 5 (Latest):void DawnWireServices::SerializerCommit() {
Corentin Wallez . unresolved

Any way to make these method name make more sense in the context of `DawnWireServices`? Maybe just removing `Serializer` would help since we're asking the wire to be committed and don't care about the implementation details.

Line 137, Patchset 5 (Latest): bool support_locking)
Corentin Wallez . unresolved

Is the plan to eventually always have `support_locking` to true such that we remove the dual-code path complexity?

Open in Gerrit

Related details

Attention is currently required from:
  • Loko Kung
  • Sunny Sachanandani
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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
    Gerrit-Change-Number: 7170840
    Gerrit-PatchSet: 5
    Gerrit-Owner: Loko Kung <loko...@google.com>
    Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
    Gerrit-Reviewer: Loko Kung <loko...@google.com>
    Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Attention: Loko Kung <loko...@google.com>
    Gerrit-Comment-Date: Tue, 02 Dec 2025 13:24:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kai Ninomiya (Gerrit)

    unread,
    Dec 5, 2025, 4:58:30 PMDec 5
    to Loko Kung, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Loko Kung

    Kai Ninomiya added 1 comment

    Patchset-level comments
    File-level comment, Patchset 5 (Latest):
    Kai Ninomiya . resolved

    Sunny is OOO

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Loko Kung
    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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
    Gerrit-Change-Number: 7170840
    Gerrit-PatchSet: 5
    Gerrit-Owner: Loko Kung <loko...@google.com>
    Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
    Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
    Gerrit-Reviewer: Loko Kung <loko...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Loko Kung <loko...@google.com>
    Gerrit-Comment-Date: Fri, 05 Dec 2025 21:58:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kai Ninomiya (Gerrit)

    unread,
    Dec 5, 2025, 7:04:09 PMDec 5
    to Loko Kung, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Loko Kung

    Kai Ninomiya added 2 comments

    File gpu/command_buffer/client/webgpu_implementation.h
    Line 69, Patchset 5 (Latest): raw_ptr<base::Lock> lock_ptr_ = nullptr;
    Kai Ninomiya . unresolved

    nit: make this `const` if possible so it's clear it doesn't change state

    or if possible combine these into one member to simplify and avoid having a self-pointer. Either:

    • `const std::unique_ptr<base::Lock> lock_;` + `lock_.get()`
    • `const std::optional<base::Lock> lock_;` + `base::OptionalToPtr(lock_)`

    I would guess the latter is slightly more efficient (cache locality) but I don't think it really makes a difference.

    File gpu/command_buffer/client/webgpu_implementation.cc
    Line 82, Patchset 5 (Latest): // TODO(enga): Instead of a CHECK, this could generate a device lost
    Corentin Wallez . unresolved

    This seems to want to harden the renderer from malformed commands coming from the GPU process. IMHO we should remove this TODO and comment that we expect commands from the GPU process to be well-formed.

    Kai Ninomiya

    +1

    Gerrit-Comment-Date: Sat, 06 Dec 2025 00:04:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Corentin Wallez <cwa...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Loko Kung (Gerrit)

    unread,
    Dec 16, 2025, 8:03:51 PM (4 days ago) Dec 16
    to Kai Ninomiya, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Corentin Wallez and Kai Ninomiya

    Loko Kung added 6 comments

    File gpu/command_buffer/client/webgpu_implementation.h
    Line 173, Patchset 5: scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
    Corentin Wallez . unresolved

    This comment seems to only explain part of the story. What I understand that happens is that we want to receive commands out of order, such that `OnGpuControlReturnData` will be called in a different `SequencedTaskRunner`. This means that we want the wire to process the return commands immediately, in parallel of whatever the user of WebGPU hosted on that `dawn::wire` is doing. However to avoid races, we will only trigger the spontaneous callbacks on the same sequence to avoid issues.

    Later in the CL chain, `WaitAny` is used that will be able to wait and synchronously trigger the callback that's marked complete in parallel to the `WaitAny`. There is additional complexity to make all the Blink callbacks use `AllowProcessEvents` vs. `AllowSpontaneous` because we want to control when the callbacks happen in multithreaded mode.

    How about instead adding an option to dawn::wire::client to "downgrade" all callbacks to `AllowProcessEvents`? This is transparent for whoever calls dawn::wire, but it groups more of the logic for multithreading in `webgpu_implementation` so we don't have to require that all the code adapts to using `AllowProcessEvents`.

    TBH there's enough moving parts that a design doc that explains the layering, the mojo filtering etc would be useful. I had to dig into the whole CL chain and recall previous CLs in Dawn to have an idea of the direction we're going. (maybe I missed the DD for this)

    Loko Kung

    Yea, sorry, I was putting a DD together for this sort of at the same time as implementing it because it was difficult to understand what was happening without actually trying stuff. The doc is relatively complete now at: https://docs.google.com/document/d/1fd1u4U8z3_tMvSE9UCATNp0mdxyWebqnAo3zkMCNKPQ/edit?usp=sharing

    As for the question about downgrading all callbacks to `AllowProcessEvents`, the callbacks that would need to be downgraded are the user callbacks on the client side, not the server ones. The server ones are still all spontaneous. If we wanted to do something like force all client callbacks to be `AllowProcessEvents`, we would need to manually overwrite all the async entry points to not take a callback mode or something? I'm also not sure if that's what we want anyways since we may need to use the `WaitAnyOnly` for some stuff also.

    Line 69, Patchset 5: raw_ptr<base::Lock> lock_ptr_ = nullptr;
    Kai Ninomiya . resolved

    nit: make this `const` if possible so it's clear it doesn't change state

    or if possible combine these into one member to simplify and avoid having a self-pointer. Either:

    • `const std::unique_ptr<base::Lock> lock_;` + `lock_.get()`
    • `const std::optional<base::Lock> lock_;` + `base::OptionalToPtr(lock_)`

    I would guess the latter is slightly more efficient (cache locality) but I don't think it really makes a difference.

    Loko Kung

    Done

    File gpu/command_buffer/client/webgpu_implementation.cc
    Line 70, Patchset 5:void DawnWireServices::ClientHandleCommands(
    Corentin Wallez . resolved

    ```suggestion
    void DawnWireServices::HandleClientCommands(
    ```

    Loko Kung

    Done

    Line 82, Patchset 5: // TODO(enga): Instead of a CHECK, this could generate a device lost
    Corentin Wallez . resolved

    This seems to want to harden the renderer from malformed commands coming from the GPU process. IMHO we should remove this TODO and comment that we expect commands from the GPU process to be well-formed.

    Kai Ninomiya

    +1

    Loko Kung

    Done

    Line 107, Patchset 5:void DawnWireServices::SerializerCommit() {
    Corentin Wallez . resolved

    Any way to make these method name make more sense in the context of `DawnWireServices`? Maybe just removing `Serializer` would help since we're asking the wire to be committed and don't care about the implementation details.

    Loko Kung

    Done

    Line 137, Patchset 5: bool support_locking)
    Corentin Wallez . unresolved

    Is the plan to eventually always have `support_locking` to true such that we remove the dual-code path complexity?

    Loko Kung

    Maybe? I did this for now so that we I could implement the new stuff without changing the existing behavior in most cases. I'm not sure if we would ever need to enable this all the time though since the additional locking could potentially cause us to regress a little performance wise if we turned this on unconditionally?

    That said, if we do some benchmarking and we don't see a significant issue with performance, it would definitely be nice to use this as the default path and not have to maintain two branches.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Corentin Wallez
    • Kai Ninomiya
    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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
    Gerrit-Change-Number: 7170840
    Gerrit-PatchSet: 6
    Gerrit-Owner: Loko Kung <loko...@google.com>
    Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
    Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
    Gerrit-Reviewer: Loko Kung <loko...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Corentin Wallez <cwa...@chromium.org>
    Gerrit-Attention: Kai Ninomiya <kai...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Dec 2025 01:03:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Corentin Wallez <cwa...@chromium.org>
    Comment-In-Reply-To: Kai Ninomiya <kai...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Corentin Wallez (Gerrit)

    unread,
    Dec 17, 2025, 7:39:51 AM (3 days ago) Dec 17
    to Loko Kung, Kai Ninomiya, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Kai Ninomiya and Loko Kung

    Corentin Wallez added 3 comments

    File gpu/command_buffer/client/webgpu_implementation.h
    Line 173, Patchset 5: scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
    Corentin Wallez . unresolved

    This comment seems to only explain part of the story. What I understand that happens is that we want to receive commands out of order, such that `OnGpuControlReturnData` will be called in a different `SequencedTaskRunner`. This means that we want the wire to process the return commands immediately, in parallel of whatever the user of WebGPU hosted on that `dawn::wire` is doing. However to avoid races, we will only trigger the spontaneous callbacks on the same sequence to avoid issues.

    Later in the CL chain, `WaitAny` is used that will be able to wait and synchronously trigger the callback that's marked complete in parallel to the `WaitAny`. There is additional complexity to make all the Blink callbacks use `AllowProcessEvents` vs. `AllowSpontaneous` because we want to control when the callbacks happen in multithreaded mode.

    How about instead adding an option to dawn::wire::client to "downgrade" all callbacks to `AllowProcessEvents`? This is transparent for whoever calls dawn::wire, but it groups more of the logic for multithreading in `webgpu_implementation` so we don't have to require that all the code adapts to using `AllowProcessEvents`.

    TBH there's enough moving parts that a design doc that explains the layering, the mojo filtering etc would be useful. I had to dig into the whole CL chain and recall previous CLs in Dawn to have an idea of the direction we're going. (maybe I missed the DD for this)

    Loko Kung

    Yea, sorry, I was putting a DD together for this sort of at the same time as implementing it because it was difficult to understand what was happening without actually trying stuff. The doc is relatively complete now at: https://docs.google.com/document/d/1fd1u4U8z3_tMvSE9UCATNp0mdxyWebqnAo3zkMCNKPQ/edit?usp=sharing

    As for the question about downgrading all callbacks to `AllowProcessEvents`, the callbacks that would need to be downgraded are the user callbacks on the client side, not the server ones. The server ones are still all spontaneous. If we wanted to do something like force all client callbacks to be `AllowProcessEvents`, we would need to manually overwrite all the async entry points to not take a callback mode or something? I'm also not sure if that's what we want anyways since we may need to use the `WaitAnyOnly` for some stuff also.

    Corentin Wallez

    Thank you for the DD, it helps a lot to understand where this is going and how it fits in the larger effort. DD LGTM.

    Alternatively, could we make first make all WebGPU callbacks use `AllowProcessEvents` and call `instance.ProcessEvents` after the `dawn::wire::client::Client::HandleCommands` so that we don't need to carry around two different callback modes that we'll have to think about? This would be done at [1] and in this CL turned into the `else` branch of `if (main_task_runner_)`. This is again to make sure we don't end up with duplicate code paths that we have to test and be aware of as we're making changes.

    File gpu/command_buffer/client/webgpu_implementation.cc
    Line 137, Patchset 5: bool support_locking)
    Corentin Wallez . unresolved

    Is the plan to eventually always have `support_locking` to true such that we remove the dual-code path complexity?

    Loko Kung

    Maybe? I did this for now so that we I could implement the new stuff without changing the existing behavior in most cases. I'm not sure if we would ever need to enable this all the time though since the additional locking could potentially cause us to regress a little performance wise if we turned this on unconditionally?

    That said, if we do some benchmarking and we don't see a significant issue with performance, it would definitely be nice to use this as the default path and not have to maintain two branches.

    Corentin Wallez

    My understanding is that all these code paths are fairly cold, so adding a little uncontested locking should be very cheap. We could start with a boolean then Finch it to eventually unconditionally set it to true.

    Line 335, Patchset 6 (Latest): }
    Corentin Wallez . resolved

    [1]

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Kai Ninomiya
    • Loko Kung
    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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
    Gerrit-Change-Number: 7170840
    Gerrit-PatchSet: 6
    Gerrit-Owner: Loko Kung <loko...@google.com>
    Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
    Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
    Gerrit-Reviewer: Loko Kung <loko...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Loko Kung <loko...@google.com>
    Gerrit-Attention: Kai Ninomiya <kai...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Dec 2025 12:39:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Loko Kung <loko...@google.com>
    Comment-In-Reply-To: Corentin Wallez <cwa...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kai Ninomiya (Gerrit)

    unread,
    Dec 17, 2025, 3:34:00 PM (3 days ago) Dec 17
    to Loko Kung, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Loko Kung

    Kai Ninomiya added 3 comments

    File gpu/command_buffer/client/webgpu_implementation.cc
    Line 137, Patchset 5: bool support_locking)
    Corentin Wallez . unresolved

    Is the plan to eventually always have `support_locking` to true such that we remove the dual-code path complexity?

    Loko Kung

    Maybe? I did this for now so that we I could implement the new stuff without changing the existing behavior in most cases. I'm not sure if we would ever need to enable this all the time though since the additional locking could potentially cause us to regress a little performance wise if we turned this on unconditionally?

    That said, if we do some benchmarking and we don't see a significant issue with performance, it would definitely be nice to use this as the default path and not have to maintain two branches.

    Corentin Wallez

    My understanding is that all these code paths are fairly cold, so adding a little uncontested locking should be very cheap. We could start with a boolean then Finch it to eventually unconditionally set it to true.

    Kai Ninomiya

    I agree these code paths seem cold enough that locking overhead should be insignificant. Finch plan SGTM (as followup)

    Line 351, Patchset 6 (Latest):bool WebGPUImplementation::EnsureAwaitingFlush() {
    Kai Ninomiya . unresolved

    nit: Maybe this could be moved into DawnWireServices so it doesn't have to take the lock twice.

    Line 371, Patchset 6 (Latest): helper_->FlushLazy();
    Kai Ninomiya . unresolved

    Is it OK that this is not locked?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Loko Kung
    Gerrit-Comment-Date: Wed, 17 Dec 2025 20:33:54 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Loko Kung (Gerrit)

    unread,
    Dec 18, 2025, 11:46:54 AM (2 days ago) Dec 18
    to Kai Ninomiya, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
    Attention needed from Corentin Wallez and Kai Ninomiya

    Loko Kung added 4 comments

    File gpu/command_buffer/client/webgpu_implementation.h
    Line 173, Patchset 5: scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
    Corentin Wallez . resolved

    This comment seems to only explain part of the story. What I understand that happens is that we want to receive commands out of order, such that `OnGpuControlReturnData` will be called in a different `SequencedTaskRunner`. This means that we want the wire to process the return commands immediately, in parallel of whatever the user of WebGPU hosted on that `dawn::wire` is doing. However to avoid races, we will only trigger the spontaneous callbacks on the same sequence to avoid issues.

    Later in the CL chain, `WaitAny` is used that will be able to wait and synchronously trigger the callback that's marked complete in parallel to the `WaitAny`. There is additional complexity to make all the Blink callbacks use `AllowProcessEvents` vs. `AllowSpontaneous` because we want to control when the callbacks happen in multithreaded mode.

    How about instead adding an option to dawn::wire::client to "downgrade" all callbacks to `AllowProcessEvents`? This is transparent for whoever calls dawn::wire, but it groups more of the logic for multithreading in `webgpu_implementation` so we don't have to require that all the code adapts to using `AllowProcessEvents`.

    TBH there's enough moving parts that a design doc that explains the layering, the mojo filtering etc would be useful. I had to dig into the whole CL chain and recall previous CLs in Dawn to have an idea of the direction we're going. (maybe I missed the DD for this)

    Loko Kung

    Yea, sorry, I was putting a DD together for this sort of at the same time as implementing it because it was difficult to understand what was happening without actually trying stuff. The doc is relatively complete now at: https://docs.google.com/document/d/1fd1u4U8z3_tMvSE9UCATNp0mdxyWebqnAo3zkMCNKPQ/edit?usp=sharing

    As for the question about downgrading all callbacks to `AllowProcessEvents`, the callbacks that would need to be downgraded are the user callbacks on the client side, not the server ones. The server ones are still all spontaneous. If we wanted to do something like force all client callbacks to be `AllowProcessEvents`, we would need to manually overwrite all the async entry points to not take a callback mode or something? I'm also not sure if that's what we want anyways since we may need to use the `WaitAnyOnly` for some stuff also.

    Corentin Wallez

    Thank you for the DD, it helps a lot to understand where this is going and how it fits in the larger effort. DD LGTM.

    Alternatively, could we make first make all WebGPU callbacks use `AllowProcessEvents` and call `instance.ProcessEvents` after the `dawn::wire::client::Client::HandleCommands` so that we don't need to carry around two different callback modes that we'll have to think about? This would be done at [1] and in this CL turned into the `else` branch of `if (main_task_runner_)`. This is again to make sure we don't end up with duplicate code paths that we have to test and be aware of as we're making changes.

    Loko Kung

    I don't want to change the callback types in this change since that affects a lot of the Blink files, but because explicitly calling `ProcessEvents` here will just be a no-op given that the existing modes are all `AllowSpontaneous`, I added the call now, and in the child CL, I will remove the need to branch modes and just have everything be `ProcessEvents` and I think that should be equivalent.

    File gpu/command_buffer/client/webgpu_implementation.cc
    Line 137, Patchset 5: bool support_locking)
    Corentin Wallez . resolved

    Is the plan to eventually always have `support_locking` to true such that we remove the dual-code path complexity?

    Loko Kung

    Maybe? I did this for now so that we I could implement the new stuff without changing the existing behavior in most cases. I'm not sure if we would ever need to enable this all the time though since the additional locking could potentially cause us to regress a little performance wise if we turned this on unconditionally?

    That said, if we do some benchmarking and we don't see a significant issue with performance, it would definitely be nice to use this as the default path and not have to maintain two branches.

    Corentin Wallez

    My understanding is that all these code paths are fairly cold, so adding a little uncontested locking should be very cheap. We could start with a boolean then Finch it to eventually unconditionally set it to true.

    Kai Ninomiya

    I agree these code paths seem cold enough that locking overhead should be insignificant. Finch plan SGTM (as followup)

    Loko Kung

    Acknowledged

    Line 351, Patchset 6:bool WebGPUImplementation::EnsureAwaitingFlush() {
    Kai Ninomiya . resolved

    nit: Maybe this could be moved into DawnWireServices so it doesn't have to take the lock twice.

    Loko Kung

    Done

    Line 371, Patchset 6: helper_->FlushLazy();
    Kai Ninomiya . resolved

    Is it OK that this is not locked?

    Loko Kung

    I think it should be ok in this case because a race would imply that the wire was cleaned up already anyways.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Corentin Wallez
    • Kai Ninomiya
    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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
      Gerrit-Change-Number: 7170840
      Gerrit-PatchSet: 7
      Gerrit-Owner: Loko Kung <loko...@google.com>
      Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
      Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
      Gerrit-Reviewer: Loko Kung <loko...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
      Gerrit-CC: Stephen Chenney <sche...@chromium.org>
      Gerrit-Attention: Corentin Wallez <cwa...@chromium.org>
      Gerrit-Attention: Kai Ninomiya <kai...@chromium.org>
      Gerrit-Comment-Date: Thu, 18 Dec 2025 16:46:48 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Loko Kung <loko...@google.com>
      Comment-In-Reply-To: Corentin Wallez <cwa...@chromium.org>
      Comment-In-Reply-To: Kai Ninomiya <kai...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Kai Ninomiya (Gerrit)

      unread,
      Dec 18, 2025, 2:33:19 PM (2 days ago) Dec 18
      to Loko Kung, Code Review Nudger, Corentin Wallez, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
      Attention needed from Corentin Wallez and Loko Kung

      Kai Ninomiya added 1 comment

      Patchset-level comments
      File-level comment, Patchset 7 (Latest):
      Kai Ninomiya . unresolved

      LGTM but Corentin should probably re-review

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Corentin Wallez
      • Loko Kung
      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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
        Gerrit-Change-Number: 7170840
        Gerrit-PatchSet: 7
        Gerrit-Owner: Loko Kung <loko...@google.com>
        Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
        Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
        Gerrit-Reviewer: Loko Kung <loko...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
        Gerrit-CC: Stephen Chenney <sche...@chromium.org>
        Gerrit-Attention: Loko Kung <loko...@google.com>
        Gerrit-Attention: Corentin Wallez <cwa...@chromium.org>
        Gerrit-Comment-Date: Thu, 18 Dec 2025 19:33:13 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Corentin Wallez (Gerrit)

        unread,
        Dec 19, 2025, 5:32:08 AM (yesterday) Dec 19
        to Loko Kung, Kai Ninomiya, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
        Attention needed from Loko Kung

        Corentin Wallez voted and added 1 comment

        Votes added by Corentin Wallez

        Code-Review+1

        1 comment

        Patchset-level comments
        Corentin Wallez . resolved

        LGTM too

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Loko Kung
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement 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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
        Gerrit-Change-Number: 7170840
        Gerrit-PatchSet: 7
        Gerrit-Owner: Loko Kung <loko...@google.com>
        Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
        Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
        Gerrit-Reviewer: Loko Kung <loko...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
        Gerrit-CC: Stephen Chenney <sche...@chromium.org>
        Gerrit-Attention: Loko Kung <loko...@google.com>
        Gerrit-Comment-Date: Fri, 19 Dec 2025 10:31:52 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Loko Kung (Gerrit)

        unread,
        Dec 19, 2025, 10:37:29 AM (22 hours ago) Dec 19
        to Corentin Wallez, Kai Ninomiya, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
        Attention needed from Kai Ninomiya

        Loko Kung added 1 comment

        Patchset-level comments
        Kai Ninomiya . resolved

        LGTM but Corentin should probably re-review

        Loko Kung

        Acknowledged

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Kai Ninomiya
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement 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: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
          Gerrit-Change-Number: 7170840
          Gerrit-PatchSet: 7
          Gerrit-Owner: Loko Kung <loko...@google.com>
          Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
          Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
          Gerrit-Reviewer: Loko Kung <loko...@google.com>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
          Gerrit-CC: Stephen Chenney <sche...@chromium.org>
          Gerrit-Attention: Kai Ninomiya <kai...@chromium.org>
          Gerrit-Comment-Date: Fri, 19 Dec 2025 15:37:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Kai Ninomiya <kai...@chromium.org>
          satisfied_requirement
          open
          diffy

          Loko Kung (Gerrit)

          unread,
          Dec 19, 2025, 10:37:32 AM (22 hours ago) Dec 19
          to Corentin Wallez, Kai Ninomiya, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org
          Attention needed from Kai Ninomiya

          Loko Kung voted Commit-Queue+2

          Commit-Queue+2
          Gerrit-Comment-Date: Fri, 19 Dec 2025 15:37:25 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          Dec 19, 2025, 10:40:45 AM (22 hours ago) Dec 19
          to Loko Kung, Corentin Wallez, Kai Ninomiya, Code Review Nudger, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, gavinp...@chromium.org, blink-re...@chromium.org, blink-reviews-p...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, cwalle...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, jmedle...@chromium.org, kainin...@chromium.org, kinuko...@chromium.org

          Chromium LUCI CQ submitted the change

          Change information

          Commit message:
          [webgpu] Make DawnWireServices optionally thread-safe.

          - This change adds an optional lock in DawnWireServices to
          make it thread-safe in the case where we want the wire client
          to handle GPU return data on a separate thread.
          - The change also removes the public getters to the internals of
          the DawnWireServices object in favor of methods that directly
          call into the internals to allow us to take the lock
          appropriately when needed.
          - Note that we also add calls to ProcessEvents on the Dawn wire
          when running in a multithreaded environment since the
          callbacks must happen on the thread which created the
          DawnWireServices object.
          Bug: 441981783
          Change-Id: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
          Commit-Queue: Loko Kung <loko...@google.com>
          Reviewed-by: Corentin Wallez <cwa...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1561142}
          Files:
          • M gpu/command_buffer/client/webgpu_implementation.cc
          • M gpu/command_buffer/client/webgpu_implementation.h
          Change size: M
          Delta: 2 files changed, 137 insertions(+), 69 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Corentin Wallez
          Open in Gerrit
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: merged
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I5f176b0132a2ed94f832a2a8261594da6d4b67b5
          Gerrit-Change-Number: 7170840
          Gerrit-PatchSet: 8
          Gerrit-Owner: Loko Kung <loko...@google.com>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Corentin Wallez <cwa...@chromium.org>
          Gerrit-Reviewer: Kai Ninomiya <kai...@chromium.org>
          Gerrit-Reviewer: Loko Kung <loko...@google.com>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages