Backed out changeset 45c838c4137d (bug 1473469) for various dom/worklet/ failures. CLOSED TREE
authorCsoregi Natalia <ncsoregi@mozilla.com>
Fri, 01 Mar 2019 19:39:32 +0200
changeset 519845 163bec72cd71867012fe81c6f52aa2b5ef6a0ef3
parent 519844 a066481987fbbf72b10e6fb60d2e2eb190586f4d
child 519846 659176e9ffde21b217890c5a75aac8795f002fab
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1473469
milestone67.0a1
backs out45c838c4137d1dcc65ac07dd893c313f5831b283
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
Backed out changeset 45c838c4137d (bug 1473469) for various dom/worklet/ failures. CLOSED TREE
dom/media/GraphDriver.cpp
dom/media/GraphDriver.h
dom/media/GraphRunner.cpp
dom/media/GraphRunner.h
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraph.h
dom/media/MediaStreamGraphImpl.h
dom/media/moz.build
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -36,17 +36,17 @@ GraphDriver::GraphDriver(MediaStreamGrap
       mGraphImpl(aGraphImpl),
       mCurrentTimeStamp(TimeStamp::Now()),
       mPreviousDriver(nullptr),
       mNextDriver(nullptr) {}
 
 void GraphDriver::SetGraphTime(GraphDriver* aPreviousDriver,
                                GraphTime aLastSwitchNextIterationStart,
                                GraphTime aLastSwitchNextIterationEnd) {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   // We set mIterationEnd here, because the first thing a driver do when it
   // does an iteration is to update graph times, so we are in fact setting
   // mIterationStart of the next iteration by setting the end of the previous
   // iteration.
   mIterationStart = aLastSwitchNextIterationStart;
   mIterationEnd = aLastSwitchNextIterationEnd;
 
@@ -58,17 +58,17 @@ void GraphDriver::SetGraphTime(GraphDriv
       ("%p: Setting previous driver: %p (%s)", GraphImpl(), aPreviousDriver,
        aPreviousDriver->AsAudioCallbackDriver() ? "AudioCallbackDriver"
                                                 : "SystemClockDriver"));
 
   SetPreviousDriver(aPreviousDriver);
 }
 
 void GraphDriver::SwitchAtNextIteration(GraphDriver* aNextDriver) {
-  MOZ_ASSERT(OnGraphThread());
+  MOZ_ASSERT(OnThread());
   MOZ_ASSERT(aNextDriver);
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
 
   LOG(LogLevel::Debug,
       ("%p: Switching to new driver: %p (%s)", GraphImpl(), aNextDriver,
        aNextDriver->AsAudioCallbackDriver() ? "AudioCallbackDriver"
                                             : "SystemClockDriver"));
   if (mNextDriver && mNextDriver != GraphImpl()->CurrentDriver()) {
@@ -82,69 +82,63 @@ void GraphDriver::SwitchAtNextIteration(
 }
 
 GraphTime GraphDriver::StateComputedTime() const {
   return GraphImpl()->mStateComputedTime;
 }
 
 void GraphDriver::EnsureNextIteration() { GraphImpl()->EnsureNextIteration(); }
 
-#ifdef DEBUG
-bool GraphDriver::OnGraphThread() {
-  return GraphImpl()->RunByGraphDriver(this);
-}
-#endif
-
 bool GraphDriver::Switching() {
-  MOZ_ASSERT(OnGraphThread());
+  MOZ_ASSERT(OnThread());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   return mNextDriver || mPreviousDriver;
 }
 
 void GraphDriver::SwitchToNextDriver() {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   MOZ_ASSERT(NextDriver());
 
   NextDriver()->SetGraphTime(this, mIterationStart, mIterationEnd);
   GraphImpl()->SetCurrentDriver(NextDriver());
   NextDriver()->Start();
   SetNextDriver(nullptr);
 }
 
 GraphDriver* GraphDriver::NextDriver() {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   return mNextDriver;
 }
 
 GraphDriver* GraphDriver::PreviousDriver() {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   return mPreviousDriver;
 }
 
 void GraphDriver::SetNextDriver(GraphDriver* aNextDriver) {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   MOZ_ASSERT(aNextDriver != this);
   MOZ_ASSERT(aNextDriver != mNextDriver);
 
   if (mNextDriver && mNextDriver != GraphImpl()->CurrentDriver()) {
     LOG(LogLevel::Debug,
         ("Discarding previous next driver: %p (%s)", mNextDriver.get(),
          mNextDriver->AsAudioCallbackDriver() ? "AudioCallbackDriver"
                                               : "SystemClockDriver"));
   }
 
   mNextDriver = aNextDriver;
 }
 
 void GraphDriver::SetPreviousDriver(GraphDriver* aPreviousDriver) {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   GraphImpl()->GetMonitor().AssertCurrentThreadOwns();
   mPreviousDriver = aPreviousDriver;
 }
 
 ThreadedDriver::ThreadedDriver(MediaStreamGraphImpl* aGraphImpl)
     : GraphDriver(aGraphImpl), mThreadRunning(false) {}
 
 class MediaStreamGraphShutdownThreadRunnable : public Runnable {
@@ -660,17 +654,17 @@ bool AudioCallbackDriver::Init() {
 
   LOG(LogLevel::Debug, ("%p: AudioCallbackDriver started.", GraphImpl()));
   return true;
 }
 
 void AudioCallbackDriver::Start() {
   MOZ_ASSERT(!IsStarted());
   MOZ_ASSERT(NS_IsMainThread() || OnCubebOperationThread() ||
-             (PreviousDriver() && PreviousDriver()->OnGraphThread()));
+             (PreviousDriver() && PreviousDriver()->OnThread()));
   if (mPreviousDriver) {
     if (mPreviousDriver->AsAudioCallbackDriver()) {
       LOG(LogLevel::Debug, ("Releasing audio driver off main thread."));
       RefPtr<AsyncCubebTask> releaseEvent =
           new AsyncCubebTask(mPreviousDriver->AsAudioCallbackDriver(),
                              AsyncCubebOperation::SHUTDOWN);
       releaseEvent->Dispatch();
       mPreviousDriver = nullptr;
@@ -724,26 +718,26 @@ void AudioCallbackDriver::Revive() {
          mGraphImpl.get()));
     RefPtr<AsyncCubebTask> initEvent =
         new AsyncCubebTask(this, AsyncCubebOperation::INIT);
     initEvent->Dispatch();
   }
 }
 
 void AudioCallbackDriver::RemoveMixerCallback() {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
 
   if (mAddedMixer) {
     GraphImpl()->mMixer.RemoveCallback(this);
     mAddedMixer = false;
   }
 }
 
 void AudioCallbackDriver::AddMixerCallback() {
-  MOZ_ASSERT(OnGraphThread());
+  MOZ_ASSERT(OnThread());
 
   if (!mAddedMixer) {
     mGraphImpl->mMixer.AddCallback(this);
     mAddedMixer = true;
   }
 }
 
 void AudioCallbackDriver::WaitForNextIteration() {
@@ -950,17 +944,17 @@ long AudioCallbackDriver::DataCallback(c
     // audio thread. This function will never get called again.
     return aFrames - 1;
   }
 
   return aFrames;
 }
 
 void AudioCallbackDriver::StateCallback(cubeb_state aState) {
-  MOZ_ASSERT(!OnGraphThread());
+  MOZ_ASSERT(!OnThread());
   LOG(LogLevel::Debug, ("AudioCallbackDriver State: %d", aState));
 
   // Clear the flag for the not running
   // states: stopped, drained, error.
   mAudioThreadRunning = (aState == CUBEB_STATE_STARTED);
 
   if (aState == CUBEB_STATE_ERROR && mShouldFallbackIfError) {
     MOZ_ASSERT(!ThreadRunning());
@@ -973,17 +967,17 @@ void AudioCallbackDriver::StateCallback(
     RemoveMixerCallback();
   }
 }
 
 void AudioCallbackDriver::MixerCallback(AudioDataValue* aMixedBuffer,
                                         AudioSampleFormat aFormat,
                                         uint32_t aChannels, uint32_t aFrames,
                                         uint32_t aSampleRate) {
-  MOZ_ASSERT(OnGraphThread());
+  MOZ_ASSERT(OnThread());
   uint32_t toWrite = mBuffer.Available();
 
   if (!mBuffer.Available()) {
     NS_WARNING("DataCallback buffer full, expect frame drops.");
   }
 
   MOZ_ASSERT(mBuffer.Available() <= aFrames);
 
@@ -1029,39 +1023,39 @@ void AudioCallbackDriver::PanOutputIfNee
       }
       cubeb_stream_device_destroy(mAudioStream, out);
     }
   }
 #endif
 }
 
 void AudioCallbackDriver::DeviceChangedCallback() {
-  MOZ_ASSERT(!OnGraphThread());
+  MOZ_ASSERT(!OnThread());
   // Tell the audio engine the device has changed, it might want to reset some
   // state.
   MonitorAutoLock mon(mGraphImpl->GetMonitor());
   GraphImpl()->DeviceChanged();
 #ifdef XP_MACOSX
   PanOutputIfNeeded(mInputChannelCount);
 #endif
 }
 
 uint32_t AudioCallbackDriver::IterationDuration() {
-  MOZ_ASSERT(OnGraphThread());
+  MOZ_ASSERT(OnThread());
   // The real fix would be to have an API in cubeb to give us the number. Short
   // of that, we approximate it here. bug 1019507
   return mIterationDurationMS;
 }
 
 bool AudioCallbackDriver::IsStarted() { return mStarted; }
 
 void AudioCallbackDriver::EnqueueStreamAndPromiseForOperation(
     MediaStream* aStream, void* aPromise,
     dom::AudioContextOperation aOperation) {
-  MOZ_ASSERT(OnGraphThread() || !ThreadRunning());
+  MOZ_ASSERT(OnThread() || !ThreadRunning());
   MonitorAutoLock mon(mGraphImpl->GetMonitor());
   mPromisesForOperation.AppendElement(
       StreamAndPromiseForOperation(aStream, aPromise, aOperation));
 }
 
 void AudioCallbackDriver::CompleteAudioContextOperations(
     AsyncCubebOperation aOperation) {
   MOZ_ASSERT(OnCubebOperationThread());
--- a/dom/media/GraphDriver.h
+++ b/dom/media/GraphDriver.h
@@ -50,27 +50,22 @@ static const int SCHEDULE_SAFETY_MARGIN_
  * is 2*MEDIA_GRAPH_TARGET_PERIOD_MS + SCHEDULE_SAFETY_MARGIN_MS.
  * There is no point in buffering more audio than this in a stream at any
  * given time (until we add processing).
  * This is not optimal yet.
  */
 static const int AUDIO_TARGET_MS =
     2 * MEDIA_GRAPH_TARGET_PERIOD_MS + SCHEDULE_SAFETY_MARGIN_MS;
 
-class MediaStream;
 class MediaStreamGraphImpl;
 
 class AudioCallbackDriver;
 class OfflineClockDriver;
 class SystemClockDriver;
 
-namespace dom {
-enum class AudioContextOperation;
-}
-
 /**
  * A driver is responsible for the scheduling of the processing, the thread
  * management, and give the different clocks to a MediaStreamGraph. This is an
  * abstract base class. A MediaStreamGraph can be driven by an
  * OfflineClockDriver, if the graph is offline, or a SystemClockDriver, if the
  * graph is real time.
  * A MediaStreamGraph holds an owning reference to its driver.
  *
@@ -180,25 +175,28 @@ class GraphDriver {
                     GraphTime aLastSwitchNextIterationEnd);
   /**
    * Call this to indicate that another iteration of the control loop is
    * required on its regular schedule. The monitor must not be held.
    * This function has to be idempotent.
    */
   void EnsureNextIteration();
 
+  /**
+   * Same thing, but not locked.
+   */
+  void EnsureNextIterationLocked();
+
   MediaStreamGraphImpl* GraphImpl() const { return mGraphImpl; }
 
-#ifdef DEBUG
-  // True if the current thread is driving the MSG.
-  bool OnGraphThread();
-#endif
   // True if the current thread is the GraphDriver's thread.
+  // This is the thread that drives the MSG.
   virtual bool OnThread() = 0;
   // GraphDriver's thread has started and the thread is running.
+  // This is the thread that drives the MSG.
   virtual bool ThreadRunning() = 0;
 
  protected:
   GraphTime StateComputedTime() const;
   // Sets the associated pointer, asserting that the lock is held
   void SetNextDriver(GraphDriver* aNextDriver);
 
   // Time of the start of this graph iteration. This must be accessed while
@@ -248,18 +246,16 @@ class ThreadedDriver : public GraphDrive
   /**
    * Runs main control loop on the graph thread. Normally a single invocation
    * of this runs for the entire lifetime of the graph thread.
    */
   void RunThread();
   friend class MediaStreamGraphInitThreadRunnable;
   uint32_t IterationDuration() override { return MEDIA_GRAPH_TARGET_PERIOD_MS; }
 
-  nsIThread* Thread() { return mThread; }
-
   bool OnThread() override {
     return !mThread || mThread->EventTarget()->IsOnCurrentThread();
   }
 
   bool ThreadRunning() override { return mThreadRunning; }
   /*
    * Return the TimeDuration to wait before the next rendering iteration.
    */
@@ -411,18 +407,16 @@ class AudioCallbackDriver : public Graph
   uint32_t InputChannelCount() { return mInputChannelCount; }
 
   /* Enqueue a promise that is going to be resolved when a specific operation
    * occurs on the cubeb stream. */
   void EnqueueStreamAndPromiseForOperation(
       MediaStream* aStream, void* aPromise,
       dom::AudioContextOperation aOperation);
 
-  std::thread::id ThreadId() { return mAudioThreadId.load(); }
-
   bool OnThread() override {
     return mAudioThreadId.load() == std::this_thread::get_id();
   }
 
   bool ThreadRunning() override { return mAudioThreadRunning; }
 
   /* Whether the underlying cubeb stream has been started. See comment for
    * mStarted for details. */
deleted file mode 100644
--- a/dom/media/GraphRunner.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 "nsISupportsImpl.h"
-#include "prthread.h"
-#include "Tracing.h"
-
-namespace mozilla {
-
-static void Start(void* aArg) {
-  GraphRunner* th = static_cast<GraphRunner*>(aArg);
-  th->Run();
-}
-
-GraphRunner::GraphRunner(MediaStreamGraphImpl* aGraph)
-    : mMonitor("GraphRunner::mMonitor"),
-      mGraph(aGraph),
-      mThread(PR_CreateThread(PR_SYSTEM_THREAD, &Start, this,
-                              PR_PRIORITY_URGENT, PR_GLOBAL_THREAD,
-                              PR_JOINABLE_THREAD, 0)) {
-  MOZ_COUNT_CTOR(GraphRunner);
-}
-
-GraphRunner::~GraphRunner() {
-  MOZ_COUNT_DTOR(GraphRunner);
-  PR_JoinThread(mThread);
-}
-
-void GraphRunner::Shutdown() {
-  MonitorAutoLock lock(mMonitor);
-  mShutdown = true;
-  mMonitor.Notify();
-}
-
-bool GraphRunner::OneIteration(GraphTime aStateEnd) {
-  TRACE_AUDIO_CALLBACK();
-
-  MonitorAutoLock lock(mMonitor);
-  MOZ_ASSERT(!mShutdown);
-  mStateEnd = aStateEnd;
-
-#ifdef DEBUG
-  if (auto audioDriver = mGraph->CurrentDriver()->AsAudioCallbackDriver()) {
-    mAudioDriverThreadId = audioDriver->ThreadId();
-  } else if (auto clockDriver =
-                 mGraph->CurrentDriver()->AsSystemClockDriver()) {
-    mClockDriverThread = clockDriver->Thread();
-  } else {
-    MOZ_CRASH("Unknown GraphDriver");
-  }
-#endif
-
-  mMonitor.Notify();  // Signal that mStateEnd was updated
-  mMonitor.Wait();    // Wait for mStillProcessing to update
-
-#ifdef DEBUG
-  mAudioDriverThreadId = std::thread::id();
-  mClockDriverThread = nullptr;
-#endif
-
-  return mStillProcessing;
-}
-
-void GraphRunner::Run() {
-  MonitorAutoLock lock(mMonitor);
-  while (true) {
-    mMonitor.Wait();  // Wait for mStateEnd or mShutdown to update
-    if (mShutdown) {
-      break;
-    }
-    TRACE();
-    mStillProcessing = mGraph->OneIterationImpl(mStateEnd);
-    mMonitor.Notify();  // Signal that mStillProcessing was updated
-  }
-}
-
-bool GraphRunner::OnThread() { return PR_GetCurrentThread() == mThread; }
-
-#ifdef DEBUG
-bool GraphRunner::RunByGraphDriver(GraphDriver* aDriver) {
-  if (!OnThread()) {
-    return false;
-  }
-
-  if (auto audioDriver = aDriver->AsAudioCallbackDriver()) {
-    return audioDriver->ThreadId() == mAudioDriverThreadId;
-  }
-
-  if (auto clockDriver = aDriver->AsSystemClockDriver()) {
-    return clockDriver->Thread() == mClockDriverThread;
-  }
-
-  MOZ_CRASH("Unknown driver");
-}
-#endif
-
-}  // namespace mozilla
deleted file mode 100644
--- a/dom/media/GraphRunner.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#ifndef mozilla_GraphRunner_h
-#define mozilla_GraphRunner_h
-
-#include "MediaSegment.h"
-#include "mozilla/Monitor.h"
-
-#include <thread>
-
-struct PRThread;
-
-namespace mozilla {
-
-class GraphDriver;
-class MediaStreamGraphImpl;
-
-class GraphRunner {
- public:
-  explicit GraphRunner(MediaStreamGraphImpl* aGraph);
-  ~GraphRunner();
-
-  /**
-   * Marks us as shut down and signals mThread, so that it runs until the end.
-   */
-  void Shutdown();
-
-  /**
-   * Signals one iteration of mGraph. Hands aStateEnd over to mThread and runs
-   * the iteration there.
-   */
-  bool OneIteration(GraphTime aStateEnd);
-
-  /**
-   * Runs mGraph until it shuts down.
-   */
-  void Run();
-
-  /**
-   * Returns true if called on mThread.
-   */
-  bool OnThread();
-
-#ifdef DEBUG
-  /**
-   * Returns true if called on mThread, and aDriver was the driver that called
-   * OneIteration() last.
-   */
-  bool RunByGraphDriver(GraphDriver* aDriver);
-#endif
-
- private:
-  // Monitor used for yielding mThread through Wait(), and scheduling mThread
-  // through Signal() from a GraphDriver.
-  Monitor mMonitor;
-  // The MediaStreamGraph we're running. Weakptr beecause this graph owns us and
-  // guarantees that our lifetime will not go beyond that of itself.
-  MediaStreamGraphImpl* const mGraph;
-  // The thread running mGraph.
-  PRThread* const mThread;
-  // GraphTime being handed over to the graph through OneIteration. Protected by
-  // mMonitor.
-  GraphTime mStateEnd = 0;
-  // Reply from mGraph's OneIteration. Protected by mMonitor.
-  bool mStillProcessing = true;
-  // True after Shutdown(). Protected by mMonitor.
-  bool mShutdown = false;
-
-#ifdef DEBUG
-  // Set to mGraph's audio callback driver's thread id, if run by an
-  // AudioCallbackDriver, while OneIteration() is running.
-  std::thread::id mAudioDriverThreadId = std::thread::id();
-  // Set to mGraph's system clock driver's thread, if run by a
-  // SystemClockDriver, while OneIteration() is running.
-  nsIThread* mClockDriverThread = nullptr;
-#endif
-};
-
-}  // namespace mozilla
-
-#endif
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -27,17 +27,16 @@
 #include "mozilla/media/MediaUtils.h"
 #include <algorithm>
 #include "GeckoProfiler.h"
 #include "VideoFrameContainer.h"
 #include "mozilla/AbstractThread.h"
 #include "mozilla/Unused.h"
 #include "mtransport/runnable_utils.h"
 #include "VideoUtils.h"
-#include "GraphRunner.h"
 #include "Tracing.h"
 
 #include "webaudio/blink/DenormalDisabler.h"
 #include "webaudio/blink/HRTFDatabaseLoader.h"
 
 using namespace mozilla::layers;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
@@ -1007,30 +1006,32 @@ void MediaStreamGraphImpl::ReevaluateInp
         new AudioCallbackDriver(this, AudioInputChannelCount());
     {
       MonitorAutoLock lock(mMonitor);
       CurrentDriver()->SwitchAtNextIteration(newDriver);
     }
   }
 }
 
-bool MediaStreamGraphImpl::OnGraphThreadOrNotRunning() const {
+bool MediaStreamGraph::OnGraphThreadOrNotRunning() const {
   // either we're on the right thread (and calling CurrentDriver() is safe),
   // or we're going to fail the assert anyway, so don't cross-check
   // via CurrentDriver().
-  return mDetectedNotRunning ? NS_IsMainThread() : OnGraphThread();
+  MediaStreamGraphImpl const* graph =
+      static_cast<MediaStreamGraphImpl const*>(this);
+  return graph->mDetectedNotRunning ? NS_IsMainThread()
+                                    : graph->mDriver->OnThread();
 }
 
-bool MediaStreamGraphImpl::OnGraphThread() const {
+bool MediaStreamGraph::OnGraphThread() const {
   // we're on the right thread (and calling mDriver is safe),
-  MOZ_ASSERT(mDriver);
-  if (mGraphRunner && mGraphRunner->OnThread()) {
-    return true;
-  }
-  return mDriver->OnThread();
+  MediaStreamGraphImpl const* graph =
+      static_cast<MediaStreamGraphImpl const*>(this);
+  MOZ_ASSERT(graph->mDriver);
+  return graph->mDriver->OnThread();
 }
 
 bool MediaStreamGraphImpl::ShouldUpdateMainThread() {
   MOZ_ASSERT(OnGraphThreadOrNotRunning());
   if (mRealtime) {
     return true;
   }
 
@@ -1373,33 +1374,23 @@ bool MediaStreamGraphImpl::UpdateMainThr
 
   CurrentDriver()->WaitForNextIteration();
 
   SwapMessageQueues();
   return true;
 }
 
 bool MediaStreamGraphImpl::OneIteration(GraphTime aStateEnd) {
-  if (mGraphRunner) {
-    return mGraphRunner->OneIteration(aStateEnd);
-  }
-
-  return OneIterationImpl(aStateEnd);
-}
-
-bool MediaStreamGraphImpl::OneIterationImpl(GraphTime aStateEnd) {
   TRACE_AUDIO_CALLBACK();
-
   // Changes to LIFECYCLE_RUNNING occur before starting or reviving the graph
   // thread, and so the monitor need not be held to check mLifecycleState.
   // LIFECYCLE_THREAD_NOT_STARTED is possible when shutting down offline
   // graphs that have not started.
   MOZ_DIAGNOSTIC_ASSERT(mLifecycleState <= LIFECYCLE_RUNNING);
   MOZ_ASSERT(OnGraphThread());
-
   WebCore::DenormalDisabler disabler;
 
   // Process graph message from the main thread for this iteration.
   RunMessagesInQueue();
 
   GraphTime stateEnd = std::min(aStateEnd, GraphTime(mEndTime));
   UpdateGraph(stateEnd);
 
@@ -1503,20 +1494,16 @@ class MediaStreamGraphShutDownRunnable :
     // XXX a better test would be have setting mDetectedNotRunning make sure
     // any current callback has finished and block future ones -- or just
     // handle it all in Shutdown()!
     if (mGraph->mDriver->AsAudioCallbackDriver()) {
       MOZ_ASSERT(!mGraph->mDriver->AsAudioCallbackDriver()->InCallback());
     }
 #endif
 
-    if (mGraph->mGraphRunner) {
-      mGraph->mGraphRunner->Shutdown();
-    }
-
     mGraph->mDriver
         ->Shutdown();  // This will wait until it's shutdown since
                        // we'll start tearing down the graph after this
 
     // Release the driver now so that an AudioCallbackDriver will release its
     // SharedThreadPool reference.  Each SharedThreadPool reference must be
     // released before SharedThreadPool::SpinUntilEmpty() runs on
     // xpcom-shutdown-threads.  Don't wait for GC/CC to release references to
@@ -3168,22 +3155,19 @@ void ProcessedMediaStream::DestroyImpl()
   MediaStream::DestroyImpl();
   // The stream order is only important if there are connections, in which
   // case MediaInputPort::Disconnect() called SetStreamOrderDirty().
   // MediaStreamGraphImpl::RemoveStreamGraphThread() will also call
   // SetStreamOrderDirty(), for other reasons.
 }
 
 MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested,
-                                           GraphRunType aRunTypeRequested,
                                            TrackRate aSampleRate,
                                            AbstractThread* aMainThread)
     : MediaStreamGraph(aSampleRate),
-      mGraphRunner(aRunTypeRequested == SINGLE_THREAD ? new GraphRunner(this)
-                                                      : nullptr),
       mFirstCycleBreaker(0)
       // An offline graph is not initially processing.
       ,
       mEndTime(aDriverRequested == OFFLINE_THREAD_DRIVER ? 0 : GRAPH_TIME_MAX),
       mPortCount(0),
       mInputDeviceID(nullptr),
       mOutputDeviceID(nullptr),
       mNeedAnotherIteration(false),
@@ -3228,23 +3212,16 @@ MediaStreamGraphImpl::MediaStreamGraphIm
   RegisterWeakAsyncMemoryReporter(this);
 }
 
 AbstractThread* MediaStreamGraph::AbstractMainThread() {
   MOZ_ASSERT(static_cast<MediaStreamGraphImpl*>(this)->mAbstractMainThread);
   return static_cast<MediaStreamGraphImpl*>(this)->mAbstractMainThread;
 }
 
-#ifdef DEBUG
-bool MediaStreamGraphImpl::RunByGraphDriver(GraphDriver* aDriver) {
-  return aDriver->OnThread() ||
-         (mGraphRunner && mGraphRunner->RunByGraphDriver(aDriver));
-}
-#endif
-
 void MediaStreamGraphImpl::Destroy() {
   // First unregister from memory reporting.
   UnregisterWeakMemoryReporter(this);
 
   // Clear the self reference which will destroy this instance if all
   // associated GraphDrivers are destroyed.
   mSelfRef = nullptr;
 }
@@ -3316,41 +3293,35 @@ MediaStreamGraph* MediaStreamGraph::GetI
     AbstractThread* mainThread;
     if (aWindow) {
       mainThread =
           aWindow->AsGlobal()->AbstractMainThreadFor(TaskCategory::Other);
     } else {
       // Uncommon case, only for some old configuration of webspeech.
       mainThread = AbstractThread::MainThread();
     }
-
-    GraphRunType runType = DIRECT_DRIVER;
-    if (aGraphDriverRequested != OFFLINE_THREAD_DRIVER &&
-        Preferences::GetBool("dom.audioworklet.enabled", false)) {
-      runType = SINGLE_THREAD;
-    }
-    graph = new MediaStreamGraphImpl(aGraphDriverRequested, runType, sampleRate,
-                                     mainThread);
+    graph =
+        new MediaStreamGraphImpl(aGraphDriverRequested, sampleRate, mainThread);
 
     uint32_t hashkey = WindowToHash(aWindow, sampleRate);
     gGraphs.Put(hashkey, graph);
 
     LOG(LogLevel::Debug,
         ("Starting up MediaStreamGraph %p for window %p", graph, aWindow));
   }
 
   return graph;
 }
 
 MediaStreamGraph* MediaStreamGraph::CreateNonRealtimeInstance(
     TrackRate aSampleRate, nsPIDOMWindowInner* aWindow) {
   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
 
   MediaStreamGraphImpl* graph = new MediaStreamGraphImpl(
-      OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aSampleRate,
+      OFFLINE_THREAD_DRIVER, aSampleRate,
       aWindow->AsGlobal()->AbstractMainThreadFor(TaskCategory::Other));
 
   LOG(LogLevel::Debug, ("Starting up Offline MediaStreamGraph %p", graph));
 
   return graph;
 }
 
 void MediaStreamGraph::DestroyNonRealtimeInstance(MediaStreamGraph* aGraph) {
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -1200,24 +1200,16 @@ class MediaStreamGraph {
   // fact that they will need an audio stream at some point by passing
   // AUDIO_THREAD_DRIVER when getting an instance of MediaStreamGraph, so that
   // the graph starts with the right driver.
   enum GraphDriverType {
     AUDIO_THREAD_DRIVER,
     SYSTEM_THREAD_DRIVER,
     OFFLINE_THREAD_DRIVER
   };
-  // A MediaStreamGraph running an AudioWorklet must always be run from the
-  // same thread, in order to run js. To acheive this, create the graph with
-  // a SINGLE_THREAD RunType. DIRECT_DRIVER will run the graph directly off
-  // the GraphDriver's thread.
-  enum GraphRunType {
-    DIRECT_DRIVER,
-    SINGLE_THREAD,
-  };
   static const uint32_t AUDIO_CALLBACK_DRIVER_SHUTDOWN_TIMEOUT = 20 * 1000;
   static const TrackRate REQUEST_DEFAULT_SAMPLE_RATE = 0;
 
   // Main thread only
   static MediaStreamGraph* GetInstanceIfExists(nsPIDOMWindowInner* aWindow,
                                                TrackRate aSampleRate);
   static MediaStreamGraph* GetInstance(GraphDriverType aGraphDriverRequested,
                                        nsPIDOMWindowInner* aWindow,
@@ -1327,18 +1319,18 @@ class MediaStreamGraph {
  protected:
   explicit MediaStreamGraph(TrackRate aSampleRate) : mSampleRate(aSampleRate) {
     MOZ_COUNT_CTOR(MediaStreamGraph);
   }
   virtual ~MediaStreamGraph() { MOZ_COUNT_DTOR(MediaStreamGraph); }
 
   // Intended only for assertions, either on graph thread or not running (in
   // which case we must be on the main thread).
-  virtual bool OnGraphThreadOrNotRunning() const = 0;
-  virtual bool OnGraphThread() const = 0;
+  bool OnGraphThreadOrNotRunning() const;
+  bool OnGraphThread() const;
 
   /**
    * Sample rate at which this graph runs. For real time graphs, this is
    * the rate of the audio mixer. For offline graphs, this is the rate specified
    * at construction.
    */
   TrackRate mSampleRate;
 };
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -26,17 +26,16 @@
 namespace mozilla {
 
 namespace media {
 class ShutdownTicket;
 }
 
 template <typename T>
 class LinkedList;
-class GraphRunner;
 
 /**
  * A per-stream update message passed from the media graph thread to the
  * main thread.
  */
 struct StreamUpdate {
   RefPtr<MediaStream> mStream;
   StreamTime mNextMainThreadCurrentTime;
@@ -105,32 +104,18 @@ class MediaStreamGraphImpl : public Medi
    * Use aGraphDriverRequested with SYSTEM_THREAD_DRIVER or AUDIO_THREAD_DRIVER
    * to create a MediaStreamGraph which provides support for real-time audio
    * and/or video.  Set it to OFFLINE_THREAD_DRIVER in order to create a
    * non-realtime instance which just churns through its inputs and produces
    * output.  Those objects currently only support audio, and are used to
    * implement OfflineAudioContext.  They do not support MediaStream inputs.
    */
   explicit MediaStreamGraphImpl(GraphDriverType aGraphDriverRequested,
-                                GraphRunType aRunTypeRequested,
                                 TrackRate aSampleRate, AbstractThread* aWindow);
 
-  // Intended only for assertions, either on graph thread or not running (in
-  // which case we must be on the main thread).
-  bool OnGraphThreadOrNotRunning() const override;
-  bool OnGraphThread() const override;
-
-#ifdef DEBUG
-  /**
-   * True if we're on aDriver's thread, or if we're on mGraphRunner's thread
-   * and mGraphRunner is currently run by aDriver.
-   */
-  bool RunByGraphDriver(GraphDriver* aDriver);
-#endif
-
   /**
    * Unregisters memory reporting and deletes this instance. This should be
    * called instead of calling the destructor directly.
    */
   void Destroy();
 
   // Main thread only.
   /**
@@ -190,29 +175,21 @@ class MediaStreamGraphImpl : public Medi
       already_AddRefed<nsISupports> aHandlerData);
 
   /**
    * Returns true if this MediaStreamGraph should keep running
    */
   bool UpdateMainThreadState();
 
   /**
-   * Proxy method called by GraphDriver to iterate the graph.
-   * If this graph was created with GraphRunType SINGLE_THREAD, mGraphRunner
-   * will take care of calling OneIterationImpl from its thread. Otherwise,
-   * OneIterationImpl is called directly.
+   * Returns true if this MediaStreamGraph should keep running
    */
   bool OneIteration(GraphTime aStateEnd);
 
   /**
-   * Returns true if this MediaStreamGraph should keep running
-   */
-  bool OneIterationImpl(GraphTime aStateEnd);
-
-  /**
    * Called from the driver, when the graph thread is about to stop, to tell
    * the main thread to attempt to begin cleanup.  The main thread may either
    * shutdown or revive the graph depending on whether it receives new
    * messages.
    */
   void SignalMainThreadCleanup();
 
   /* This is the end of the current iteration, that is, the current time of the
@@ -260,17 +237,17 @@ class MediaStreamGraphImpl : public Medi
   void RunMessagesInQueue();
   /**
    * Update stream processing order and recompute stream blocking until
    * aEndBlockingDecisions.
    */
   void UpdateGraph(GraphTime aEndBlockingDecisions);
 
   void SwapMessageQueues() {
-    MOZ_ASSERT(OnGraphThread());
+    MOZ_ASSERT(CurrentDriver()->OnThread());
     MOZ_ASSERT(mFrontMessageQueue.IsEmpty());
     mMonitor.AssertCurrentThreadOwns();
     mFrontMessageQueue.SwapElements(mBackMessageQueue);
   }
   /**
    * Do all the processing and play the audio and video, from
    * mProcessedTime to mStateComputedTime.
    */
@@ -522,17 +499,17 @@ class MediaStreamGraphImpl : public Medi
   /**
    * Effectively set the new driver, while we are switching.
    * It is only safe to call this at the very end of an iteration, when there
    * has been a SwitchAtNextIteration call during the iteration. The driver
    * should return and pass the control to the new driver shortly after.
    * We can also switch from Revive() (on MainThread). Monitor must be held.
    */
   void SetCurrentDriver(GraphDriver* aDriver) {
-    MOZ_ASSERT(RunByGraphDriver(mDriver) || !mDriver->ThreadRunning());
+    MOZ_ASSERT(mDriver->OnThread() || !mDriver->ThreadRunning());
 #ifdef DEBUG
     mMonitor.AssertCurrentThreadOwns();
 #endif
     mDriver = aDriver;
   }
 
   Monitor& GetMonitor() { return mMonitor; }
 
@@ -606,23 +583,17 @@ class MediaStreamGraphImpl : public Medi
     iterator end() { return iterator(); }
 
    private:
     MediaStreamGraphImpl& mGraph;
   };
   StreamSet AllStreams() { return StreamSet(*this); }
 
   // Data members
-
-  /*
-   * If set, the GraphRunner class handles handing over data from audio
-   * callbacks to a common single thread, shared across GraphDrivers.
-   */
-  const UniquePtr<GraphRunner> mGraphRunner;
-
+  //
   /**
    * Graphs own owning references to their driver, until shutdown. When a driver
    * switch occur, previous driver is either deleted, or it's ownership is
    * passed to a event that will take care of the asynchronous cleanup, as
    * audio stream can take some time to shut down.
    * Accessed on both the main thread and the graph thread; both read and write.
    * Must hold monitor to access it.
    */
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -235,17 +235,16 @@ UNIFIED_SOURCES += [
     'ChannelMediaDecoder.cpp',
     'ChannelMediaResource.cpp',
     'CloneableWithRangeMediaResource.cpp',
     'DOMMediaStream.cpp',
     'FileBlockCache.cpp',
     'FileMediaResource.cpp',
     'GetUserMediaRequest.cpp',
     'GraphDriver.cpp',
-    'GraphRunner.cpp',
     'ImageToI420.cpp',
     'MediaCache.cpp',
     'MediaContainerType.cpp',
     'MediaData.cpp',
     'MediaDecoder.cpp',
     'MediaDecoderStateMachine.cpp',
     'MediaDeviceInfo.cpp',
     'MediaDevices.cpp',
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -649,34 +649,34 @@ AudioInputProcessing::AudioInputProcessi
       mTrackID(aTrackID),
       mPrincipal(aPrincipalHandle),
       mEnabled(false),
       mEnded(false) {
 }
 
 void AudioInputProcessing::Disconnect(MediaStreamGraphImpl* aGraph) {
   // This method is just for asserts.
-  MOZ_ASSERT(aGraph->OnGraphThread());
+  MOZ_ASSERT(aGraph->CurrentDriver()->OnThread());
 }
 
 void MediaEngineWebRTCMicrophoneSource::Shutdown() {
   AssertIsOnOwningThread();
 
   if (mState == kStarted) {
     Stop(nullptr);
     MOZ_ASSERT(mState == kStopped);
   }
 
   MOZ_ASSERT(mState == kAllocated || mState == kStopped);
   Deallocate(nullptr);
   MOZ_ASSERT(mState == kReleased);
 }
 
 bool AudioInputProcessing::PassThrough(MediaStreamGraphImpl* aGraph) const {
-  MOZ_ASSERT(aGraph->OnGraphThread());
+  MOZ_ASSERT(aGraph->CurrentDriver()->OnThread());
   return mSkipProcessing;
 }
 
 void AudioInputProcessing::SetPassThrough(bool aPassThrough) {
   mSkipProcessing = aPassThrough;
 }
 
 uint32_t AudioInputProcessing::GetRequestedInputChannelCount(
@@ -846,17 +846,17 @@ void AudioInputProcessing::Pull(const Re
   audio.AppendNullData(delta);
   aStream->AppendToTrack(aTrackID, &audio);
 }
 
 void AudioInputProcessing::NotifyOutputData(MediaStreamGraphImpl* aGraph,
                                             AudioDataValue* aBuffer,
                                             size_t aFrames, TrackRate aRate,
                                             uint32_t aChannels) {
-  MOZ_ASSERT(aGraph->OnGraphThread());
+  MOZ_ASSERT(aGraph->CurrentDriver()->OnThread());
   MOZ_ASSERT(mEnabled);
 
   if (!mPacketizerOutput || mPacketizerOutput->PacketSize() != aRate / 100u ||
       mPacketizerOutput->Channels() != aChannels) {
     // It's ok to drop the audio still in the packetizer here: if this changes,
     // we changed devices or something.
     mPacketizerOutput =
         new AudioPacketizer<AudioDataValue, float>(aRate / 100, aChannels);
@@ -1091,17 +1091,17 @@ void AudioInputProcessing::InsertInGraph
 }
 
 // Called back on GraphDriver thread!
 // Note this can be called back after ::Shutdown()
 void AudioInputProcessing::NotifyInputData(MediaStreamGraphImpl* aGraph,
                                            const AudioDataValue* aBuffer,
                                            size_t aFrames, TrackRate aRate,
                                            uint32_t aChannels) {
-  MOZ_ASSERT(aGraph->OnGraphThread());
+  MOZ_ASSERT(aGraph->CurrentDriver()->OnThread());
   TRACE_AUDIO_CALLBACK();
 
   MOZ_ASSERT(mEnabled);
 
   // If some processing is necessary, packetize and insert in the WebRTC.org
   // code. Otherwise, directly insert the mic data in the MSG, bypassing all
   // processing.
   if (PassThrough(aGraph)) {
@@ -1127,17 +1127,17 @@ void AudioInputProcessing::NotifyInputDa
         NS_WARNING("Could not reset the status of the " #_processing \
                    " on device change.");                            \
         return;                                                      \
       }                                                              \
     }                                                                \
   } while (0)
 
 void AudioInputProcessing::DeviceChanged(MediaStreamGraphImpl* aGraph) {
-  MOZ_ASSERT(aGraph->OnGraphThread());
+  MOZ_ASSERT(aGraph->CurrentDriver()->OnThread());
   // Reset some processing
   ResetProcessingIfNeeded(gain_control);
   ResetProcessingIfNeeded(echo_cancellation);
   ResetProcessingIfNeeded(noise_suppression);
 }
 
 void AudioInputProcessing::End() { mEnded = true; }