Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r=tnikkel
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 29 Aug 2016 16:22:57 -0400
changeset 311748 29f27e5ab2177d8f4ee0c3c9eb06d8705985b14a
parent 311747 414e2d95cffec1713b152f17878eec09f33963c8
child 311749 ee96068b9523274d9354b0b530f97d2b15ce9a08
push id20417
push userryanvm@gmail.com
push dateTue, 30 Aug 2016 13:55:34 +0000
treeherderfx-team@b18c8bcdc116 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1298084
milestone51.0a1
Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r=tnikkel MozReview-Commit-ID: 2q9hdZPjrPt
gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
--- a/gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
+++ b/gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
@@ -608,27 +608,42 @@ function* test(testDriver) {
   utils.setDisplayPortMarginsForElement(0, 0, 0, 0, elm, 0);
 
   var maxScroll = elm.scrollTopMax;
   elm.scrollTop = maxScroll;
   yield waitForAllPaints(function() {
     flushApzRepaints(testDriver);
   });
 
+  // Take control of the refresh driver
+  utils.advanceTimeAndRefresh(0);
+
+  // Force the next reflow to get interrupted
   utils.forceReflowInterrupt();
-  // Trigger the frame reconstruction. The reflow that results will be
-  // interrupted, and we should end up with a transient 0,0 scroll offset.
+
+  // Make a change that triggers frame reconstruction, and then tick the refresh
+  // driver so that layout processes the pending restyles and then runs an
+  // interruptible reflow. That reflow *will* be interrupted (because of the flag
+  // we set above), and we should end up with a transient 0,0 scroll offset
+  // being sent to the compositor.
   elm.parentNode.classList.add('contentBefore');
-  yield waitForAllPaints(function() {
-    flushApzRepaints(testDriver);
-  });
+  utils.advanceTimeAndRefresh(0);
+  // On android, and maybe non-e10s platforms generally, we need to manually
+  // kick the paint to send the layer transaction to the compositor.
+  yield waitForAllPaints(function() { setTimeout(testDriver, 0) });
 
+  // Read the main-thread scroll offset; although this is temporarily 0,0 that
+  // temporary value is never exposed to content - instead reading this value
+  // will finish doing the interrupted reflow from above and then report the
+  // correct scroll offset.
   is(elm.scrollTop, maxScroll, "Main-thread scroll position was restored");
 
-  // Ensure the interrupted reflow finished and got pushed to the APZ
+  // .. and now flush everything to make sure the state gets pushed over to the
+  // compositor and APZ as well.
+  utils.restoreNormalRefresh();
   yield waitForApzFlushedRepaints(testDriver);
 
   // Now we pull the compositor data and check it. What we expect to see is that
   // the scroll position goes to maxScroll, then drops to 0 and then goes back
   // to maxScroll. This test is specifically testing that last bit - that it
   // properly gets restored from 0 to maxScroll.
   // The one hitch is that on Android this page is loaded with some amount of
   // zoom, and the async scroll is in ParentLayerPixel coordinates, so it will