Bug 1535214 run AudioWorklet for realtime AudioContext on GraphRunner thread r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 14 Mar 2019 13:40:07 +0000
changeset 521984 5621ae8031cee4184a717aea503c6a468136c4b8
parent 521983 5ce27c44f79e369501db52170709194a30d12f8a
child 521985 8b0cef2fcae5db6514df30c8fd9f9b37418054ed
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1535214
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1535214 run AudioWorklet for realtime AudioContext on GraphRunner thread r=padenot Differential Revision: https://phabricator.services.mozilla.com/D23445
dom/media/GraphRunner.cpp
dom/media/webaudio/AudioWorkletImpl.cpp
--- a/dom/media/GraphRunner.cpp
+++ b/dom/media/GraphRunner.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 #include "GraphRunner.h"
 
 #include "GraphDriver.h"
 #include "MediaStreamGraph.h"
 #include "MediaStreamGraphImpl.h"
+#include "mozilla/dom/WorkletThread.h"
 #include "nsISupportsImpl.h"
 #include "prthread.h"
 #include "Tracing.h"
 
 namespace mozilla {
 
 static void Start(void* aArg) {
   GraphRunner* th = static_cast<GraphRunner*>(aArg);
@@ -96,16 +97,18 @@ void GraphRunner::Run() {
     mMonitor.Wait();  // Wait for mStateEnd or mShutdown to update
     if (mShutdown) {
       break;
     }
     TRACE();
     mStillProcessing = mGraph->OneIterationImpl(mStateEnd);
     mMonitor.Notify();  // Signal that mStillProcessing was updated
   }
+
+  dom::WorkletThread::DeleteCycleCollectedJSContext();
 }
 
 bool GraphRunner::OnThread() { return PR_GetCurrentThread() == mThread; }
 
 #ifdef DEBUG
 bool GraphRunner::RunByGraphDriver(GraphDriver* aDriver) {
   if (!OnThread()) {
     return false;
--- a/dom/media/webaudio/AudioWorkletImpl.cpp
+++ b/dom/media/webaudio/AudioWorkletImpl.cpp
@@ -53,25 +53,16 @@ AudioWorkletImpl::~AudioWorkletImpl() = 
 JSObject* AudioWorkletImpl::WrapWorklet(JSContext* aCx, dom::Worklet* aWorklet,
                                         JS::Handle<JSObject*> aGivenProto) {
   MOZ_ASSERT(NS_IsMainThread());
   return dom::AudioWorklet_Binding::Wrap(aCx, aWorklet, aGivenProto);
 }
 
 nsresult AudioWorkletImpl::SendControlMessage(
     already_AddRefed<nsIRunnable> aRunnable) {
-  MediaStreamGraph* graph = mDestinationStream->Graph();
-  if (!graph->IsNonRealtime()) {
-    // Bug 1473469 Realtime graphs currently use multiple threads, which is
-    // not compatible with the JS engine implementation.  In the meantime,
-    // this creates a separate thread which can process addModule() but not
-    // much else.
-    return WorkletImpl::SendControlMessage(std::move(aRunnable));
-  }
-
   mDestinationStream->SendRunnable(std::move(aRunnable));
   return NS_OK;
 }
 
 already_AddRefed<dom::WorkletGlobalScope>
 AudioWorkletImpl::ConstructGlobalScope() {
   dom::WorkletThread::AssertIsOnWorkletThread();