Bug 1455841 - Don't update mPreviousFrameTimeStamp in the case of testing refresh mode. r?kats draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 23 Apr 2018 06:27:19 +0900
changeset 786309 4d5cbd8119de2653c6ba4a42598dd5a64b682bbc
parent 786082 d36d2c2ab772c4b5479e2516a87e830cab8da509
child 786409 70476d3c06b0146a3f472fa3e9d304f08b4603cc
push id107431
push userhikezoe@mozilla.com
push dateSun, 22 Apr 2018 21:27:56 +0000
reviewerskats
bugs1455841
milestone61.0a1
Bug 1455841 - Don't update mPreviousFrameTimeStamp in the case of testing refresh mode. r?kats On the testing refresh mode, we shouldn't update mPreviousFrameTimeStamp and don't need to use it since there shouldn't have any time difference between compositor time stamp and main-thread time stamp on the testing mode. MozReview-Commit-ID: FCcyEcFhmU
gfx/layers/wr/WebRenderBridgeParent.cpp
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -1160,34 +1160,42 @@ void
 WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   Destroy();
 }
 
 void
 WebRenderBridgeParent::AdvanceAnimations()
 {
-  Maybe<TimeStamp> testingTimeStamp;
   if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
-    testingTimeStamp = cbp->GetTestingTimeStamp();
+    Maybe<TimeStamp> testingTimeStamp = cbp->GetTestingTimeStamp();
+    if (testingTimeStamp) {
+      // If we are on testing refresh mode, use the testing time stamp.  And
+      // also we don't update mPreviousFrameTimeStamp since unlike normal
+      // refresh mode, on the testing mode animations on the compositor are
+      // synchronously composed, so we don't need to worry about the time gap
+      // between the main thread and compositor thread.
+      AnimationHelper::SampleAnimations(mAnimStorage, *testingTimeStamp);
+      return;
+    }
   }
 
-  TimeStamp animTime = testingTimeStamp.valueOr(
-    !mPreviousFrameTimeStamp.IsNull()
-    ? mPreviousFrameTimeStamp
-    : mCompositorScheduler->GetLastComposeTime());
-
-
-  AnimationHelper::SampleAnimations(mAnimStorage, animTime);
+  TimeStamp lastComposeTime = mCompositorScheduler->GetLastComposeTime();
+  // if we have already mPreviousTimeStamp, use it since on the compositor the
+  // time in the previous tick is more closer to the main-thread tick time.
+  AnimationHelper::SampleAnimations(mAnimStorage,
+      !mPreviousFrameTimeStamp.IsNull()
+      ? mPreviousFrameTimeStamp
+      : lastComposeTime);
 
   // Reset the previous time stamp if we don't already have any running
   // animations to avoid using the time which is far behind for newly
   // started animations.
   mPreviousFrameTimeStamp =
-    mAnimStorage->AnimatedValueCount() ? animTime : TimeStamp();
+    mAnimStorage->AnimatedValueCount() ? lastComposeTime : TimeStamp();
 }
 
 void
 WebRenderBridgeParent::SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
                                         nsTArray<wr::WrTransformProperty>& aTransformArray)
 {
   AdvanceAnimations();