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

Unified Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp

Issue 2638413004: Don't run removeFinishedSourceNodes with the context lock. (Closed)
Patch Set: Add removeFinishedSourceNodesOnMainThread Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 44c5badf83d62db681b89090707876641dba8236..29b446600e43a8984068cd45b4bb43c42dedf32d 100644
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
@@ -633,7 +633,19 @@ void BaseAudioContext::notifySourceNodeFinishedProcessing(
m_finishedSourceHandlers.push_back(handler);
}
-void BaseAudioContext::removeFinishedSourceNodes() {
+void BaseAudioContext::removeFinishedSourceNodes(bool needsRemoval) {
+ DCHECK(isAudioThread());
+
+ if (needsRemoval) {
+ Platform::current()->mainThread()->getWebTaskRunner()->postTask(
+ BLINK_FROM_HERE,
+ crossThreadBind(
+ &BaseAudioContext::removeFinishedSourceNodesOnMainThread,
+ wrapCrossThreadPersistent(this)));
+ }
+}
+
+void BaseAudioContext::removeFinishedSourceNodesOnMainThread() {
DCHECK(isMainThread());
AutoLocker locker(this);
// Quadratic worst case, but sizes of both vectors are considered
@@ -646,7 +658,7 @@ void BaseAudioContext::removeFinishedSourceNodes() {
m_finishedSourceNodes.clear();
}
-void BaseAudioContext::releaseFinishedSourceNodes() {
+bool BaseAudioContext::releaseFinishedSourceNodes() {
ASSERT(isGraphOwner());
DCHECK(isAudioThread());
bool didRemove = false;
@@ -662,13 +674,8 @@ void BaseAudioContext::releaseFinishedSourceNodes() {
}
}
}
- if (didRemove)
- Platform::current()->mainThread()->getWebTaskRunner()->postTask(
- BLINK_FROM_HERE,
- crossThreadBind(&BaseAudioContext::removeFinishedSourceNodes,
- wrapCrossThreadPersistent(this)));
-
m_finishedSourceHandlers.clear();
+ return didRemove;
}
void BaseAudioContext::notifySourceNodeStartedProcessing(AudioNode* node) {
@@ -741,18 +748,21 @@ void BaseAudioContext::handlePostRenderTasks() {
// is that there will be some nodes which will take slightly longer than usual
// to be deleted or removed from the render graph (in which case they'll
// render silence).
+ bool didRemove = false;
if (tryLock()) {
// Take care of AudioNode tasks where the tryLock() failed previously.
deferredTaskHandler().breakConnections();
// Dynamically clean up nodes which are no longer needed.
- releaseFinishedSourceNodes();
+ didRemove = releaseFinishedSourceNodes();
deferredTaskHandler().handleDeferredTasks();
deferredTaskHandler().requestToDeleteHandlersOnMainThread();
unlock();
}
+
+ removeFinishedSourceNodes(didRemove);
hongchan 2017/01/20 23:27:05 What's the difference between doing the above and
Raymond Toy 2017/01/21 00:12:15 Mostly less duplication in the two places that cal
hongchan 2017/01/23 17:38:41 What I meant by the comment above is: why do we ha
Raymond Toy 2017/01/23 17:45:01 Just to make the logic of what to do with didRemov
hongchan 2017/01/23 18:08:06 Okay, probably this will be the last question; can
Raymond Toy 2017/01/23 18:11:20 Let me try. You mean DeferredTaskHandler? (Not su
}
void BaseAudioContext::resolvePromisesForResumeOnMainThread() {

Powered by Google App Engine
This is Rietveld 408576698