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

Issue 2854463002: Fix data race in AudioDestination.cpp (Closed)

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

Description

Fix data race in AudioDestination.cpp ** This CL is replaced by https://codereview.chromium.org/2853923002/ ** This CL fixes the data race in AudioDestination.cpp, which is caused by the change in the WebAudio rendering architecture. The newly introduced WebThread is scheduled by the device thread, and the WebThread still tries to access the WebAudio graph even after the AudioContext starts the tear-down process. The fix is to call .reset() on the WebThread when the AudioDestination is shutting down. BUG=716358 TEST=(ran the local TSAN for 30 minutes and no data race reported.)

Patch Set 1 #

Total comments: 23

Patch Set 2 : Adding DCHECK(IsMainThread()) in getters #

Patch Set 3 : SampleRate() fix after l-g-t-m #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -17 lines) Patch
M third_party/WebKit/Source/platform/audio/AudioDestination.h View 1 2 2 chunks +13 lines, -9 lines 1 comment Download
M third_party/WebKit/Source/platform/audio/AudioDestination.cpp View 1 2 4 chunks +35 lines, -8 lines 1 comment Download

Messages

Total messages: 21 (14 generated)
hongchan
PTAL.
3 years, 7 months ago (2017-04-28 18:24:42 UTC) #2
Raymond Toy
https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode73 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:73: Platform::Current()->CreateThread("WebAudio Rendering Thread"))), Why change the order? https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode124 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:124: ...
3 years, 7 months ago (2017-04-28 19:53:56 UTC) #5
hongchan
https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode73 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:73: Platform::Current()->CreateThread("WebAudio Rendering Thread"))), On 2017/04/28 19:53:56, Raymond Toy wrote: ...
3 years, 7 months ago (2017-04-28 20:24:54 UTC) #6
nhiroki
https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode124 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:124: // TODO(hongchan): this check might be redundant, so consider ...
3 years, 7 months ago (2017-05-01 01:56:39 UTC) #9
hongchan
https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right): https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/platform/audio/AudioDestination.cpp#newcode124 third_party/WebKit/Source/platform/audio/AudioDestination.cpp:124: // TODO(hongchan): this check might be redundant, so consider ...
3 years, 7 months ago (2017-05-01 16:43:11 UTC) #10
Raymond Toy
lgtm
3 years, 7 months ago (2017-05-01 17:24:15 UTC) #13
nhiroki
3 years, 7 months ago (2017-05-02 01:42:51 UTC) #20
LGTM with nits

https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/p...
File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right):

https://codereview.chromium.org/2854463002/diff/1/third_party/WebKit/Source/p...
third_party/WebKit/Source/platform/audio/AudioDestination.cpp:124: //
TODO(hongchan): this check might be redundant, so consider removing later.
On 2017/05/01 16:43:08, hongchan wrote:
> On 2017/05/01 01:56:39, nhiroki (ooo May 3-7) wrote:
> > On 2017/04/28 20:24:54, hongchan wrote:
> > > On 2017/04/28 19:53:56, Raymond Toy wrote:
> > > > Which checks are redundant? Both?  Is it possible for Pull() to return
0? 
> > And
> > > 
> > > Yes, theoretically it's possible when there is enough data to cover all
the
> > > requested frames from the device.
> > > 
> > > > how can rendering_thread_ not be set here?
> > > 
> > > Perhaps I should use rendering_thread_.get()?
> > 
> > If |rendering_thread_| is nullptr here, DCHECK at line 106 should crash.
> 
> True, but it cannot be caught in the release build.

If it's valid to call Render() when |render_thread_| is null, we should avoid
the crash even on the debug build. How about checking the validity of the render
thread at the beginning of Render() like this?

if (!rendering_thread_)
  return;
// This method is called by AudioDeviceThread.
DCHECK(!IsRenderingThread());

https://codereview.chromium.org/2854463002/diff/40001/third_party/WebKit/Sour...
File third_party/WebKit/Source/platform/audio/AudioDestination.cpp (right):

https://codereview.chromium.org/2854463002/diff/40001/third_party/WebKit/Sour...
third_party/WebKit/Source/platform/audio/AudioDestination.cpp:70:
fifo_(WTF::WrapUnique(
MakeUnique?

https://codereview.chromium.org/2854463002/diff/40001/third_party/WebKit/Sour...
File third_party/WebKit/Source/platform/audio/AudioDestination.h (right):

https://codereview.chromium.org/2854463002/diff/40001/third_party/WebKit/Sour...
third_party/WebKit/Source/platform/audio/AudioDestination.h:90: bool
IsPlaying();
bool IsPlaying() const; ?

Powered by Google App Engine
This is Rietveld 408576698