Bug 1447870 - Don't flush throttled animations in nsIDOMWindowUtils.updateLayerTree. r?mattwoodrow draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 22 Mar 2018 14:08:29 +0900
changeset 770946 0f7df2de084b590897380f766b7dabd2e6705693
parent 769726 bfb7edfd0436db388bb9e103b8ad817fc50bfdcf
push id103542
push userhikezoe@mozilla.com
push dateThu, 22 Mar 2018 05:08:43 +0000
reviewersmattwoodrow
bugs1447870, 1083635
milestone61.0a1
Bug 1447870 - Don't flush throttled animations in nsIDOMWindowUtils.updateLayerTree. r?mattwoodrow updateLayerTree() is called from the callback of MozAfterPaint in reftest-content.js all the time except when we specify reftest-no-sync-layers or reftest-no-flush. If there is a throttled animation, FlushPendingNotifications flushes the animation, thus it will fire another MozAfterPaint event. It means we will end up waiting for the throttled animation to finish. This reiteration MozAfterPaint events can be easily observed in WebRender since WebRender fires MozAfterPaint event without checking invalidation change. Whereas current Gecko fires MozAfterPaint only if invalidation change happens and reftests for such throttled animations specify the same value for 'from' and 'to' value, so it hasn't been a problem there. The FlushPendingNotifications in updateLayerTree() was introduced in bug 1083635 <https://hg.mozilla.org/mozilla-central/rev/5bebfbefb3c2> to sync-decode images so it shouldn't matter if there are still throttled animations. MozReview-Commit-ID: B9KgNCX0kWq
dom/base/nsDOMWindowUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -377,17 +377,21 @@ nsDOMWindowUtils::Redraw(uint32_t aCount
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::UpdateLayerTree()
 {
   if (nsIPresShell* presShell = GetPresShell()) {
-    presShell->FlushPendingNotifications(FlushType::Display);
+    // Don't flush throttled animations since it might fire MozAfterPaint event
+    // (in WebRender it constantly does), thus the reftest harness can't take
+    // any snapshot until the throttled animations finished.
+    presShell->FlushPendingNotifications(
+      ChangesToFlush(FlushType::Display, false /* flush animations */));
     RefPtr<nsViewManager> vm = presShell->GetViewManager();
     nsView* view = vm->GetRootView();
     if (view) {
       presShell->Paint(view, view->GetBounds(),
           nsIPresShell::PAINT_LAYERS | nsIPresShell::PAINT_SYNC_DECODE_IMAGES);
       presShell->GetLayerManager()->WaitOnTransactionProcessed();
     }
   }