Bug 1548923 - part4 : prevent run `TimeMarchesOn` before media has any data. r=jya
authoralwu <alwu@mozilla.com>
Thu, 09 May 2019 01:33:36 +0000
changeset 532075 c64974ef15b2e1d1b58c8fa5ed16a641179af213
parent 532074 1a3bb9e678fe8a4d999dbf399d4c3f4d5a1aa6b5
child 532076 005917cd9f361ea5bebcd9af1000d5799ef724ac
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1548923
milestone68.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 1548923 - part4 : prevent run `TimeMarchesOn` before media has any data. r=jya In patch2, whenever the media element's readyState is changed back to HAVE_NOTHING, we would reset all cues' active flag and update cue display in order to hide them. It also means that we should not set any cue's flag when media element's readyState is `HAVE_NOTHING`, so we should abort the `TimeMarchesOn` in this situation. Differential Revision: https://phabricator.services.mozilla.com/D30390
dom/html/TextTrackManager.cpp
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -626,16 +626,22 @@ void TextTrackManager::TimeMarchesOn() {
   }
 
   nsISupports* parentObject = mMediaElement->OwnerDoc()->GetParentObject();
   if (NS_WARN_IF(!parentObject)) {
     return;
   }
   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
 
+  if (mMediaElement->ReadyState() == HTMLMediaElement_Binding::HAVE_NOTHING) {
+    WEBVTT_LOG(
+        "TimeMarchesOn return because media doesn't contain any data yet");
+    return;
+  }
+
   if (mMediaElement->Seeking()) {
     WEBVTT_LOG("TimeMarchesOn return during seeking");
     return;
   }
 
   // Step 3.
   auto currentPlaybackTime =
       media::TimeUnit::FromSeconds(mMediaElement->CurrentTime());