Bug 1192910 - Ensure we flush paints on the main thread during an APZ flush. r=mstange a=ritu
☠☠ backed out by e6bd5cd06759 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 07 Mar 2016 16:27:44 -0500
changeset 323559 bf8eb8bd2dbc0537d9b841df0ae2f3c32a702a1e
parent 323558 e59f963b1a1560b76a9af111b7bf1bfe23b092c3
child 323560 7e5731e04d40e2e5be5b51bb5371055bcc071335
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, ritu
bugs1192910
milestone47.0a2
Bug 1192910 - Ensure we flush paints on the main thread during an APZ flush. r=mstange a=ritu MozReview-Commit-ID: 61dyeqxxtVP
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/ChromeProcessController.cpp
gfx/layers/ipc/APZChild.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -887,19 +887,29 @@ APZCCallbackHelper::NotifyMozMouseScroll
 
   nsContentUtils::DispatchTrustedEvent(
     ownerDoc, targetContent,
     aEvent,
     true, true);
 }
 
 void
-APZCCallbackHelper::NotifyFlushComplete()
+APZCCallbackHelper::NotifyFlushComplete(nsIPresShell* aShell)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  // In some cases, flushing the APZ state to the main thread doesn't actually
+  // trigger a flush and repaint (this is an intentional optimization - the stuff
+  // visible to the user is still correct). However, reftests update their
+  // snapshot based on invalidation events that are emitted during paints,
+  // so we ensure that we kick off a paint when an APZ flush is done. Note that
+  // only chrome/testing code can trigger this behaviour.
+  if (aShell && aShell->GetRootFrame()) {
+    aShell->GetRootFrame()->SchedulePaint();
+  }
+
   nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
   MOZ_ASSERT(observerService);
   observerService->NotifyObservers(nullptr, "apz-repaints-flushed", nullptr);
 }
 
 static int32_t sActiveSuppressDisplayport = 0;
 
 void
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -156,17 +156,17 @@ public:
                                                          const WidgetTouchEvent& aEvent,
                                                          uint64_t aInputBlockId,
                                                          const SetAllowedTouchBehaviorCallback& aCallback);
 
     /* Notify content of a mouse scroll testing event. */
     static void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent);
 
     /* Notify content that the repaint flush is complete. */
-    static void NotifyFlushComplete();
+    static void NotifyFlushComplete(nsIPresShell* aShell);
 
     /* Temporarily ignore the Displayport for better paint performance. If at
      * all possible, pass in a presShell if you have one at the call site, we
      * use it to trigger a repaint once suppression is disabled. Without that
      * the displayport may get left at the suppressed size for an extended
      * period of time and result in unnecessary checkerboarding (see bug
      * 1255054). */
     static void SuppressDisplayport(const bool& aEnabled,
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -227,10 +227,10 @@ ChromeProcessController::NotifyMozMouseS
 
   APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
 }
 
 void
 ChromeProcessController::NotifyFlushComplete()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  APZCCallbackHelper::NotifyFlushComplete();
+  APZCCallbackHelper::NotifyFlushComplete(GetPresShell());
 }
--- a/gfx/layers/ipc/APZChild.cpp
+++ b/gfx/layers/ipc/APZChild.cpp
@@ -146,17 +146,21 @@ APZChild::RecvNotifyAPZStateChange(const
                                    const int& aArg)
 {
   return mBrowser->NotifyAPZStateChange(aViewId, aChange, aArg);
 }
 
 bool
 APZChild::RecvNotifyFlushComplete()
 {
-  APZCCallbackHelper::NotifyFlushComplete();
+  nsCOMPtr<nsIPresShell> shell;
+  if (nsCOMPtr<nsIDocument> doc = mBrowser->GetDocument()) {
+    shell = doc->GetShell();
+  }
+  APZCCallbackHelper::NotifyFlushComplete(shell.get());
   return true;
 }
 
 void
 APZChild::SetObserver(nsIObserver* aObserver)
 {
   MOZ_ASSERT(!mBrowser);
   mObserver = aObserver;