Bug 1329117 - Run HonorUserPreferencesForTrackSelection at stable state. r=jwwang, a=ritu
authorbechen <bechen@mozilla.com>
Mon, 23 Jan 2017 11:12:22 +0800
changeset 375811 9df75a609fd44c8b4ae337b283b01ec9a1309b5f
parent 375810 41325adb5477a84e8353c40c93ab717b357ec984
child 375812 d78356134309c0f119faf0b061a2d2320ba7dcb1
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, ritu
bugs1329117
milestone53.0a2
Bug 1329117 - Run HonorUserPreferencesForTrackSelection at stable state. r=jwwang, a=ritu MozReview-Commit-ID: FwZyHHFa8KD
dom/html/TextTrackManager.cpp
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -153,17 +153,19 @@ TextTrackManager::AddTextTrack(TextTrack
     NS_ConvertUTF16toUTF8(aLabel).get(), NS_ConvertUTF16toUTF8(aLanguage).get());
   RefPtr<TextTrack> track =
     mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState,
                               aTextTrackSource, CompareTextTracks(mMediaElement));
   AddCues(track);
   ReportTelemetryForTrack(track);
 
   if (aTextTrackSource == TextTrackSource::Track) {
-    NS_DispatchToMainThread(NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection));
+    RefPtr<nsIRunnable> task =
+      NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection);
+    nsContentUtils::RunInStableState(task.forget());
   }
 
   return track.forget();
 }
 
 void
 TextTrackManager::AddTextTrack(TextTrack* aTextTrack)
 {
@@ -171,17 +173,19 @@ TextTrackManager::AddTextTrack(TextTrack
     return;
   }
   WEBVTT_LOG("%p AddTextTrack TextTrack %p",this, aTextTrack);
   mTextTracks->AddTextTrack(aTextTrack, CompareTextTracks(mMediaElement));
   AddCues(aTextTrack);
   ReportTelemetryForTrack(aTextTrack);
 
   if (aTextTrack->GetTextTrackSource() == TextTrackSource::Track) {
-    NS_DispatchToMainThread(NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection));
+    RefPtr<nsIRunnable> task =
+      NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection);
+    nsContentUtils::RunInStableState(task.forget());
   }
 }
 
 void
 TextTrackManager::AddCues(TextTrack* aTextTrack)
 {
   if (!mNewCues) {
     WEBVTT_LOG("AddCues mNewCues is null");