Bug 918288 - Add logging for some of the SetTargetAPZ codepaths. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 21 Nov 2014 21:36:26 -0500
changeset 216991 3595f65c82194b37c3089ad0dd9398ea85455f84
parent 216990 f6fa5d7651214bad337577b1f2e6350f01b6666c
child 216992 ac55dd11daec941a7341ddfc6310ca39e4089cd0
push id27871
push usercbook@mozilla.com
push dateMon, 24 Nov 2014 12:32:57 +0000
treeherdermozilla-central@b8e1741b7d5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs918288
milestone36.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 918288 - Add logging for some of the SetTargetAPZ codepaths. r=botond
dom/ipc/TabChild.cpp
gfx/layers/apz/src/InputBlockState.cpp
gfx/layers/apz/src/InputQueue.cpp
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2443,16 +2443,17 @@ public:
   }
 
   void DidRefresh() MOZ_OVERRIDE {
     if (!mTabChild) {
       MOZ_ASSERT_UNREACHABLE("Post-refresh observer fired again after failed attempt at unregistering it");
       return;
     }
 
+    TABC_LOG("Got refresh, sending target APZCs for input block %" PRIu64 "\n", mInputBlockId);
     mTabChild->SendSetTargetAPZC(mInputBlockId, mTargets);
 
     if (!mPresShell->RemovePostRefreshObserver(this)) {
       MOZ_ASSERT_UNREACHABLE("Unable to unregister post-refresh observer! Leaking it instead of leaving garbage registered");
       // Graceful handling, just in case...
       mTabChild = nullptr;
       mPresShell = nullptr;
       return;
@@ -2489,31 +2490,44 @@ TabChild::SendSetTargetAPZCNotification(
     ScrollableLayerGuid guid(aGuid.mLayersId, 0, FrameMetrics::NULL_SCROLL_ID);
     nsPoint touchPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
       WebWidget(), aEvent.touches[i]->mRefPoint, rootFrame);
     nsIFrame* target = nsLayoutUtils::GetFrameForPoint(rootFrame, touchPoint,
       nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
     nsIScrollableFrame* scrollAncestor = GetScrollableAncestorFrame(target);
     nsCOMPtr<dom::Element> dpElement = GetDisplayportElementFor(scrollAncestor);
 
+    nsAutoString dpElementDesc;
+    if (dpElement) {
+      dpElement->Describe(dpElementDesc);
+    }
+    TABC_LOG("For input block %" PRIu64 " found scrollable element %p (%s)\n",
+        aInputBlockId, dpElement.get(),
+        NS_LossyConvertUTF16toASCII(dpElementDesc).get());
+
     bool guidIsValid = APZCCallbackHelper::GetOrCreateScrollIdentifiers(
       dpElement, &(guid.mPresShellId), &(guid.mScrollId));
     targets.AppendElement(guid);
 
     if (guidIsValid && !nsLayoutUtils::GetDisplayPort(dpElement, nullptr)) {
+      TABC_LOG("%p didn't have a displayport, so setting one...\n", dpElement.get());
       waitForRefresh |= nsLayoutUtils::CalculateAndSetDisplayPortMargins(
         scrollAncestor, nsLayoutUtils::RepaintMode::Repaint);
     }
   }
   if (waitForRefresh) {
+    TABC_LOG("At least one target got a new displayport, need to wait for refresh\n");
     waitForRefresh = shell->AddPostRefreshObserver(
       new DisplayportSetListener(this, shell, aInputBlockId, targets));
   }
   if (!waitForRefresh) {
+    TABC_LOG("Sending target APZCs for input block %" PRIu64 "\n", aInputBlockId);
     SendSetTargetAPZC(aInputBlockId, targets);
+  } else {
+    TABC_LOG("Successfully registered post-refresh observer\n");
   }
 }
 
 bool
 TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
                              const ScrollableLayerGuid& aGuid,
                              const uint64_t& aInputBlockId)
 {
--- a/gfx/layers/apz/src/InputBlockState.cpp
+++ b/gfx/layers/apz/src/InputBlockState.cpp
@@ -32,16 +32,26 @@ InputBlockState::InputBlockState(const n
 bool
 InputBlockState::SetConfirmedTargetApzc(const nsRefPtr<AsyncPanZoomController>& aTargetApzc)
 {
   if (mTargetConfirmed) {
     return false;
   }
   mTargetConfirmed = true;
 
+  if (mTargetApzc == aTargetApzc) {
+    // The confirmed target is the same as the tentative one, so we're done.
+    return true;
+  }
+
+  // Log enabled by default for now, we will put it in a TBS_LOG eventually
+  // once this code is more baked
+  printf_stderr("%p replacing unconfirmed target %p with real target %p\n",
+      this, mTargetApzc.get(), aTargetApzc.get());
+
   // note that aTargetApzc MAY be null here.
   mTargetApzc = aTargetApzc;
   mOverscrollHandoffChain = (mTargetApzc ? mTargetApzc->BuildOverscrollHandoffChain() : nullptr);
   return true;
 }
 
 const nsRefPtr<AsyncPanZoomController>&
 InputBlockState::GetTargetApzc() const
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -222,17 +222,18 @@ InputQueue::ContentReceivedTouch(uint64_
     ProcessPendingInputBlocks();
   }
 }
 
 void
 InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const nsRefPtr<AsyncPanZoomController>& aTargetApzc) {
   AsyncPanZoomController::AssertOnControllerThread();
 
-  INPQ_LOG("got a target apzc; block=%" PRIu64 "\n", aInputBlockId);
+  INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n",
+    aInputBlockId, aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : "");
   bool success = false;
   for (size_t i = 0; i < mTouchBlockQueue.Length(); i++) {
     if (mTouchBlockQueue[i]->GetBlockId() == aInputBlockId) {
       success = mTouchBlockQueue[i]->SetConfirmedTargetApzc(aTargetApzc);
       break;
     }
   }
   if (success) {