Bug 1590319 - Revert async task queueing in MediaRecorder::Pause()/Resume(). r=jib
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 23 Oct 2019 13:04:12 +0000
changeset 498700 d6e5123eba183aa2f6c75aa57a541f128587a1a5
parent 498699 8b72f1465217f66f3715dd277cf8d303dda11f65
child 498701 243d10dad9d810f0261d9c5bfb88fac2cd46cbff
push id36724
push useraiakab@mozilla.com
push dateWed, 23 Oct 2019 21:54:06 +0000
treeherdermozilla-central@82274c202574 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1590319
milestone72.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 1590319 - Revert async task queueing in MediaRecorder::Pause()/Resume(). r=jib Differential Revision: https://phabricator.services.mozilla.com/D50030
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1608,24 +1608,26 @@ void MediaRecorder::Pause(ErrorResult& a
   // 2. If state is paused, abort these steps.
   if (mState == RecordingState::Paused) {
     return;
   }
 
   // 3. Set state to paused, and queue a task, using the DOM manipulation task
   //    source, that runs the following steps:
   mState = RecordingState::Paused;
+
+  // XXX - We pause synchronously pending spec issue
+  //       https://github.com/w3c/mediacapture-record/issues/131
+  //   1. Stop gathering data into blob (but keep it available so that
+  //      recording can be resumed in the future).
   MOZ_ASSERT(!mSessions.IsEmpty());
+  mSessions.LastElement()->Pause();
+
   NS_DispatchToMainThread(NS_NewRunnableFunction(
-      "MediaRecorder::Pause", [session = mSessions.LastElement(),
-                               recorder = RefPtr<MediaRecorder>(this)] {
-        // 1. Stop gathering data into blob (but keep it available so that
-        //    recording can be resumed in the future).
-        session->Pause();
-
+      "MediaRecorder::Pause", [recorder = RefPtr<MediaRecorder>(this)] {
         // 2. Let target be the MediaRecorder context object. Fire an event
         //    named pause at target.
         recorder->DispatchSimpleEvent(NS_LITERAL_STRING("pause"));
       }));
 
   // 4. return undefined.
 }
 
@@ -1647,23 +1649,25 @@ void MediaRecorder::Resume(ErrorResult& 
   // 2. If state is recording, abort these steps.
   if (mState == RecordingState::Recording) {
     return;
   }
 
   // 3. Set state to recording, and queue a task, using the DOM manipulation
   //    task source, that runs the following steps:
   mState = RecordingState::Recording;
+
+  // XXX - We resume synchronously pending spec issue
+  //       https://github.com/w3c/mediacapture-record/issues/131
+  //   1. Resume (or continue) gathering data into the current blob.
   MOZ_ASSERT(!mSessions.IsEmpty());
+  mSessions.LastElement()->Resume();
+
   NS_DispatchToMainThread(NS_NewRunnableFunction(
-      "MediaRecorder::Resume", [session = mSessions.LastElement(),
-                                recorder = RefPtr<MediaRecorder>(this)] {
-        // 1. Resume (or continue) gathering data into the current blob.
-        session->Resume();
-
+      "MediaRecorder::Resume", [recorder = RefPtr<MediaRecorder>(this)] {
         // 2. Let target be the MediaRecorder context object. Fire an event
         //    named resume at target.
         recorder->DispatchSimpleEvent(NS_LITERAL_STRING("resume"));
       }));
 
   // 4. return undefined.
 }