Backout e62c37b8e6b5 for Mulet test failure
authorChris Double <chris.double@double.co.nz>
Wed, 19 Nov 2014 16:00:09 +1300
changeset 240714 1f9f483663196eb47517b579a18fd3fa7bf95fea
parent 240713 f3335fb1f0b89f406c691d504f9bd443efe483ca
child 240715 ce076d08ad78abf4e9d693eac704fbe66b5265db
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone36.0a1
backs oute62c37b8e6b5412029bf81b08481f4f52849f654
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
Backout e62c37b8e6b5 for Mulet test failure
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/SourceBuffer.cpp
dom/media/mediasource/SourceBuffer.h
dom/media/mediasource/SourceBufferList.cpp
dom/media/mediasource/SourceBufferList.h
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_BufferedSeek.html
dom/media/mediasource/test/test_EndOfStream.html
dom/media/mediasource/test/test_FrameSelection.html
dom/media/mediasource/test/test_MediaSource.html
dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html
dom/media/mediasource/test/test_SplitAppend.html
dom/media/mediasource/test/test_SplitAppendDelay.html
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -413,20 +413,24 @@ MediaSource::QueueAsyncSimpleEvent(const
   nsCOMPtr<nsIRunnable> event = new AsyncEventRunner<MediaSource>(this, aName);
   NS_DispatchToMainThread(event);
 }
 
 void
 MediaSource::DurationChange(double aOldDuration, double aNewDuration)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("MediaSource(%p)::DurationChange(aOldDuration=%f, aNewDuration=%f)", this, aOldDuration, aNewDuration);
+  MSE_DEBUG("MediaSource(%p)::DurationChange(aNewDuration=%f)", this, aNewDuration);
 
   if (aNewDuration < aOldDuration) {
-    mSourceBuffers->RangeRemoval(aNewDuration, aOldDuration);
+    ErrorResult rv;
+    mSourceBuffers->Remove(aNewDuration, aOldDuration, rv);
+    if (rv.Failed()) {
+      return;
+    }
   }
   // TODO: If partial audio frames/text cues exist, clamp duration based on mSourceBuffers.
 }
 
 void
 MediaSource::NotifyEvicted(double aStart, double aEnd)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -183,29 +183,20 @@ SourceBuffer::Remove(double aStart, doub
     return;
   }
   if (IsNaN(mMediaSource->Duration()) ||
       aStart < 0 || aStart > mMediaSource->Duration() ||
       aEnd <= aStart || IsNaN(aEnd)) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return;
   }
-  if (mUpdating) {
+  if (mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
-  if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
-    mMediaSource->SetReadyState(MediaSourceReadyState::Open);
-  }
-  RangeRemoval(aStart, aEnd);
-}
-
-void
-SourceBuffer::RangeRemoval(double aStart, double aEnd)
-{
   StartUpdating();
   /// TODO: Run coded frame removal algorithm.
 
   // Run the final step of the coded frame removal algorithm asynchronously
   // to ensure the SourceBuffer's updating flag transition behaves as
   // required by the spec.
   nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
   NS_DispatchToMainThread(event);
--- a/dom/media/mediasource/SourceBuffer.h
+++ b/dom/media/mediasource/SourceBuffer.h
@@ -103,19 +103,16 @@ public:
   void Ended();
 
   // Evict data in the source buffer in the given time range.
   void Evict(double aStart, double aEnd);
 
   double GetBufferedStart();
   double GetBufferedEnd();
 
-  // Runs the range removal algorithm as defined by the MSE spec.
-  void RangeRemoval(double aStart, double aEnd);
-
 #if defined(DEBUG)
   void Dump(const char* aPath);
 #endif
 
 private:
   ~SourceBuffer();
 
   friend class AsyncEventRunner<SourceBuffer>;
--- a/dom/media/mediasource/SourceBufferList.cpp
+++ b/dom/media/mediasource/SourceBufferList.cpp
@@ -103,22 +103,25 @@ SourceBufferList::AnyUpdating()
     if (mSourceBuffers[i]->Updating()) {
       return true;
     }
   }
   return false;
 }
 
 void
-SourceBufferList::RangeRemoval(double aStart, double aEnd)
+SourceBufferList::Remove(double aStart, double aEnd, ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("SourceBufferList(%p)::RangeRemoval(aStart=%f, aEnd=%f", this, aStart, aEnd);
+  MSE_DEBUG("SourceBufferList(%p)::Remove(aStart=%f, aEnd=%f", this, aStart, aEnd);
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
-    mSourceBuffers[i]->RangeRemoval(aStart, aEnd);
+    mSourceBuffers[i]->Remove(aStart, aEnd, aRv);
+    if (aRv.Failed()) {
+      return;
+    }
   }
 }
 
 void
 SourceBufferList::Evict(double aStart, double aEnd)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("SourceBufferList(%p)::Evict(aStart=%f, aEnd=%f)", this, aStart, aEnd);
--- a/dom/media/mediasource/SourceBufferList.h
+++ b/dom/media/mediasource/SourceBufferList.h
@@ -61,18 +61,19 @@ public:
   void Clear();
 
   // True if list has zero entries.
   bool IsEmpty();
 
   // Returns true if updating is true on any SourceBuffers in the list.
   bool AnyUpdating();
 
-  // Runs the range removal steps from the MSE specification on each SourceBuffer.
-  void RangeRemoval(double aStart, double aEnd);
+  // Calls Remove(aStart, aEnd) on each SourceBuffer in the list.  Aborts on
+  // first error, with result returned in aRv.
+  void Remove(double aStart, double aEnd, ErrorResult& aRv);
 
   // Mark all SourceBuffers input buffers as ended.
   void Ended();
 
   // Evicts data for the given time range from each SourceBuffer in the list.
   void Evict(double aStart, double aEnd);
 
   // Returns the highest end time of any of the Sourcebuffers.
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -4,18 +4,16 @@ support-files =
   mediasource.js
   seek.webm seek.webm^headers^
   seek_lowres.webm seek_lowres.webm^headers^
 
 [test_MediaSource.html]
 [test_MediaSource_disabled.html]
 [test_BufferedSeek.html]
 [test_BufferingWait.html]
-[test_EndOfStream.html]
-skip-if = (toolkit == 'android') #timeout android only bug 1101187
 [test_FrameSelection.html]
 [test_HaveMetadataUnbufferedSeek.html]
 [test_LoadedMetadataFired.html]
 [test_SeekableAfterEndOfStream.html]
 [test_SeekableAfterEndOfStreamSplit.html]
 [test_SeekableBeforeEndOfStream.html]
 [test_SeekableBeforeEndOfStreamSplit.html]
 [test_SplitAppendDelay.html]
--- a/dom/media/mediasource/test/test_BufferedSeek.html
+++ b/dom/media/mediasource/test/test_BufferedSeek.html
@@ -7,32 +7,24 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       sb.addEventListener("updateend", function () {
-        updateCount++;
-        /* Ensure that we endOfStream on the first update event only as endOfStream can
-           raise more if the duration of the last buffered range and the intial duration
-           differ. See bug 1065207 */
-        if (updateCount == 1) {
-          ms.endOfStream();
-        };
+        ms.endOfStream()
       });
     });
 
     var target = 2;
 
     v.addEventListener("loadedmetadata", function () {
       if (v.currentTime != target &&
           v.buffered.length &&
deleted file mode 100644
--- a/dom/media/mediasource/test/test_EndOfStream.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>MSE: endOfStream call after an appendBuffer</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="mediasource.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-SimpleTest.waitForExplicitFinish();
-
-runWithMSE(function () {
-  var ms = new MediaSource();
-
-  var v = document.createElement("video");
-  v.src = URL.createObjectURL(ms);
-  document.body.appendChild(v);
-
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
-
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
-      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 88966));
-      var count = 0;
-      sb.addEventListener("updateend", function () {
-        ++count;
-        if (count == 1) {
-          setTimeout(function() {
-                       var fail = false;
-                       try {
-                         ms.endOfStream();
-                       } catch (e) {
-                         fail = true;
-                       }
-                       ok(!fail, "MediaSource.endOfStream succeeded");
-                       SimpleTest.finish();
-                     }, 0);
-        }
-      });
-    });
-  });
-});
-
-</script>
-</pre>
-</body>
-</html>
--- a/dom/media/mediasource/test/test_FrameSelection.html
+++ b/dom/media/mediasource/test/test_FrameSelection.html
@@ -7,18 +7,16 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       // Append entire file covering range [0, 4].
       sb.appendBuffer(new Uint8Array(arrayBuffer));
     });
@@ -31,23 +29,23 @@ runWithMSE(function (ms, v) {
     v.addEventListener("loadedmetadata", function () {
       is(v.currentTime, 0, "currentTime has correct initial value");
       is(v.videoWidth, 320, "videoWidth has correct initial value");
       is(v.videoHeight, 240, "videoHeight has correct initial value");
 
       fetchWithXHR("seek_lowres.webm", function (arrayBuffer) {
         // Append initialization segment.
         sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
+        var first = true;
         sb.addEventListener("updateend", function () {
-          updateCount++;
-          if (updateCount == 1) {
+          if (first) {
             // Append media segment covering range [2, 4].
             sb.appendBuffer(new Uint8Array(arrayBuffer, 51003));
-          }
-          else if (updateCount == 2) {
+            first = false;
+          } else {
             ms.endOfStream();
             target = targets.shift();
             v.currentTime = target.currentTime;
           }
         });
       });
     });
 
--- a/dom/media/mediasource/test/test_MediaSource.html
+++ b/dom/media/mediasource/test/test_MediaSource.html
@@ -52,22 +52,17 @@ runWithMSE(function () {
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
     });
 
     sb.addEventListener("update", function () {
       is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
       updateCount++;
-      /* Ensure that we endOfStream on the first update event only as endOfStream can
-         raise more if the duration of the last buffered range and the intial duration
-         differ. See bug 1065207 */
-      if (updateCount == 1) {
-        ms.endOfStream();
-      }
+      ms.endOfStream();
     });
 
     sb.addEventListener("updatestart", function () {
       updatestartCount++;
     });
 
     sb.addEventListener("updateend", function () {
       is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
@@ -84,20 +79,19 @@ runWithMSE(function () {
   v.addEventListener("loadedmetadata", function () {
     loadedmetadataCount++;
   });
 
   v.addEventListener("ended", function () {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
-    // XXX: 2 update events can be received dueto duration differences, see bug 1065207.
-    ok(updateCount == 1 || updateCount == 2, "update event received");
-    ok(updateendCount == 1 || updateendCount == 2, "updateend event received");
-    ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received");
+    is(updateCount, 1, "update event received");
+    is(updateendCount, 1, "updateend event received");
+    is(updatestartCount, 1, "updatestart event received");
     is(loadedmetadataCount, 1, "loadedmetadata event received");
     v.parentNode.removeChild(v);
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
+++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
@@ -7,32 +7,24 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       sb.addEventListener("updateend", function () {
-        updateCount++;
-        /* Ensure that we endOfStream on the first update event only as endOfStream can
-           raise more if the duration of the last buffered range and the intial duration
-           differ. See bug 1065207 */
-        if (updateCount == 1) {
-          ms.endOfStream();
-        };
+        ms.endOfStream()
       });
     });
 
     var target = 2;
 
     v.addEventListener("loadedmetadata", function () {
       ok(v.seekable.length, "Resource is seekable");
       ok(v.seekable.length &&
--- a/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html
+++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html
@@ -19,17 +19,17 @@ runWithMSE(function (ms, v) {
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25223));
       var updateCount = 0;
       sb.addEventListener("updateend", function () {
         updateCount++;
         if (updateCount == 1) {
           sb.appendBuffer(new Uint8Array(arrayBuffer, 25223));
         }
-        else if (updateCount == 2) {
+        else {
           ms.endOfStream();
         }
       });
     });
 
     var target = 2;
 
     v.addEventListener("loadedmetadata", function () {
--- a/dom/media/mediasource/test/test_SplitAppend.html
+++ b/dom/media/mediasource/test/test_SplitAppend.html
@@ -7,30 +7,28 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
+      var first = true;
       sb.addEventListener("updateend", function () {
-        updateCount++;
-        if (updateCount == 1) {
+        if (first) {
           sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
-        }
-        else if (updateCount == 2) {
+          first = false;
+        } else {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
   v.addEventListener("ended", function () {
--- a/dom/media/mediasource/test/test_SplitAppendDelay.html
+++ b/dom/media/mediasource/test/test_SplitAppendDelay.html
@@ -7,32 +7,30 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
+      var first = true;
       sb.addEventListener("updateend", function () {
-        updateCount++;
-        if (updateCount == 1) {
+        if (first) {
           window.setTimeout(function () {
             sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
+            first = false;
           }, 1000);
-        }
-        else if (updateCount == 2) {
+        } else {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
   v.addEventListener("ended", function () {