Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Issue 2853923002: Improve thread creation in plaform/audio/AudioDestination (Closed)

Created:
3 years, 7 months ago by hongchan
Modified:
3 years, 7 months ago
CC:
chromium-reviews, blink-reviews, kinuko+watch
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Improve thread creation in plaform/audio/AudioDestination After the introduction of the new rendering thread for WebAudio in AudioDestination, two racy situnations were observed by ClusterFuzz. These race conditions become critical especially when the AudioContext is in the tear-down stage; when the main thread is dumping its member variables, the rendering thread is still trying to access them. This CL moves the thread creation logic into Start() and Stop() methods in AudioDestination. By doing so, the thread is always be in sync with the associated audio device and the thread can be safely deleted when the AudioContext goes away. BUG=716358, 716945 TEST=(The local TSAN/ASAN passed the repro test cases.) Review-Url: https://codereview.chromium.org/2853923002 Cr-Commit-Position: refs/heads/master@{#468726} Committed: https://chromium.googlesource.com/chromium/src/+/d94da1744907ed1bb90e37756806841609b0cc52

Patch Set 1 #

Total comments: 12

Patch Set 2 : Addressing feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -12 lines) Patch
M third_party/WebKit/Source/platform/audio/AudioDestination.h View 1 2 chunks +7 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/platform/audio/AudioDestination.cpp View 1 3 chunks +34 lines, -8 lines 0 comments Download

Messages

Total messages: 25 (11 generated)
hongchan
PTAL. haraken@, nhiroki@: Handling of WebThread. rtoy@: WebAudio.
3 years, 7 months ago (2017-05-01 22:32:11 UTC) #2
Raymond Toy
On 2017/05/01 22:32:11, hongchan wrote: > PTAL. > > haraken@, nhiroki@: Handling of WebThread. > ...
3 years, 7 months ago (2017-05-01 22:53:19 UTC) #3
hongchan
On 2017/05/01 22:53:19, Raymond Toy wrote: > On 2017/05/01 22:32:11, hongchan wrote: > > PTAL. ...
3 years, 7 months ago (2017-05-01 22:59:11 UTC) #4
nhiroki
https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode178 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:178: if (web_audio_device_ && !is_playing_) { When is |web_audio_device_| null? ...
3 years, 7 months ago (2017-05-02 02:08:06 UTC) #9
hongchan
On 2017/05/02 02:08:06, nhiroki (ooo May 3-7) wrote: > https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp > File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): > ...
3 years, 7 months ago (2017-05-02 02:31:45 UTC) #10
nhiroki
LGTM after the comments are addressed. On 2017/05/02 02:31:45, hongchan wrote: > On 2017/05/02 02:08:06, ...
3 years, 7 months ago (2017-05-02 03:28:06 UTC) #11
haraken
LGTM https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode175 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:175: DCHECK(WTF::IsMainThread()); WTF:: would not be needed. https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.h File ...
3 years, 7 months ago (2017-05-02 05:02:07 UTC) #12
hongchan
Thanks for the review, everyone! https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode175 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:175: DCHECK(WTF::IsMainThread()); On 2017/05/02 05:02:07, ...
3 years, 7 months ago (2017-05-02 16:49:41 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2853923002/20001
3 years, 7 months ago (2017-05-02 16:50:01 UTC) #16
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/443639)
3 years, 7 months ago (2017-05-02 17:52:33 UTC) #18
Raymond Toy
https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode205 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:205: return is_playing_; On 2017/05/02 16:49:41, hongchan wrote: > On ...
3 years, 7 months ago (2017-05-02 18:11:19 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2853923002/20001
3 years, 7 months ago (2017-05-02 18:12:22 UTC) #21
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/chromium/src/+/d94da1744907ed1bb90e37756806841609b0cc52
3 years, 7 months ago (2017-05-02 18:56:11 UTC) #24
haraken
3 years, 7 months ago (2017-05-03 09:18:01 UTC) #25
Message was sent while issue was closed.
https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/p...
File third_party/WebKit/Source/platform/audio/AudioDestination.h (right):

https://codereview.chromium.org/2853923002/diff/1/third_party/WebKit/Source/p...
third_party/WebKit/Source/platform/audio/AudioDestination.h:117: // Accessed by
the device thread. Rendering thread for WebAudio graph.
On 2017/05/02 16:49:41, hongchan wrote:
> On 2017/05/02 05:02:07, haraken wrote:
> > 
> > The rendering_thread_ is accessed by the main thread, right?
> > 
> 
> Its life cycle is governed by the main thread, but it is mostly used
(accessed)
> by the device thread.

Makes sense. We could probably unify terms between 'device thread' and
'rendering thread'.

Powered by Google App Engine
This is Rietveld 408576698