Bug 1451149 - P2. Don't fire the "stalled" event when using MSE. r?bryce draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 14 May 2018 11:32:09 +0200
changeset 799394 3fd3a990f528d1a44407668e1a6e8153107b5c5e
parent 799393 70dc58a31eb01fcccda8bb3a8960c78e9b8c4211
push id111035
push userbmo:jyavenard@mozilla.com
push dateThu, 24 May 2018 16:00:26 +0000
reviewersbryce
bugs1451149
milestone62.0a1
Bug 1451149 - P2. Don't fire the "stalled" event when using MSE. r?bryce When using a media element with a Media Source, the resource fetching algorithm is to be called in "local" mode: https://www.w3.org/TR/media-source/#mediasource-attach "Continue the resource fetch algorithm by running the remaining "Otherwise (mode is local)" steps, with these clarifications" https://html.spec.whatwg.org/multipage/media.html#concept-media-load-resource Under the local mode, the steps that would cause the element to fire suspend, stalled or progress can never occur. We only prevent the stalled event to be fired, many websites rely on the progress event to be fired (such as when the init segment has been parsed). The HTML5 media spec will be amended to clearly indicate that progress is to be fired even with mediasource MozReview-Commit-ID: DkoQzoV0JzO
dom/html/HTMLMediaElement.cpp
dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5712,19 +5712,19 @@ HTMLMediaElement::CheckProgress(bool aHa
       }
     }
     // Download statistics may have been updated, force a recheck of the
     // readyState.
     UpdateReadyStateInternal();
   }
 
   if (now - mDataTime >= TimeDuration::FromMilliseconds(STALL_MS)) {
-    DispatchAsyncEvent(NS_LITERAL_STRING("stalled"));
-
-    if (mMediaSource) {
+    if (!mMediaSource) {
+      DispatchAsyncEvent(NS_LITERAL_STRING("stalled"));
+    } else {
       ChangeDelayLoadStatus(false);
     }
 
     NS_ASSERTION(mProgressTimer, "detected stalled without timer");
     // Stop timer events, which prevents repeated stalled events until there
     // is more progress.
     StopProgress();
   }
--- a/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
@@ -18,17 +18,17 @@ runWithMSE(function(ms, el) {
     const sb = ms.addSourceBuffer("video/mp4");
     fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
     .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
     .then(function() {
       el.play();
       // let seek to the last audio frame.
       // The seek will complete and then playback will stall.
       el.currentTime = 1.532517;
-      return Promise.all([ once(el, "seeked"), once(el, "stalled") ]);
+      return Promise.all([ once(el, "seeked"), once(el, "waiting") ]);
     })
     .then(function() {
       info("seek completed");
       return fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
     })
     .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", range(1, 4), ".m4s"))
     .then(function() {
       ms.endOfStream();