Index: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
index 607f2e6c32ad832bcd59b703c02c60340ed66c7a..42c0a9b1df0a1d9955b7db8de559aefc47d80ce4 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
@@ -680,6 +680,10 @@ bool BaseAudioContext::ReleaseFinishedSourceNodes() { |
DCHECK(IsAudioThread()); |
bool did_remove = false; |
for (AudioHandler* handler : finished_source_handlers_) { |
+ // See HandleStoppableSourceNodes() comment for why |
+ // this is needed. |
+ ThreadState::GCLockScope gc_lock(ThreadState::MainThreadState()); |
hongchan
2017/06/01 16:08:55
rtoy@ If we have this lock, perhaps we don't need
Raymond Toy
2017/06/01 18:20:47
Based on the name of the class, I think we still n
sof
2017/06/01 21:10:05
That's correct, it prevents the audio thread from
haraken
2017/06/02 02:42:25
I'm a bit confused.
Is it possible that a GC runs
sof
2017/06/02 05:39:40
Yes, that can happen - the lock is over an off-hea
|
+ |
for (AudioNode* node : active_source_nodes_) { |
if (finished_source_nodes_.Contains(node)) |
continue; |
@@ -712,8 +716,13 @@ void BaseAudioContext::ReleaseActiveSourceNodes() { |
} |
void BaseAudioContext::HandleStoppableSourceNodes() { |
+ DCHECK(IsAudioThread()); |
DCHECK(IsGraphOwner()); |
+ // A main thread GC must not be running while the audio |
+ // thread iterates over the |active_source_nodes_| heap object. |
+ ThreadState::GCLockScope gc_lock(ThreadState::MainThreadState()); |
Raymond Toy
2017/06/01 18:20:47
Is it possible to make this a trylock where we can
sof
2017/06/01 21:10:05
I see, thanks - a tryLock() operation could be pro
|
+ |
// Find AudioBufferSourceNodes to see if we can stop playing them. |
for (AudioNode* node : active_source_nodes_) { |
// If the AudioNode has been marked as finished and released by |