Bug 1471174 - Don't try to send invisible animations that we already throttled on the main thread. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 27 Jun 2018 09:40:52 +0900
changeset 811148 e6fc4b8df4dba8839d041cbd943bbc252d24a335
parent 811147 bdd7029aac5c12d3030b6e6290e74fd3ade9e0fb
child 811149 8fe97c4726750de4a3c855d9376b425533f5dd31
push id114204
push userhikezoe@mozilla.com
push dateWed, 27 Jun 2018 00:44:53 +0000
reviewersbirtles
bugs1471174
milestone63.0a1
Bug 1471174 - Don't try to send invisible animations that we already throttled on the main thread. r?birtles Even if we unthrottled the invisbile animations to update the overflow region, we don't need to send the animations to the compositor since the scroll bar updates caused by the overflow should have been finished before sending animations to the compositor. MozReview-Commit-ID: GtKdPfBSyRB
dom/animation/EffectCompositor.cpp
dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -103,16 +103,23 @@ IsMatchForCompositor(const KeyframeEffec
     // need to be synchronized with the main thread, run them all there.
     return MatchForCompositor::NoAndBlockThisProperty;
   }
 
   if (!aEffect.HasEffectiveAnimationOfProperty(aProperty)) {
     return MatchForCompositor::No;
   }
 
+  // If we know that the animation is not visible, we don't need to send the
+  // animation to the compositor.
+  if (!aFrame->IsVisibleOrMayHaveVisibleDescendants() ||
+      aFrame->IsScrolledOutOfView()) {
+    return MatchForCompositor::NoAndBlockThisProperty;
+  }
+
   return animation->IsPlaying()
          ? MatchForCompositor::Yes
          : MatchForCompositor::IfNeeded;
 }
 
 // Helper function to factor out the common logic from
 // GetAnimationsForCompositor and HasAnimationsForCompositor.
 //
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -130,18 +130,16 @@ function waitForWheelEvent(aTarget) {
                                deltaY: targetRect.height },
                              resolve);
   });
 }
 
 const omtaEnabled = isOMTAEnabled();
 
 const isAndroid = !!navigator.userAgent.includes("Android");
-const isWebRender =
-  SpecialPowers.DOMWindowUtils.layerManagerType == 'WebRender';
 
 function add_task_if_omta_enabled(test) {
   if (!omtaEnabled) {
     info(test.name + " is skipped because OMTA is disabled");
     return;
   }
   add_task(test);
 }
@@ -540,25 +538,17 @@ waitForAllPaints(() => {
   });
 
   add_task_if_omta_enabled(async function no_restyling_compositor_animations_in_visibility_hidden_element() {
     const div = addDiv(null,
      { style: 'animation: opacity 100s; visibility: hidden' });
     const animation = div.getAnimations()[0];
 
     await waitForAnimationReadyToRestyle(animation);
-    if (!isWebRender) {
-      ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
-    } else {
-      // FIXME: Bug 1456389: The animation should be throttled on the
-      // main-thread (i.e. not to be sent to the compositor)
-      todo(!SpecialPowers.wrap(animation).isRunningOnCompositor,
-           'Animation in visibility:hidden element should NOT be running ' +
-           'on the compositor');
-    }
+    ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);
 
     const markers = await observeStyling(5);
 
     is(markers.length, 0,
        'Animations running on the compositor in visibility hidden element ' +
        'should never cause restyles');
     await ensureElementRemoval(div);
   });