Bug 1472654 - Drop SchedulePaint call in AddAnimationsForProperty. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 05 Jul 2018 07:18:45 +0900
changeset 425147 205ea36361d0e3aec701ddc5c2918152b88ef01e
parent 425146 ca35db7e2619a2bea6550fe716152ab8d460e664
child 425148 9a7aca342029408ef2903a80079cf2bd67df16ae
push id104984
push useraciure@mozilla.com
push dateThu, 05 Jul 2018 09:55:01 +0000
treeherdermozilla-inbound@35ae03d7cf2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1472654, 929362
milestone63.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 1472654 - Drop SchedulePaint call in AddAnimationsForProperty. r=birtles This call was added in bug 929362, but the key factor to fix the bug was just setting a flag representing that the target frame doesn't allow the animation running on the compositor and checking the flag in the function whether the animation can be run on the compositor or not in later ticks. So the call wasn't necessary in the first place. The test case here fails without this fix. The test case actually doesn't observe animation restyle count at all, so it might look a bit awkward in file_restyles.html, if we add other test cases checking SchedulePaint calls in future, we will move the tests in a different file. (The reason there is no animation restyles in this case is that we properly throttle the animation in this case.) MozReview-Commit-ID: AyHciRJHM0s
dom/animation/test/mozilla/file_restyles.html
layout/painting/nsDisplayList.cpp
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -1833,12 +1833,39 @@ waitForAllPaints(() => {
 
     const markers = await observeStylingInTargetWindow(iframe.contentWindow, 5);
     is(markers.length, 0,
        'Animation in out-of-view iframe should be throttled');
 
     await ensureElementRemoval(div);
   });
 
+  // Tests that transform animations are not able to run on the compositor due
+  // to layout restrictions (e.g. animations on a large size frame) doesn't
+  // flush layout at all.
+  add_task(async function flush_layout_for_transform_animations() {
+    // Set layout.animation.prerender.partial to disallow transform animations
+    // on large frames to be sent to the compositor.
+    await SpecialPowers.pushPrefEnv({
+      set: [['layout.animation.prerender.partial', false]] });
+    const div = addDiv(null, { style: 'width: 10000px; height: 10000px;' });
+
+    const animation = div.animate([ { transform: 'rotate(360deg)', } ],
+                                  { duration: 100 * MS_PER_SEC,
+                                    // Set step-end to skip further restyles.
+                                    easing: 'step-end' });
+
+    const FLUSH_LAYOUT = SpecialPowers.DOMWindowUtils.FLUSH_LAYOUT;
+    ok(SpecialPowers.DOMWindowUtils.needsFlush(FLUSH_LAYOUT),
+       'Flush layout is needed for the appended div');
+    await waitForAnimationReadyToRestyle(animation);
+
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
+    ok(!SpecialPowers.DOMWindowUtils.needsFlush(FLUSH_LAYOUT),
+       'No further flush layout needed');
+
+    await ensureElementRemoval(div);
+  });
+
 });
 
 </script>
 </body>
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -651,20 +651,16 @@ AddAnimationsForProperty(nsIFrame* aFram
   // If the frame is not prerendered, bail out.
   // Do this check only during layer construction; during updating the
   // caller is required to check it appropriately.
   if (aItem && !aItem->CanUseAsyncAnimations(aBuilder)) {
     // EffectCompositor needs to know that we refused to run this animation
     // asynchronously so that it will not throttle the main thread
     // animation.
     aFrame->SetProperty(nsIFrame::RefusedAsyncAnimationProperty(), true);
-
-    // We need to schedule another refresh driver run so that EffectCompositor
-    // gets a chance to unthrottle the animation.
-    aFrame->SchedulePaint();
     return;
   }
 
   AnimationData data;
   if (aProperty == eCSSProperty_transform) {
     // XXX Performance here isn't ideal for SVG. We'd prefer to avoid resolving
     // the dimensions of refBox. That said, we only get here if there are CSS
     // animations or transitions on this element, and that is likely to be a