Bug 1401919 - Functions used after the seekToNextFrame promise should not be interpreted half the time, r=nbp.
authorFlorian Quèze <florian@queze.net>
Wed, 04 Oct 2017 16:01:04 +0200
changeset 1311794 03487f70562ad79f1248190255fc193be9bbd8fa
parent 1311793 77b91f388fee2c961a00c39ae6314934392ec351
child 1311795 33ef79c5fe06fb8aee5ca32fd700b5a5091899ff
push id225897
push useropettay@mozilla.com
push dateWed, 04 Oct 2017 19:25:01 +0000
treeherdertry@2f2f41234c44 [default view] [failures only]
reviewersnbp
bugs1401919
milestone58.0a1
Bug 1401919 - Functions used after the seekToNextFrame promise should not be interpreted half the time, r=nbp.
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2655,16 +2655,28 @@ HTMLMediaElement::FastSeek(double aTime,
   LOG(LogLevel::Debug, ("Reporting telemetry VIDEO_FASTSEEK_USED"));
   Telemetry::Accumulate(Telemetry::VIDEO_FASTSEEK_USED, 1);
   RefPtr<Promise> tobeDropped = Seek(aTime, SeekTarget::PrevSyncPoint, aRv);
 }
 
 already_AddRefed<Promise>
 HTMLMediaElement::SeekToNextFrame(ErrorResult& aRv)
 {
+  /* This will cause JIT code to be kept around longer, to help performance
+   * when using SeekToNextFrame to iterate through every frame of a video.
+   */
+  nsCOMPtr<nsIGlobalObject> global =
+    do_QueryInterface(OwnerDoc()->GetInnerWindow());
+
+  if (global) {
+    if (JSObject *obj = global->GetGlobalJSObject()) {
+      js::NotifyAnimationActivity(obj);
+    }
+  }
+
   return Seek(CurrentTime(), SeekTarget::NextFrame, aRv);
 }
 
 void
 HTMLMediaElement::SetCurrentTime(double aCurrentTime, ErrorResult& aRv)
 {
   RefPtr<Promise> tobeDropped = Seek(aCurrentTime, SeekTarget::Accurate, aRv);
 }