Use base::Lock instead of RecursiveMutex in DeferredTaskHandler [chromium/src : main]

0 views
Skip to first unread message

Michael Wilson (Gerrit)

unread,
Mar 21, 2024, 1:34:59 PM3/21/24
to Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Hongchan Choi, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Jeremy Roman

Michael Wilson added 1 comment

Patchset-level comments
File-level comment, Patchset 14 (Latest):
Michael Wilson . unresolved

Please take a look. The main part of this change is in the following files:

  • third_party/blink/renderer/modules/webaudio/audio_context.cc
  • third_party/blink/renderer/modules/webaudio/base_audio_context.h
  • third_party/blink/renderer/modules/webaudio/base_audio_context.cc
  • third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
  • third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc

Everything else is mechanical cleanup. If you would like me to split this into multiple CLs please let me know.

Open in Gerrit

Related details

Attention is currently required from:
  • Jeremy Roman
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 14
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Hongchan Choi <hong...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Sina Firoozabadi <sinaf...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Comment-Date: Thu, 21 Mar 2024 17:34:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Jeremy Roman (Gerrit)

unread,
Mar 28, 2024, 5:44:40 PM3/28/24
to Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Hongchan Choi and Michael Wilson

Jeremy Roman added 1 comment

Patchset-level comments
Jeremy Roman . resolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Open in Gerrit

Related details

Attention is currently required from:
  • Hongchan Choi
  • Michael Wilson
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 14
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Sina Firoozabadi <sinaf...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Attention: Hongchan Choi <hong...@chromium.org>
Gerrit-Attention: Michael Wilson <mjwi...@chromium.org>
Gerrit-Comment-Date: Thu, 28 Mar 2024 21:44:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongchan Choi (Gerrit)

unread,
Mar 28, 2024, 6:00:21 PM3/28/24
to Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Jeremy Roman and Michael Wilson

Hongchan Choi added 4 comments

Patchset-level comments
Jeremy Roman . unresolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Hongchan Choi

+1

I really can't say I am confident on possible fallout, but this CL can achieve a decent and meaningful clean up.

mjwilson@ - should we consider flag guarding this or doing a finch roll out?

File third_party/blink/renderer/bindings/core/v8/script_cache_consumer.cc
Line 25, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . unresolved

Is this directly relevant to the nature of this patch?

File third_party/blink/renderer/core/workers/worker_backing_thread.h
Line 15, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . unresolved

Ditto.

File third_party/blink/renderer/modules/mediasource/handle_attachment_provider.cc
Line 12, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . unresolved

Ditto.

Open in Gerrit

Related details

Attention is currently required from:
  • Jeremy Roman
  • Michael Wilson
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Attention: Michael Wilson <mjwi...@chromium.org>
Gerrit-Comment-Date: Thu, 28 Mar 2024 22:00:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Jeremy Roman <jbr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
Mar 28, 2024, 6:11:22 PM3/28/24
to Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Michael Wilson

Michael Wilson added 1 comment

Patchset-level comments
Jeremy Roman . unresolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Hongchan Choi

+1

I really can't say I am confident on possible fallout, but this CL can achieve a decent and meaningful clean up.

mjwilson@ - should we consider flag guarding this or doing a finch roll out?

Michael Wilson

When I wrote this I was fairly confident, but I was looking more today and saw some discussion about issues when objects go out of scope, etc. that have made me less confident. I will do a bit more analysis and I also agree that a flag guard seems appropriate if I can't strongly prove it.

(Also, I will write a separate CL to remove the unused includes which should reduce the number of people who will get emails about this issue; sorry.)

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Wilson
Gerrit-Attention: Michael Wilson <mjwi...@chromium.org>
Gerrit-Comment-Date: Thu, 28 Mar 2024 22:11:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
Comment-In-Reply-To: Jeremy Roman <jbr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
Mar 30, 2024, 12:07:55 AM3/30/24
to Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org

Michael Wilson added 4 comments

Patchset-level comments
File-level comment, Patchset 14:
Michael Wilson . resolved

Please take a look. The main part of this change is in the following files:

  • third_party/blink/renderer/modules/webaudio/audio_context.cc
  • third_party/blink/renderer/modules/webaudio/base_audio_context.h
  • third_party/blink/renderer/modules/webaudio/base_audio_context.cc
  • third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
  • third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc

Everything else is mechanical cleanup. If you would like me to split this into multiple CLs please let me know.

Michael Wilson

Done

File third_party/blink/renderer/bindings/core/v8/script_cache_consumer.cc
Line 25, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . resolved

Is this directly relevant to the nature of this patch?

Michael Wilson

No, handled in crrev.com/c/5405863

File third_party/blink/renderer/core/workers/worker_backing_thread.h
Line 15, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . resolved

Ditto.

Michael Wilson

Done

File third_party/blink/renderer/modules/mediasource/handle_attachment_provider.cc
Line 12, Patchset 14 (Parent):#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
Hongchan Choi . resolved

Ditto.

Michael Wilson

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 16
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Sina Firoozabadi <sinaf...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Comment-Date: Sat, 30 Mar 2024 04:07:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
Comment-In-Reply-To: Michael Wilson <mjwi...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongchan Choi (Gerrit)

unread,
Mar 30, 2024, 12:32:13 AM3/30/24
to Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Michael Wilson

Hongchan Choi added 5 comments

Patchset-level comments
File-level comment, Patchset 16 (Latest):
Hongchan Choi . resolved

It looks pretty clean! My comments are mostly question - we can discuss offline if that's better.

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
Line 307, Patchset 16 (Latest): // Graph locking.
Hongchan Choi . unresolved

Revise the comment:

The mutex for exclusive graph manipulation. It can be held from either the main or the audio thread when the graph is changed. (e.g. connection or disconnection of AudioNodes)

Line 231, Patchset 16 (Latest): void Lock() EXCLUSIVE_LOCK_FUNCTION(context_graph_mutex_);
bool TryLock() EXCLUSIVE_TRYLOCK_FUNCTION(true, context_graph_mutex_);
void Unlock() UNLOCK_FUNCTION(context_graph_mutex_);
Hongchan Choi . unresolved

Could you explain what these macros do?

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 41, Patchset 16 (Latest):void DeferredTaskHandler::Lock() {
Hongchan Choi . unresolved

Also this "Lock" method seems vague. Can we name it to "GraphLock()"? Or "LockGraph()"?

Line 52, Patchset 16 (Latest): // In release build treat tryLock() as lock() (since above
// DCHECK(isAudioThread) never fires) - this is the best we can do.
Hongchan Choi . unresolved

This logic is a bit weird. TryLock shouldn't be needed on the main thread. Right?

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Wilson
Gerrit-Attention: Michael Wilson <mjwi...@chromium.org>
Gerrit-Comment-Date: Sat, 30 Mar 2024 04:32:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
Apr 2, 2024, 6:27:51 PM4/2/24
to Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, AyeAye, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org

Michael Wilson added 3 comments

Patchset-level comments
Jeremy Roman . unresolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Hongchan Choi

+1

I really can't say I am confident on possible fallout, but this CL can achieve a decent and meaningful clean up.

mjwilson@ - should we consider flag guarding this or doing a finch roll out?

Michael Wilson

When I wrote this I was fairly confident, but I was looking more today and saw some discussion about issues when objects go out of scope, etc. that have made me less confident. I will do a bit more analysis and I also agree that a flag guard seems appropriate if I can't strongly prove it.

(Also, I will write a separate CL to remove the unused includes which should reduce the number of people who will get emails about this issue; sorry.)

Michael Wilson

I tried a few things to get the thread analysis tools to verify the lock is not used recursively, but I think the lock is accessed through too many layers of indirection for the analysis to work.

The team has a plan to work on threading and architecture later this year so I will put this down for now and plan to pick it up again then. Set back to WIP.

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
Line 231, Patchset 16 (Latest): void Lock() EXCLUSIVE_LOCK_FUNCTION(context_graph_mutex_);
bool TryLock() EXCLUSIVE_TRYLOCK_FUNCTION(true, context_graph_mutex_);
void Unlock() UNLOCK_FUNCTION(context_graph_mutex_);
Hongchan Choi . unresolved

Could you explain what these macros do?

Michael Wilson

The thread annotations are described here:
https://crsrc.org/c/base/thread_annotations.h

They are to document threading constraints and also serve as hints to the compiler thread safety analysis to help catch some (but not all) multi-threading bugs.

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 52, Patchset 16 (Latest): // In release build treat tryLock() as lock() (since above
// DCHECK(isAudioThread) never fires) - this is the best we can do.
Hongchan Choi . unresolved

This logic is a bit weird. TryLock shouldn't be needed on the main thread. Right?

Michael Wilson

Right.

This is actually a violation of the coding standard: we should either remove the `DCHECK`, remove the handling of `!IsAudioThread()`, or just remove both.

But, since I'm not confident that this is never called from the main thread, I left it here. I think if we want to remove this it should be a separate change so it could be rolled back independently if there is a problem.

Open in Gerrit

Related details

Attention set is empty
Gerrit-Comment-Date: Tue, 02 Apr 2024 22:27:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
Comment-In-Reply-To: Jeremy Roman <jbr...@chromium.org>
Comment-In-Reply-To: Michael Wilson <mjwi...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
May 7, 2026, 4:26:30 AM (12 days ago) May 7
to Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, Sina Firoozabadi, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org

Michael Wilson added 4 comments

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
Line 307, Patchset 16: // Graph locking.
Hongchan Choi . resolved

Revise the comment:

The mutex for exclusive graph manipulation. It can be held from either the main or the audio thread when the graph is changed. (e.g. connection or disconnection of AudioNodes)

Michael Wilson

Done

Line 231, Patchset 16: void Lock() EXCLUSIVE_LOCK_FUNCTION(context_graph_mutex_);

bool TryLock() EXCLUSIVE_TRYLOCK_FUNCTION(true, context_graph_mutex_);
void Unlock() UNLOCK_FUNCTION(context_graph_mutex_);
Hongchan Choi . resolved

Could you explain what these macros do?

Michael Wilson

The thread annotations are described here:
https://crsrc.org/c/base/thread_annotations.h

They are to document threading constraints and also serve as hints to the compiler thread safety analysis to help catch some (but not all) multi-threading bugs.

Michael Wilson

Done

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 41, Patchset 16:void DeferredTaskHandler::Lock() {
Hongchan Choi . unresolved

Also this "Lock" method seems vague. Can we name it to "GraphLock()"? Or "LockGraph()"?

Michael Wilson

This is the standard naming for this type of method throughout the codebase. I would prefer to keep it just as `Lock`.

Line 52, Patchset 16: // In release build treat tryLock() as lock() (since above

// DCHECK(isAudioThread) never fires) - this is the best we can do.
Hongchan Choi . resolved

This logic is a bit weird. TryLock shouldn't be needed on the main thread. Right?

Michael Wilson

Right.

This is actually a violation of the coding standard: we should either remove the `DCHECK`, remove the handling of `!IsAudioThread()`, or just remove both.

But, since I'm not confident that this is never called from the main thread, I left it here. I think if we want to remove this it should be a separate change so it could be rolled back independently if there is a problem.

Michael Wilson

I ended up removing it; the DCHECK has been in place for a while and we can verify statically that this private method is only called from the audio thread.

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 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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 19
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Sina Firoozabadi <sinaf...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Comment-Date: Thu, 07 May 2026 08:26:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Wilson <mjwi...@chromium.org>
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
May 7, 2026, 7:35:24 AM (12 days ago) May 7
to Mahesh Kannan, Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, blink-re...@chromium.org, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Hongchan Choi and Jeremy Roman

Michael Wilson added 3 comments

Patchset-level comments
Jeremy Roman . unresolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Hongchan Choi

+1

I really can't say I am confident on possible fallout, but this CL can achieve a decent and meaningful clean up.

mjwilson@ - should we consider flag guarding this or doing a finch roll out?

Michael Wilson

When I wrote this I was fairly confident, but I was looking more today and saw some discussion about issues when objects go out of scope, etc. that have made me less confident. I will do a bit more analysis and I also agree that a flag guard seems appropriate if I can't strongly prove it.

(Also, I will write a separate CL to remove the unused includes which should reduce the number of people who will get emails about this issue; sorry.)

Michael Wilson

I tried a few things to get the thread analysis tools to verify the lock is not used recursively, but I think the lock is accessed through too many layers of indirection for the analysis to work.

The team has a plan to work on threading and architecture later this year so I will put this down for now and plan to pick it up again then. Set back to WIP.

Michael Wilson

I have added a flag guard. I don't think Finch is appropriate, because there's no metric to compare (either we will observe deadlocks or not). Once the change is verified we can remove the remaining files along with the flag.

File-level comment, Patchset 23 (Latest):
Michael Wilson . resolved

PTAL again. I worked with Gemini and am more confident in the change now, especially with the flag guard in place.

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 52, Patchset 16: // In release build treat tryLock() as lock() (since above
// DCHECK(isAudioThread) never fires) - this is the best we can do.
Hongchan Choi . unresolved

This logic is a bit weird. TryLock shouldn't be needed on the main thread. Right?

Michael Wilson

Right.

This is actually a violation of the coding standard: we should either remove the `DCHECK`, remove the handling of `!IsAudioThread()`, or just remove both.

But, since I'm not confident that this is never called from the main thread, I left it here. I think if we want to remove this it should be a separate change so it could be rolled back independently if there is a problem.

Michael Wilson

I ended up removing it; the DCHECK has been in place for a while and we can verify statically that this private method is only called from the audio thread.

Michael Wilson

(unresolve for visibility).

Open in Gerrit

Related details

Attention is currently required from:
  • Hongchan Choi
  • Jeremy Roman
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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 23
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Mahesh Kannan <kmah...@google.com>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Attention: Hongchan Choi <hong...@chromium.org>
Gerrit-Comment-Date: Thu, 07 May 2026 11:35:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Wilson <mjwi...@chromium.org>
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
Comment-In-Reply-To: Jeremy Roman <jbr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongchan Choi (Gerrit)

unread,
May 7, 2026, 4:53:35 PM (12 days ago) May 7
to Mahesh Kannan, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, blink-re...@chromium.org, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org
Attention needed from Jeremy Roman and Michael Wilson

Hongchan Choi added 8 comments

Commit Message
Line 23, Patchset 24 (Latest):This is the last usage of RecursiveMatrix, so also remove the
Hongchan Choi . unresolved

RecursiveMutex?

File third_party/blink/common/features.cc
Line 2690, Patchset 24 (Latest):BASE_FEATURE(kWebAudioUseBaseLock, base::FEATURE_ENABLED_BY_DEFAULT);
Hongchan Choi . unresolved

Can we have a comment on this flag?

File third_party/blink/renderer/modules/webaudio/audio_context.cc
Line 1424, Patchset 24 (Latest): // rendering graph state (from main thread changes). It's OK if the tryLock()
Hongchan Choi . unresolved

It needs to be updated. (I'd just rewrite this comment)

Line 1480, Patchset 24 (Latest): // Must use a tryLock() here too. Don't worry, the lock will very rarely be
Hongchan Choi . unresolved

Ditto. Let's just rewrite this comment.

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
Line 186, Patchset 24 (Latest): class MODULES_EXPORT GraphAutoTryLocker {
Hongchan Choi . unresolved

Does adding "SCOPED_LOCKABLE" make sense here?

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 41, Patchset 16:void DeferredTaskHandler::Lock() {
Hongchan Choi . resolved

Also this "Lock" method seems vague. Can we name it to "GraphLock()"? Or "LockGraph()"?

Michael Wilson

This is the standard naming for this type of method throughout the codebase. I would prefer to keep it just as `Lock`.

Hongchan Choi

Acknowledged

Line 42, Patchset 24 (Latest):void DeferredTaskHandler::Lock() NO_THREAD_SAFETY_ANALYSIS {
Hongchan Choi . unresolved

Why is this necessary? I think it makes sense to add a comment on why it's needed here.

Also it looks like we don't need "NO_THREAD_SAFETY_ANALYSIS_FIXME" anymore on this annotation? If you have an explanation, it would be easier for me to review.

Line 52, Patchset 16: // In release build treat tryLock() as lock() (since above
// DCHECK(isAudioThread) never fires) - this is the best we can do.
Hongchan Choi . resolved

This logic is a bit weird. TryLock shouldn't be needed on the main thread. Right?

Michael Wilson

Right.

This is actually a violation of the coding standard: we should either remove the `DCHECK`, remove the handling of `!IsAudioThread()`, or just remove both.

But, since I'm not confident that this is never called from the main thread, I left it here. I think if we want to remove this it should be a separate change so it could be rolled back independently if there is a problem.

Michael Wilson

I ended up removing it; the DCHECK has been in place for a while and we can verify statically that this private method is only called from the audio thread.

Michael Wilson

(unresolve for visibility).

Hongchan Choi

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Jeremy Roman
  • Michael Wilson
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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 24
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Mahesh Kannan <kmah...@google.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Attention: Michael Wilson <mjwi...@chromium.org>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Comment-Date: Thu, 07 May 2026 20:53:25 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Wilson (Gerrit)

unread,
May 7, 2026, 8:47:38 PM (11 days ago) May 7
to Mahesh Kannan, Hongchan Choi, Code Review Nudger, Jeremy Roman, Kentaro Hara, Stephen Chenney, Dirk Schulze, srirama chandra sekhar, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Alvin Ji, chromium...@chromium.org, blink-re...@chromium.org, shimazu...@chromium.org, jshin...@chromium.org, blink-revie...@chromium.org, kinuko...@chromium.org, cblume+im...@chromium.org, drott+bl...@chromium.org, kinuko...@chromium.org, oilpan-rev...@chromium.org, poscia...@chromium.org, fmalit...@chromium.org, eric.c...@apple.com, kouhe...@chromium.org, mbarowsky+watc...@chromium.org, video-networking...@google.com, tommyw+w...@chromium.org, blink-reviews-p...@chromium.org, blink-work...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, horo+...@chromium.org, feature-me...@chromium.org, blink-...@chromium.org

Michael Wilson added 7 comments

Patchset-level comments
Jeremy Roman . unresolved

+hongchan for extra WebAudio experience

If this works, I'm happy with it. At some point in the past a straightforward replacement like this was impossible because WebAudio relied on recursive acquisition of the lock in subtle ways, which this CL turns into a thread deadlocking itself.

How confident are we that this (acquisition of a lock already held by the same thread) cannot in fact happen today? Would it be worth doing some additional legwork to validate that this is the case, or feature-guard it (and maybe even roll it out via Finch)?

Hongchan Choi

+1

I really can't say I am confident on possible fallout, but this CL can achieve a decent and meaningful clean up.

mjwilson@ - should we consider flag guarding this or doing a finch roll out?

Michael Wilson

When I wrote this I was fairly confident, but I was looking more today and saw some discussion about issues when objects go out of scope, etc. that have made me less confident. I will do a bit more analysis and I also agree that a flag guard seems appropriate if I can't strongly prove it.

(Also, I will write a separate CL to remove the unused includes which should reduce the number of people who will get emails about this issue; sorry.)

Michael Wilson

I tried a few things to get the thread analysis tools to verify the lock is not used recursively, but I think the lock is accessed through too many layers of indirection for the analysis to work.

The team has a plan to work on threading and architecture later this year so I will put this down for now and plan to pick it up again then. Set back to WIP.

Michael Wilson

I have added a flag guard. I don't think Finch is appropriate, because there's no metric to compare (either we will observe deadlocks or not). Once the change is verified we can remove the remaining files along with the flag.

Michael Wilson

Now I am working on some pre-work CLs that enable thread annotations and compile-time checking. If we can get those strong enough we may not need to land behind a flag after all.

Commit Message
Line 23, Patchset 24:This is the last usage of RecursiveMatrix, so also remove the
Hongchan Choi . resolved

RecursiveMutex?

Michael Wilson

Whoops, done.

File third_party/blink/common/features.cc
Line 2690, Patchset 24:BASE_FEATURE(kWebAudioUseBaseLock, base::FEATURE_ENABLED_BY_DEFAULT);
Hongchan Choi . resolved

Can we have a comment on this flag?

Michael Wilson

Done

File third_party/blink/renderer/modules/webaudio/audio_context.cc
Line 1424, Patchset 24: // rendering graph state (from main thread changes). It's OK if the tryLock()
Hongchan Choi . resolved

It needs to be updated. (I'd just rewrite this comment)

Michael Wilson

Done

Line 1480, Patchset 24: // Must use a tryLock() here too. Don't worry, the lock will very rarely be
Hongchan Choi . resolved

Ditto. Let's just rewrite this comment.

Michael Wilson

Done

File third_party/blink/renderer/modules/webaudio/deferred_task_handler.h
Line 186, Patchset 24: class MODULES_EXPORT GraphAutoTryLocker {
Hongchan Choi . resolved

Does adding "SCOPED_LOCKABLE" make sense here?

Michael Wilson
File third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc
Line 42, Patchset 24:void DeferredTaskHandler::Lock() NO_THREAD_SAFETY_ANALYSIS {
Hongchan Choi . resolved

Why is this necessary? I think it makes sense to add a comment on why it's needed here.

Also it looks like we don't need "NO_THREAD_SAFETY_ANALYSIS_FIXME" anymore on this annotation? If you have an explanation, it would be easier for me to review.

Michael Wilson

This was to disable the analysis when the flag was off, since the same mutex was not acquired. But with the new pre-work CL this may not be necessary anymore.

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 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: Ib75e820c58901e7cdf2d785e5c5d12959e44930a
Gerrit-Change-Number: 5077841
Gerrit-PatchSet: 28
Gerrit-Owner: Michael Wilson <mjwi...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Michael Wilson <mjwi...@chromium.org>
Gerrit-CC: Alvin Ji <alv...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Mahesh Kannan <kmah...@google.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Comment-Date: Fri, 08 May 2026 00:47:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Wilson <mjwi...@chromium.org>
Comment-In-Reply-To: Hongchan Choi <hong...@chromium.org>
Comment-In-Reply-To: Jeremy Roman <jbr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages