Backed out 8 changesets (bug 1445662) for bustage at build/src/gfx/layers/apz/util/ChromeProcessController.cp on a CLOSED TREE
authorCoroiu Cristina <ccoroiu@mozilla.com>
Thu, 15 Mar 2018 20:37:10 +0200
changeset 408403 72a41cf593c7416619b3da744603c65108bf173f
parent 408402 32f45689f03377c8345812106cfcf1b82b322140
child 408404 647154f3033288e3cc3552f86d92eb1ad5f8f742
push id33637
push usertoros@mozilla.com
push dateFri, 16 Mar 2018 09:53:55 +0000
treeherdermozilla-central@d8e8ec54ed9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1445662
milestone61.0a1
backs outd514b05d1f6a60aae21ba4a22c6b7af43fc06d76
13f4f51d7bd1e999af621eeef4587455aed79e05
20c79dee1905275492f557cee4a51aa6d92fbf24
ca1e29c9b4394a47077e2ff5a60ad5307b9ee43b
8fadda7d555ed02b876598b16b2e683211858ba8
b5f2ceda75bd9ea493d660d7d568f518f00b27fc
41d8b7a6b339659290c1807e4fd94d7e2f0bda45
121cd3a0490f2493f669b6c622e559ce683050ef
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
Backed out 8 changesets (bug 1445662) for bustage at build/src/gfx/layers/apz/util/ChromeProcessController.cp on a CLOSED TREE Backed out changeset d514b05d1f6a (bug 1445662) Backed out changeset 13f4f51d7bd1 (bug 1445662) Backed out changeset 20c79dee1905 (bug 1445662) Backed out changeset ca1e29c9b439 (bug 1445662) Backed out changeset 8fadda7d555e (bug 1445662) Backed out changeset b5f2ceda75bd (bug 1445662) Backed out changeset 41d8b7a6b339 (bug 1445662) Backed out changeset 121cd3a0490f (bug 1445662)
gfx/layers/apz/public/IAPZCTreeManager.h
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/src/APZCTreeManager.h
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
gfx/layers/apz/src/Axis.cpp
gfx/layers/apz/src/GestureEventListener.cpp
gfx/layers/apz/src/InputBlockState.cpp
gfx/layers/apz/util/APZThreadUtils.cpp
gfx/layers/apz/util/APZThreadUtils.h
gfx/layers/apz/util/ChromeProcessController.cpp
gfx/layers/ipc/APZCTreeManagerChild.cpp
gfx/layers/ipc/APZCTreeManagerChild.h
gfx/layers/ipc/APZCTreeManagerParent.cpp
gfx/layers/ipc/APZCTreeManagerParent.h
gfx/layers/ipc/PAPZCTreeManager.ipdl
gfx/layers/ipc/RemoteContentController.cpp
gfx/layers/ipc/RemoteContentController.h
widget/nsBaseWidget.cpp
--- a/gfx/layers/apz/public/IAPZCTreeManager.h
+++ b/gfx/layers/apz/public/IAPZCTreeManager.h
@@ -185,16 +185,23 @@ public:
   /**
    * Function used to disable LongTap gestures.
    *
    * On slow running tests, drags and touch events can be misinterpreted
    * as a long tap. This allows tests to disable long tap gesture detection.
    */
   virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0;
 
+  /**
+   * Process touch velocity.
+   * Sometimes the touch move event will have a velocity even though no scrolling
+   * is occurring such as when the toolbar is being hidden/shown in Fennec.
+   * This function can be called to have the y axis' velocity queue updated.
+   */
+  virtual void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) = 0;
 
   // Returns whether or not a wheel event action will be (or was) performed by
   // APZ. If this returns true, the event must not perform a synchronous
   // scroll.
   //
   // Even if this returns false, all wheel events in APZ-aware widgets must
   // be sent through APZ so they are transformed correctly for TabParent.
   static bool WillHandleWheelEvent(WidgetWheelEvent* aEvent);
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -60,16 +60,18 @@ namespace layers {
 using mozilla::gfx::CompositorHitTestInfo;
 
 typedef mozilla::gfx::Point Point;
 typedef mozilla::gfx::Point4D Point4D;
 typedef mozilla::gfx::Matrix4x4 Matrix4x4;
 
 typedef CompositorBridgeParent::LayerTreeState LayerTreeState;
 
+float APZCTreeManager::sDPI = 160.0;
+
 struct APZCTreeManager::TreeBuildingState {
   TreeBuildingState(uint64_t aRootLayersId,
                     bool aIsFirstPaint, uint64_t aOriginatingLayersId,
                     APZTestData* aTestData, uint32_t aPaintSequence)
     : mIsFirstPaint(aIsFirstPaint)
     , mOriginatingLayersId(aOriginatingLayersId)
     , mPaintLogger(aTestData, aPaintSequence)
   {
@@ -223,18 +225,17 @@ private:
 APZCTreeManager::APZCTreeManager(uint64_t aRootLayersId)
     : mInputQueue(new InputQueue()),
       mRootLayersId(aRootLayersId),
       mTreeLock("APZCTreeLock"),
       mHitResultForInputBlock(CompositorHitTestInfo::eInvisibleToHitTest),
       mRetainedTouchIdentifier(-1),
       mInScrollbarTouchDrag(false),
       mApzcTreeLog("apzctree"),
-      mTestDataLock("APZTestDataLock"),
-      mDPI(160.0)
+      mTestDataLock("APZTestDataLock")
 {
   RefPtr<APZCTreeManager> self(this);
   NS_DispatchToMainThread(
     NS_NewRunnableFunction("layers::APZCTreeManager::APZCTreeManager", [self] {
       self->mFlushObserver = new CheckerboardFlushObserver(self);
     }));
   AsyncPanZoomController::InitializeGlobalState();
   mApzcTreeLog.ConditionOnPrefFunction(gfxPrefs::APZPrintTree);
@@ -301,18 +302,16 @@ APZCTreeManager::GetFrameTime()
 {
   return TimeStamp::Now();
 }
 
 void
 APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId,
                                          const nsTArray<TouchBehaviorFlags> &aValues)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   mInputQueue->SetAllowedTouchBehavior(aInputBlockId, aValues);
 }
 
 template<class ScrollNode> void // ScrollNode is a LayerMetricsWrapper or a WebRenderScrollDataWrapper
 APZCTreeManager::UpdateHitTestingTreeImpl(uint64_t aRootLayerTreeId,
                                           const ScrollNode& aRoot,
                                           bool aIsFirstPaint,
                                           uint64_t aOriginatingLayersId,
@@ -728,34 +727,30 @@ GetEventRegionsOverride(HitTestingTreeNo
   }
   return result;
 }
 
 void
 APZCTreeManager::StartScrollbarDrag(const ScrollableLayerGuid& aGuid,
                                     const AsyncDragMetrics& aDragMetrics)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
   if (!apzc) {
     NotifyScrollbarDragRejected(aGuid);
     return;
   }
 
   uint64_t inputBlockId = aDragMetrics.mDragStartSequenceNumber;
   mInputQueue->ConfirmDragBlock(inputBlockId, apzc, aDragMetrics);
 }
 
 bool
 APZCTreeManager::StartAutoscroll(const ScrollableLayerGuid& aGuid,
                                  const ScreenPoint& aAnchorLocation)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
   if (!apzc) {
     if (XRE_IsGPUProcess()) {
       // If we're in the compositor process, the "return false" will be
       // ignored because the query comes over the PAPZCTreeManager protocol
       // via an async message. In this case, send an explicit rejection
       // message to content.
       NotifyAutoscrollRejected(aGuid);
@@ -765,18 +760,16 @@ APZCTreeManager::StartAutoscroll(const S
 
   apzc->StartAutoscroll(aAnchorLocation);
   return true;
 }
 
 void
 APZCTreeManager::StopAutoscroll(const ScrollableLayerGuid& aGuid)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   if (RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid)) {
     apzc->StopAutoscroll();
   }
 }
 
 void
 APZCTreeManager::NotifyScrollbarDragRejected(const ScrollableLayerGuid& aGuid) const
 {
@@ -1067,17 +1060,17 @@ APZCTreeManager::PrepareNodeForLayer(con
   node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId());
   return node;
 }
 
 template<typename PanGestureOrScrollWheelInput>
 static bool
 WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput)
 {
-  if (!XRE_IsParentProcess() || !NS_IsMainThread()) {
+  if (!NS_IsMainThread()) {
     return true;
   }
 
   WidgetWheelEvent wheelEvent = aPanInput.ToWidgetWheelEvent(nullptr);
   return IAPZCTreeManager::WillHandleWheelEvent(&wheelEvent);
 }
 
 void
@@ -1798,18 +1791,16 @@ APZCTreeManager::SetupScrollbarDrag(Mous
                          *thumbData.mDirection));
   }
 }
 
 void
 APZCTreeManager::UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint,
                                         EventMessage aEventMessage)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   WheelBlockState* txn = mInputQueue->GetActiveWheelTransaction();
   if (!txn) {
     return;
   }
 
   // If the transaction has simply timed out, we don't need to do anything
   // else.
   if (txn->MaybeTimeout(TimeStamp::Now())) {
@@ -1845,18 +1836,16 @@ APZCTreeManager::UpdateWheelTransaction(
   }
 }
 
 void
 APZCTreeManager::ProcessUnhandledEvent(LayoutDeviceIntPoint* aRefPoint,
                                         ScrollableLayerGuid*  aOutTargetGuid,
                                         uint64_t*             aOutFocusSequenceNumber)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   // Transform the aRefPoint.
   // If the event hits an overscrolled APZC, instruct the caller to ignore it.
   CompositorHitTestInfo hitResult = CompositorHitTestInfo::eInvisibleToHitTest;
   PixelCastJustification LDIsScreen = PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent;
   ScreenIntPoint refPointAsScreen =
     ViewAs<ScreenPixel>(*aRefPoint, LDIsScreen);
   RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(refPointAsScreen, &hitResult);
   if (apzc) {
@@ -1884,31 +1873,24 @@ APZCTreeManager::ProcessTouchVelocity(ui
   if (mApzcForInputBlock) {
     mApzcForInputBlock->HandleTouchVelocity(aTimestampMs, aSpeedY);
   }
 }
 
 void
 APZCTreeManager::SetKeyboardMap(const KeyboardMap& aKeyboardMap)
 {
-  APZThreadUtils::AssertOnControllerThread();
-
   mKeyboardMap = aKeyboardMap;
 }
 
 void
 APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid,
                             const CSSRect& aRect,
                             const uint32_t aFlags)
 {
-  // We could probably move this to run on the sampler thread if needed, but
-  // either way we should restrict it to a single thread. For now let's use the
-  // controller thread.
-  APZThreadUtils::AssertOnControllerThread();
-
   RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
   if (apzc) {
     apzc->ZoomToRect(aRect, aFlags);
   }
 }
 
 void
 APZCTreeManager::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault)
@@ -1943,34 +1925,16 @@ APZCTreeManager::SetTargetAPZC(uint64_t 
   RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aTarget);
   mInputQueue->SetConfirmedTargetApzc(aInputBlockId, apzc);
 }
 
 void
 APZCTreeManager::UpdateZoomConstraints(const ScrollableLayerGuid& aGuid,
                                        const Maybe<ZoomConstraints>& aConstraints)
 {
-  if (!APZThreadUtils::IsSamplerThread()) {
-    // This can happen if we're in the UI process and got a call directly from
-    // nsBaseWidget (as opposed to over PAPZCTreeManager). We want this function
-    // to run on the sampler thread, so bounce it over.
-    MOZ_ASSERT(XRE_IsParentProcess());
-
-    APZThreadUtils::RunOnSamplerThread(
-        NewRunnableMethod<ScrollableLayerGuid, Maybe<ZoomConstraints>>(
-            "APZCTreeManager::UpdateZoomConstraints",
-            this,
-            &APZCTreeManager::UpdateZoomConstraints,
-            aGuid,
-            aConstraints));
-    return;
-  }
-
-  APZThreadUtils::AssertOnSamplerThread();
-
   RecursiveMutexAutoLock lock(mTreeLock);
   RefPtr<HitTestingTreeNode> node = GetTargetNode(aGuid, nullptr);
   MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC
 
   // Propagate the zoom constraints down to the subtree, stopping at APZCs
   // which have their own zoom constraints or are in a different layers id.
   if (aConstraints) {
     APZCTM_LOG("Recording constraints %s for guid %s\n",
@@ -3182,30 +3146,16 @@ APZCTreeManager::ComputeTransformForScro
       *aOutClipTransform = asyncCompensation;
     }
   }
   transform = transform * compensation;
 
   return transform;
 }
 
-void
-APZCTreeManager::SetDPI(float aDpiValue)
-{
-  APZThreadUtils::AssertOnControllerThread();
-  mDPI = aDpiValue;
-}
-
-float
-APZCTreeManager::GetDPI() const
-{
-  APZThreadUtils::AssertOnControllerThread();
-  return mDPI;
-}
-
 #if defined(MOZ_WIDGET_ANDROID)
 AndroidDynamicToolbarAnimator*
 APZCTreeManager::GetAndroidDynamicToolbarAnimator()
 {
   return mToolbarAnimator;
 }
 #endif // defined(MOZ_WIDGET_ANDROID)
 
--- a/gfx/layers/apz/src/APZCTreeManager.h
+++ b/gfx/layers/apz/src/APZCTreeManager.h
@@ -335,26 +335,25 @@ public:
   void ClearTree();
 
   /**
    * Tests if a screen point intersect an apz in the tree.
    */
   bool HitTestAPZC(const ScreenIntPoint& aPoint);
 
   /**
-   * Sets the dpi value used by all AsyncPanZoomControllers attached to this
-   * tree manager.
-   * DPI defaults to 160 if not set using SetDPI() at any point.
+   * Sets the dpi value used by all AsyncPanZoomControllers.
+   * DPI defaults to 72 if not set using SetDPI() at any point.
    */
-  void SetDPI(float aDpiValue) override;
+  void SetDPI(float aDpiValue) override { sDPI = aDpiValue; }
 
   /**
    * Returns the current dpi value in use.
    */
-  float GetDPI() const;
+  static float GetDPI() { return sDPI; }
 
   /**
    * Find the hit testing node for the scrollbar thumb that matches these
    * drag metrics.
    */
   RefPtr<HitTestingTreeNode> FindScrollThumbNode(const AsyncDragMetrics& aDragMetrics);
 
   /**
@@ -547,17 +546,17 @@ public:
   ScreenPoint GetCurrentMousePosition() const;
 
   /**
    * Process touch velocity.
    * Sometimes the touch move event will have a velocity even though no scrolling
    * is occurring such as when the toolbar is being hidden/shown in Fennec.
    * This function can be called to have the y axis' velocity queue updated.
    */
-  void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY);
+  void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) override;
 private:
   typedef bool (*GuidComparator)(const ScrollableLayerGuid&, const ScrollableLayerGuid&);
 
   /* Helpers */
   template<class ScrollNode>
   void UpdateHitTestingTreeImpl(uint64_t aRootLayerTreeId,
                                 const ScrollNode& aRoot,
                                 bool aIsFirstPaint,
@@ -686,27 +685,25 @@ private:
   /* Layers id for the root CompositorBridgeParent that owns this APZCTreeManager. */
   uint64_t mRootLayersId;
 
   /* Whenever walking or mutating the tree rooted at mRootNode, mTreeLock must be held.
    * This lock does not need to be held while manipulating a single APZC instance in
    * isolation (that is, if its tree pointers are not being accessed or mutated). The
    * lock also needs to be held when accessing the mRootNode instance variable, as that
    * is considered part of the APZC tree management state.
+   * Finally, the lock needs to be held when accessing mZoomConstraints.
    * IMPORTANT: See the note about lock ordering at the top of this file. */
   mutable mozilla::RecursiveMutex mTreeLock;
   RefPtr<HitTestingTreeNode> mRootNode;
-
   /* Holds the zoom constraints for scrollable layers, as determined by the
-   * the main-thread gecko code. This can only be accessed on the sampler
-   * thread. */
+   * the main-thread gecko code. */
   std::unordered_map<ScrollableLayerGuid, ZoomConstraints, ScrollableLayerGuidHash> mZoomConstraints;
   /* A list of keyboard shortcuts to use for translating keyboard inputs into
    * keyboard actions. This is gathered on the main thread from XBL bindings.
-   * This must only be accessed on the controller thread.
    */
   KeyboardMap mKeyboardMap;
   /* This tracks the focus targets of chrome and content and whether we have
    * a current focus target or whether we are waiting for a new confirmation.
    */
   FocusState mFocusState;
   /* This tracks the APZC that should receive all inputs for the current input event block.
    * This allows touch points to move outside the thing they started on, but still have the
@@ -744,18 +741,17 @@ private:
   friend class CheckerboardFlushObserver;
   RefPtr<CheckerboardFlushObserver> mFlushObserver;
 
   // Map from layers id to APZTestData. Accesses and mutations must be
   // protected by the mTestDataLock.
   std::unordered_map<uint64_t, UniquePtr<APZTestData>> mTestData;
   mutable mozilla::Mutex mTestDataLock;
 
-  // This must only be touched on the controller thread.
-  float mDPI;
+  static float sDPI;
 
 #if defined(MOZ_WIDGET_ANDROID)
 public:
   AndroidDynamicToolbarAnimator* GetAndroidDynamicToolbarAnimator();
 
 private:
   RefPtr<AndroidDynamicToolbarAnimator> mToolbarAnimator;
 #endif // defined(MOZ_WIDGET_ANDROID)
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -863,44 +863,26 @@ AsyncPanZoomController::Destroy()
 }
 
 bool
 AsyncPanZoomController::IsDestroyed() const
 {
   return mTreeManager == nullptr;
 }
 
-float
-AsyncPanZoomController::GetDPI() const
+/* static */ScreenCoord
+AsyncPanZoomController::GetTouchStartTolerance()
 {
-  if (APZCTreeManager* localPtr = mTreeManager) {
-    return localPtr->GetDPI();
-  }
-  // If this APZC has been destroyed then this value is not going to be
-  // used for anything that the user will end up seeing, so we can just
-  // return 0.
-  return 0.0;
+  return (gfxPrefs::APZTouchStartTolerance() * APZCTreeManager::GetDPI());
 }
 
-ScreenCoord
-AsyncPanZoomController::GetTouchStartTolerance() const
+/* static */ScreenCoord
+AsyncPanZoomController::GetSecondTapTolerance()
 {
-  return (gfxPrefs::APZTouchStartTolerance() * GetDPI());
-}
-
-ScreenCoord
-AsyncPanZoomController::GetTouchMoveTolerance() const
-{
-  return (gfxPrefs::APZTouchMoveTolerance() * GetDPI());
-}
-
-ScreenCoord
-AsyncPanZoomController::GetSecondTapTolerance() const
-{
-  return (gfxPrefs::APZSecondTapTolerance() * GetDPI());
+  return (gfxPrefs::APZSecondTapTolerance() * APZCTreeManager::GetDPI());
 }
 
 /* static */AsyncPanZoomController::AxisLockMode AsyncPanZoomController::GetAxisLockMode()
 {
   return static_cast<AxisLockMode>(gfxPrefs::APZAxisLockMode());
 }
 
 /* static */AsyncPanZoomController::PinchLockMode AsyncPanZoomController::GetPinchLockMode()
@@ -2659,17 +2641,17 @@ void AsyncPanZoomController::HandlePanni
 
 void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance) {
   // If we're axis-locked, check if the user is trying to break the lock
   if (GetAxisLockMode() == STICKY && !mPanDirRestricted) {
 
     double angle = atan2(aPanDistance.y, aPanDistance.x); // range [-pi, pi]
     angle = fabs(angle); // range [0, pi]
 
-    float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * GetDPI();
+    float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * APZCTreeManager::GetDPI();
 
     if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) {
       if (mState == PANNING_LOCKED_X) {
         if (!IsCloseToHorizontal(angle, gfxPrefs::APZAxisBreakoutAngle())) {
           mY.SetAxisLocked(false);
           SetState(PANNING);
         }
       } else if (mState == PANNING_LOCKED_Y) {
@@ -2680,23 +2662,23 @@ void AsyncPanZoomController::HandlePanni
       }
     }
   }
 }
 
 void AsyncPanZoomController::HandlePinchLocking(ScreenCoord spanDistance, ScreenPoint focusChange) {
   if (mPinchLocked) {
     if (GetPinchLockMode() == PINCH_STICKY) {
-      ScreenCoord spanBreakoutThreshold = gfxPrefs::APZPinchLockSpanBreakoutThreshold() * GetDPI();
+      ScreenCoord spanBreakoutThreshold = gfxPrefs::APZPinchLockSpanBreakoutThreshold() * APZCTreeManager::GetDPI();
       mPinchLocked = !(spanDistance > spanBreakoutThreshold);
     }
   } else {
     if (GetPinchLockMode() != PINCH_FREE) {
-      ScreenCoord spanLockThreshold = gfxPrefs::APZPinchLockSpanLockThreshold() * GetDPI();
-      ScreenCoord scrollLockThreshold = gfxPrefs::APZPinchLockScrollLockThreshold() * GetDPI();
+      ScreenCoord spanLockThreshold = gfxPrefs::APZPinchLockSpanLockThreshold() * APZCTreeManager::GetDPI();
+      ScreenCoord scrollLockThreshold = gfxPrefs::APZPinchLockScrollLockThreshold() * APZCTreeManager::GetDPI();
 
       if (spanDistance < spanLockThreshold && focusChange.Length() > scrollLockThreshold) {
         mPinchLocked = true;
       }
     }
   }
 }
 
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -148,41 +148,30 @@ public:
     // will not attempt to generate gesture events from MultiTouchInputs.
     DEFAULT_GESTURES,
     // An instance of GestureEventListener is used to detect gestures. This is
     // handled completely internally within this class.
     USE_GESTURE_DETECTOR
   };
 
   /**
-   * Gets the DPI from the tree manager.
-   */
-  float GetDPI() const;
-
-  /**
    * Constant describing the tolerance in distance we use, multiplied by the
    * device DPI, before we start panning the screen. This is to prevent us from
    * accidentally processing taps as touch moves, and from very short/accidental
    * touches moving the screen.
    * Note: It's an abuse of the 'Coord' class to use it to represent a 2D
    *       distance, but it's the closest thing we currently have.
    */
-  ScreenCoord GetTouchStartTolerance() const;
-  /**
-   * Same as GetTouchStartTolerance, but the tolerance for how far the touch
-   * has to move before it starts allowing touchmove events to be dispatched
-   * to content, for non-scrollable content.
-   */
-  ScreenCoord GetTouchMoveTolerance() const;
+  static ScreenCoord GetTouchStartTolerance();
   /**
    * Same as GetTouchStartTolerance, but the tolerance for how close the second
    * tap has to be to the first tap in order to be counted as part of a multi-tap
    * gesture (double-tap or one-touch-pinch).
    */
-  ScreenCoord GetSecondTapTolerance() const;
+  static ScreenCoord GetSecondTapTolerance();
 
   AsyncPanZoomController(uint64_t aLayersId,
                          APZCTreeManager* aTreeManager,
                          const RefPtr<InputQueue>& aInputQueue,
                          GeckoContentController* aController,
                          GestureBehavior aGestures = DEFAULT_GESTURES);
 
   // --------------------------------------------------------------------------
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -55,17 +55,17 @@ Axis::Axis(AsyncPanZoomController* aAsyn
     mAxisLocked(false),
     mAsyncPanZoomController(aAsyncPanZoomController),
     mOverscroll(0),
     mMSDModel(0.0, 0.0, 0.0, 400.0, 1.2)
 {
 }
 
 float Axis::ToLocalVelocity(float aVelocityInchesPerMs) const {
-  ScreenPoint velocity = MakePoint(aVelocityInchesPerMs * mAsyncPanZoomController->GetDPI());
+  ScreenPoint velocity = MakePoint(aVelocityInchesPerMs * APZCTreeManager::GetDPI());
   // Use ToScreenCoordinates() to convert a point rather than a vector by
   // treating the point as a vector, and using (0, 0) as the anchor.
   ScreenPoint panStart = mAsyncPanZoomController->ToScreenCoordinates(
       mAsyncPanZoomController->PanStart(),
       ParentLayerPoint());
   ParentLayerPoint localVelocity =
       mAsyncPanZoomController->ToParentLayerCoordinates(velocity, panStart);
   return localVelocity.Length();
--- a/gfx/layers/apz/src/GestureEventListener.cpp
+++ b/gfx/layers/apz/src/GestureEventListener.cpp
@@ -258,25 +258,25 @@ bool GestureEventListener::MoveDistanceE
   const ParentLayerPoint start = mLastTouchInput.mTouches[0].mLocalScreenPoint;
   ParentLayerPoint delta = start - mTouchStartPosition;
   ScreenPoint screenDelta = mAsyncPanZoomController->ToScreenCoordinates(delta, start);
   return (screenDelta.Length() > aThreshold);
 }
 
 bool GestureEventListener::MoveDistanceIsLarge() const
 {
-  return MoveDistanceExceeds(mAsyncPanZoomController->GetTouchStartTolerance());
+  return MoveDistanceExceeds(AsyncPanZoomController::GetTouchStartTolerance());
 }
 
 bool GestureEventListener::SecondTapIsFar() const
 {
   // Allow a little more room here, because the is actually lifting their finger
   // off the screen before replacing it, and that tends to have more error than
   // wiggling the finger while on the screen.
-  return MoveDistanceExceeds(mAsyncPanZoomController->GetSecondTapTolerance());
+  return MoveDistanceExceeds(AsyncPanZoomController::GetSecondTapTolerance());
 }
 
 nsEventStatus GestureEventListener::HandleInputTouchMove()
 {
   nsEventStatus rv = nsEventStatus_eIgnore;
 
   switch (mState) {
   case GESTURE_NONE:
--- a/gfx/layers/apz/src/InputBlockState.cpp
+++ b/gfx/layers/apz/src/InputBlockState.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "InputBlockState.h"
 
+#include "APZCTreeManager.h"                // for APZCTreeManager::GetDPI
 #include "AsyncPanZoomController.h"         // for AsyncPanZoomController
 #include "ScrollAnimationPhysics.h"         // for kScrollSeriesTimeoutMs
 #include "gfxPrefs.h"                       // for gfxPrefs
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Telemetry.h"              // for Telemetry
 #include "mozilla/layers/IAPZCTreeManager.h" // for AllowedTouchBehavior
 #include "OverscrollHandoffState.h"
 #include "QueuedInput.h"
@@ -884,23 +885,19 @@ TouchBlockState::UpdateSlopState(const M
     mInSlop = (aInput.mTouches.Length() == 1);
     if (mInSlop) {
       mSlopOrigin = aInput.mTouches[0].mScreenPoint;
       TBS_LOG("%p entering slop with origin %s\n", this, Stringify(mSlopOrigin).c_str());
     }
     return false;
   }
   if (mInSlop) {
-    ScreenCoord threshold = 0;
-    // If the target was confirmed to null then the threshold doesn't
-    // matter anyway since the events will never be processed.
-    if (const RefPtr<AsyncPanZoomController>& apzc = GetTargetApzc()) {
-      threshold = aApzcCanConsumeEvents ? apzc->GetTouchStartTolerance()
-                                        : apzc->GetTouchMoveTolerance();
-    }
+    ScreenCoord threshold = aApzcCanConsumeEvents
+        ? AsyncPanZoomController::GetTouchStartTolerance()
+        : ScreenCoord(gfxPrefs::APZTouchMoveTolerance() * APZCTreeManager::GetDPI());
     bool stayInSlop = (aInput.mType == MultiTouchInput::MULTITOUCH_MOVE) &&
         (aInput.mTouches.Length() == 1) &&
         ((aInput.mTouches[0].mScreenPoint - mSlopOrigin).Length() < threshold);
     if (!stayInSlop) {
       // we're out of the slop zone, and will stay out for the remainder of
       // this block
       TBS_LOG("%p exiting slop\n", this);
       mInSlop = false;
--- a/gfx/layers/apz/util/APZThreadUtils.cpp
+++ b/gfx/layers/apz/util/APZThreadUtils.cpp
@@ -38,16 +38,24 @@ APZThreadUtils::AssertOnControllerThread
   if (!GetThreadAssertionsEnabled()) {
     return;
   }
 
   MOZ_ASSERT(sControllerThread == MessageLoop::current());
 }
 
 /*static*/ void
+APZThreadUtils::AssertOnSamplerThread()
+{
+  if (GetThreadAssertionsEnabled()) {
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
+  }
+}
+
+/*static*/ void
 APZThreadUtils::RunOnControllerThread(already_AddRefed<Runnable> aTask)
 {
   RefPtr<Runnable> task = aTask;
 
   if (!sControllerThread) {
     // Could happen on startup
     NS_WARNING("Dropping task posted to controller thread");
     return;
@@ -61,45 +69,12 @@ APZThreadUtils::RunOnControllerThread(al
 }
 
 /*static*/ bool
 APZThreadUtils::IsControllerThread()
 {
   return sControllerThread == MessageLoop::current();
 }
 
-/*static*/ void
-APZThreadUtils::AssertOnSamplerThread()
-{
-  if (GetThreadAssertionsEnabled()) {
-    MOZ_ASSERT(IsSamplerThread());
-  }
-}
-
-/*static*/ void
-APZThreadUtils::RunOnSamplerThread(already_AddRefed<Runnable> aTask)
-{
-  RefPtr<Runnable> task = aTask;
-
-  MessageLoop* loop = CompositorThreadHolder::Loop();
-  if (!loop) {
-    // Could happen during startup
-    NS_WARNING("Dropping task posted to sampler thread");
-    return;
-  }
-
-  if (IsSamplerThread()) {
-    task->Run();
-  } else {
-    loop->PostTask(task.forget());
-  }
-}
-
-/*static*/ bool
-APZThreadUtils::IsSamplerThread()
-{
-  return CompositorThreadHolder::IsInCompositorThread();
-}
-
 NS_IMPL_ISUPPORTS(GenericNamedTimerCallbackBase, nsITimerCallback, nsINamed)
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/apz/util/APZThreadUtils.h
+++ b/gfx/layers/apz/util/APZThreadUtils.h
@@ -36,45 +36,33 @@ public:
   /**
    * This can be used to assert that the current thread is the
    * controller/UI thread (on which input events are received).
    * This does nothing if thread assertions are disabled.
    */
   static void AssertOnControllerThread();
 
   /**
+   * This can be used to assert that the current thread is the
+   * sampler thread (which samples the async transform).
+   * This does nothing if thread assertions are disabled.
+   */
+  static void AssertOnSamplerThread();
+
+  /**
    * Run the given task on the APZ "controller thread" for this platform. If
    * this function is called from the controller thread itself then the task is
    * run immediately without getting queued.
    */
   static void RunOnControllerThread(already_AddRefed<Runnable> aTask);
 
   /**
    * Returns true if currently on APZ "controller thread".
    */
   static bool IsControllerThread();
-
-  /**
-   * This can be used to assert that the current thread is the
-   * sampler thread (which samples the async transform).
-   * This does nothing if thread assertions are disabled.
-   */
-  static void AssertOnSamplerThread();
-
-  /**
-   * Runs the given task on the APZ "sampler thread" for this platform. If
-   * this function is called from the sampler thread itself then the task is
-   * run immediately without getting queued.
-   */
-  static void RunOnSamplerThread(already_AddRefed<Runnable> aTask);
-
-  /**
-   * Returns true if currently on the APZ "sampler thread".
-   */
-  static bool IsSamplerThread();
 };
 
 // A base class for GenericNamedTimerCallback<Function>.
 // This is necessary because NS_IMPL_ISUPPORTS doesn't work for a class
 // template.
 class GenericNamedTimerCallbackBase : public nsITimerCallback,
                                       public nsINamed
 {
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -153,24 +153,18 @@ ChromeProcessController::HandleDoubleTap
   const float resolution = presShell->ScaleToResolution() ? presShell->GetResolution () : 1.0f;
   CSSPoint point(aPoint.x / resolution, aPoint.y / resolution);
   CSSRect zoomToRect = CalculateRectToZoomTo(document, point);
 
   uint32_t presShellId;
   FrameMetrics::ViewID viewId;
   if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
       document->GetDocumentElement(), &presShellId, &viewId)) {
-    APZThreadUtils::RunOnControllerThread(
-      NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
-        "IAPZCTreeManager::ZoomToRect",
-        mAPZCTreeManager,
-        &IAPZCTreeManager::ZoomToRect,
-        ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId),
-        zoomToRect,
-        ZoomToRectBehavior::DEFAULT_BEHAVIOR));
+    mAPZCTreeManager->ZoomToRect(
+      ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId), zoomToRect);
   }
 }
 
 void
 ChromeProcessController::HandleTap(TapType aType,
                                    const mozilla::LayoutDevicePoint& aPoint,
                                    Modifiers aModifiers,
                                    const ScrollableLayerGuid& aGuid,
--- a/gfx/layers/ipc/APZCTreeManagerChild.cpp
+++ b/gfx/layers/ipc/APZCTreeManagerChild.cpp
@@ -217,16 +217,22 @@ APZCTreeManagerChild::StopAutoscroll(con
 
 void
 APZCTreeManagerChild::SetLongTapEnabled(bool aTapGestureEnabled)
 {
   SendSetLongTapEnabled(aTapGestureEnabled);
 }
 
 void
+APZCTreeManagerChild::ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY)
+{
+  SendProcessTouchVelocity(aTimestampMs, aSpeedY);
+}
+
+void
 APZCTreeManagerChild::UpdateWheelTransaction(
     LayoutDeviceIntPoint aRefPoint,
     EventMessage aEventMessage)
 {
   SendUpdateWheelTransaction(aRefPoint, aEventMessage);
 }
 
 void APZCTreeManagerChild::ProcessUnhandledEvent(
--- a/gfx/layers/ipc/APZCTreeManagerChild.h
+++ b/gfx/layers/ipc/APZCTreeManagerChild.h
@@ -74,16 +74,19 @@ public:
 
   void
   StopAutoscroll(const ScrollableLayerGuid& aGuid) override;
 
   void
   SetLongTapEnabled(bool aTapGestureEnabled) override;
 
   void
+  ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) override;
+
+  void
   ProcessUnhandledEvent(
           LayoutDeviceIntPoint* aRefPoint,
           ScrollableLayerGuid*  aOutTargetGuid,
           uint64_t*             aOutFocusSequenceNumber) override;
 
   void
   UpdateWheelTransaction(
           LayoutDeviceIntPoint aRefPoint,
--- a/gfx/layers/ipc/APZCTreeManagerParent.cpp
+++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp
@@ -161,43 +161,34 @@ APZCTreeManagerParent::RecvReceiveKeyboa
   *aOutEvent = event;
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvSetKeyboardMap(const KeyboardMap& aKeyboardMap)
 {
-  APZThreadUtils::RunOnControllerThread(NewRunnableMethod<KeyboardMap>(
-    "layers::IAPZCTreeManager::SetKeyboardMap",
-    mTreeManager,
-    &IAPZCTreeManager::SetKeyboardMap,
-    aKeyboardMap));
+  mTreeManager->SetKeyboardMap(aKeyboardMap);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvZoomToRect(
     const ScrollableLayerGuid& aGuid,
     const CSSRect& aRect,
     const uint32_t& aFlags)
 {
   if (aGuid.mLayersId != mLayersId) {
     // Guard against bad data from hijacked child processes
     NS_ERROR("Unexpected layers id in RecvZoomToRect; dropping message...");
     return IPC_FAIL_NO_REASON(this);
   }
 
-  APZThreadUtils::RunOnControllerThread(
-    NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
-      "layers::IAPZCTreeManager::ZoomToRect",
-      mTreeManager,
-      &IAPZCTreeManager::ZoomToRect,
-      aGuid, aRect, aFlags));
+  mTreeManager->ZoomToRect(aGuid, aRect, aFlags);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvContentReceivedInputBlock(
     const uint64_t& aInputBlockId,
     const bool& aPreventDefault)
 {
@@ -248,21 +239,17 @@ APZCTreeManagerParent::RecvUpdateZoomCon
 
   mTreeManager->UpdateZoomConstraints(aGuid, aConstraints);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvSetDPI(const float& aDpiValue)
 {
-  APZThreadUtils::RunOnControllerThread(NewRunnableMethod<float>(
-    "layers::IAPZCTreeManager::SetDPI",
-    mTreeManager,
-    &IAPZCTreeManager::SetDPI,
-    aDpiValue));
+  mTreeManager->SetDPI(aDpiValue);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvSetAllowedTouchBehavior(
     const uint64_t& aInputBlockId,
     nsTArray<TouchBehaviorFlags>&& aValues)
 {
@@ -340,16 +327,25 @@ APZCTreeManagerParent::RecvStopAutoscrol
 mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvSetLongTapEnabled(const bool& aTapGestureEnabled)
 {
   mTreeManager->SetLongTapEnabled(aTapGestureEnabled);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
+APZCTreeManagerParent::RecvProcessTouchVelocity(
+  const uint32_t& aTimestampMs,
+  const float& aSpeedY)
+{
+  mTreeManager->ProcessTouchVelocity(aTimestampMs, aSpeedY);
+  return IPC_OK();
+}
+
+mozilla::ipc::IPCResult
 APZCTreeManagerParent::RecvUpdateWheelTransaction(
         const LayoutDeviceIntPoint& aRefPoint,
         const EventMessage& aEventMessage)
 {
   mTreeManager->UpdateWheelTransaction(aRefPoint, aEventMessage);
   return IPC_OK();
 }
 
--- a/gfx/layers/ipc/APZCTreeManagerParent.h
+++ b/gfx/layers/ipc/APZCTreeManagerParent.h
@@ -130,16 +130,21 @@ public:
 
   mozilla::ipc::IPCResult
   RecvStopAutoscroll(const ScrollableLayerGuid& aGuid) override;
 
   mozilla::ipc::IPCResult
   RecvSetLongTapEnabled(const bool& aTapGestureEnabled) override;
 
   mozilla::ipc::IPCResult
+  RecvProcessTouchVelocity(
+          const uint32_t& aTimestampMs,
+          const float& aSpeedY) override;
+
+  mozilla::ipc::IPCResult
   RecvUpdateWheelTransaction(
           const LayoutDeviceIntPoint& aRefPoint,
           const EventMessage& aEventMessage) override;
 
   mozilla::ipc::IPCResult
   RecvProcessUnhandledEvent(
           const LayoutDeviceIntPoint& aRefPoint,
           LayoutDeviceIntPoint* aOutRefPoint,
--- a/gfx/layers/ipc/PAPZCTreeManager.ipdl
+++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl
@@ -80,16 +80,18 @@ parent:
   async StartScrollbarDrag(ScrollableLayerGuid aGuid, AsyncDragMetrics aDragMetrics);
 
   async StartAutoscroll(ScrollableLayerGuid aGuid, ScreenPoint aAnchorLocation);
 
   async StopAutoscroll(ScrollableLayerGuid aGuid);
 
   async SetLongTapEnabled(bool aTapGestureEnabled);
 
+  async ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY);
+
   // The following messages are used to
   // implement the ReceiveInputEvent methods
 
   sync ReceiveMultiTouchInputEvent(MultiTouchInput aEvent)
     returns (nsEventStatus       aOutStatus,
              MultiTouchInput     aOutEvent,
              ScrollableLayerGuid aOutTargetGuid,
              uint64_t            aOutInputBlockId);
--- a/gfx/layers/ipc/RemoteContentController.cpp
+++ b/gfx/layers/ipc/RemoteContentController.cpp
@@ -55,62 +55,35 @@ RemoteContentController::HandleTapOnMain
 
   dom::TabParent* tab = dom::TabParent::GetTabParentFromLayersId(aGuid.mLayersId);
   if (tab) {
     tab->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
   }
 }
 
 void
-RemoteContentController::HandleTapOnCompositorThread(TapType aTapType,
-                                                     LayoutDevicePoint aPoint,
-                                                     Modifiers aModifiers,
-                                                     ScrollableLayerGuid aGuid,
-                                                     uint64_t aInputBlockId)
-{
-  MOZ_ASSERT(XRE_IsGPUProcess());
-  MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
-
-  // The raw pointer to APZCTreeManagerParent is ok here because we are on the
-  // compositor thread.
-  APZCTreeManagerParent* apzctmp =
-      CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
-  if (apzctmp) {
-    Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
-  }
-}
-
-void
 RemoteContentController::HandleTap(TapType aTapType,
                                    const LayoutDevicePoint& aPoint,
                                    Modifiers aModifiers,
                                    const ScrollableLayerGuid& aGuid,
                                    uint64_t aInputBlockId)
 {
   APZThreadUtils::AssertOnControllerThread();
 
   if (XRE_GetProcessType() == GeckoProcessType_GPU) {
-    if (MessageLoop::current() == mCompositorThread) {
-      HandleTapOnCompositorThread(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
-    } else {
-      // We have to send messages from the compositor thread
-      mCompositorThread->PostTask(NewRunnableMethod<TapType,
-                                                    LayoutDevicePoint,
-                                                    Modifiers,
-                                                    ScrollableLayerGuid,
-                                                    uint64_t>(
-        "layers::RemoteContentController::HandleTapOnCompositorThread",
-        this,
-        &RemoteContentController::HandleTapOnCompositorThread,
-        aTapType,
-        aPoint,
-        aModifiers,
-        aGuid,
-        aInputBlockId));
+    MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
+
+    // The raw pointer to APZCTreeManagerParent is ok here because we are on the
+    // compositor thread.
+    APZCTreeManagerParent* apzctmp =
+        CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
+    if (apzctmp) {
+      Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
     }
+
     return;
   }
 
   MOZ_ASSERT(XRE_IsParentProcess());
 
   if (NS_IsMainThread()) {
     HandleTapOnMainThread(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
   } else {
@@ -128,63 +101,39 @@ RemoteContentController::HandleTap(TapTy
       aPoint,
       aModifiers,
       aGuid,
       aInputBlockId));
   }
 }
 
 void
-RemoteContentController::NotifyPinchGestureOnCompositorThread(
-    PinchGestureInput::PinchGestureType aType,
-    const ScrollableLayerGuid& aGuid,
-    LayoutDeviceCoord aSpanChange,
-    Modifiers aModifiers)
-{
-  MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
-
-  // The raw pointer to APZCTreeManagerParent is ok here because we are on the
-  // compositor thread.
-  APZCTreeManagerParent* apzctmp =
-      CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
-  if (apzctmp) {
-    Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
-  }
-}
-
-void
 RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
                                             const ScrollableLayerGuid& aGuid,
                                             LayoutDeviceCoord aSpanChange,
                                             Modifiers aModifiers)
 {
   APZThreadUtils::AssertOnControllerThread();
 
   // For now we only ever want to handle this NotifyPinchGesture message in
   // the parent process, even if the APZ is sending it to a content process.
 
   // If we're in the GPU process, try to find a handle to the parent process
   // and send it there.
   if (XRE_IsGPUProcess()) {
-    if (MessageLoop::current() == mCompositorThread) {
-      NotifyPinchGestureOnCompositorThread(aType, aGuid, aSpanChange, aModifiers);
-    } else {
-      mCompositorThread->PostTask(NewRunnableMethod<PinchGestureInput::PinchGestureType,
-                                                    ScrollableLayerGuid,
-                                                    LayoutDeviceCoord,
-                                                    Modifiers>(
-        "layers::RemoteContentController::NotifyPinchGestureOnCompositorThread",
-        this,
-        &RemoteContentController::NotifyPinchGestureOnCompositorThread,
-        aType,
-        aGuid,
-        aSpanChange,
-        aModifiers));
+    MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
+
+    // The raw pointer to APZCTreeManagerParent is ok here because we are on the
+    // compositor thread.
+    APZCTreeManagerParent* apzctmp =
+        CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
+    if (apzctmp) {
+      Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
+      return;
     }
-    return;
   }
 
   // If we're in the parent process, handle it directly. We don't have a handle
   // to the widget though, so we fish out the ChromeProcessController and
   // delegate to that instead.
   if (XRE_IsParentProcess()) {
     MOZ_ASSERT(NS_IsMainThread());
     RefPtr<GeckoContentController> rootController =
--- a/gfx/layers/ipc/RemoteContentController.h
+++ b/gfx/layers/ipc/RemoteContentController.h
@@ -85,25 +85,16 @@ private:
   MessageLoop* mCompositorThread;
   bool mCanSend;
 
   void HandleTapOnMainThread(TapType aType,
                              LayoutDevicePoint aPoint,
                              Modifiers aModifiers,
                              ScrollableLayerGuid aGuid,
                              uint64_t aInputBlockId);
-  void HandleTapOnCompositorThread(TapType aType,
-                                   LayoutDevicePoint aPoint,
-                                   Modifiers aModifiers,
-                                   ScrollableLayerGuid aGuid,
-                                   uint64_t aInputBlockId);
-  void NotifyPinchGestureOnCompositorThread(PinchGestureInput::PinchGestureType aType,
-                                            const ScrollableLayerGuid& aGuid,
-                                            LayoutDeviceCoord aSpanChange,
-                                            Modifiers aModifiers);
 
   void CancelAutoscrollInProcess(const ScrollableLayerGuid& aScrollId);
   void CancelAutoscrollCrossProcess(const ScrollableLayerGuid& aScrollId);
 };
 
 } // namespace layers
 
 } // namespace mozilla
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -928,37 +928,24 @@ already_AddRefed<GeckoContentController>
 nsBaseWidget::CreateRootContentController()
 {
   RefPtr<GeckoContentController> controller = new ChromeProcessController(this, mAPZEventState, mAPZC);
   return controller.forget();
 }
 
 void nsBaseWidget::ConfigureAPZCTreeManager()
 {
-  MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mAPZC);
 
   ConfigureAPZControllerThread();
 
-  float dpi = GetDPI();
-  // On Android the main thread is not the controller thread
-  APZThreadUtils::RunOnControllerThread(NewRunnableMethod<float>(
-      "layers::IAPZCTreeManager::SetDPI",
-      mAPZC,
-      &IAPZCTreeManager::SetDPI,
-      dpi));
+  mAPZC->SetDPI(GetDPI());
 
   if (gfxPrefs::APZKeyboardEnabled()) {
-    KeyboardMap map = nsXBLWindowKeyHandler::CollectKeyboardShortcuts();
-    // On Android the main thread is not the controller thread
-    APZThreadUtils::RunOnControllerThread(NewRunnableMethod<KeyboardMap>(
-        "layers::IAPZCTreeManager::SetKeyboardMap",
-        mAPZC,
-        &IAPZCTreeManager::SetKeyboardMap,
-        map));
+    mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts());
   }
 
   RefPtr<IAPZCTreeManager> treeManager = mAPZC;  // for capture by the lambdas
 
   ContentReceivedInputBlockCallback callback(
       [treeManager](const ScrollableLayerGuid& aGuid,
                     uint64_t aInputBlockId,
                     bool aPreventDefault)
@@ -1928,24 +1915,17 @@ nsBaseWidget::ZoomToRect(const uint32_t&
                          const FrameMetrics::ViewID& aViewId,
                          const CSSRect& aRect,
                          const uint32_t& aFlags)
 {
   if (!mCompositorSession || !mAPZC) {
     return;
   }
   uint64_t layerId = mCompositorSession->RootLayerTreeId();
-  APZThreadUtils::RunOnControllerThread(
-    NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
-      "layers::IAPZCTreeManager::ZoomToRect",
-      mAPZC,
-      &IAPZCTreeManager::ZoomToRect,
-      ScrollableLayerGuid(layerId, aPresShellId, aViewId),
-      aRect,
-      aFlags));
+  mAPZC->ZoomToRect(ScrollableLayerGuid(layerId, aPresShellId, aViewId), aRect, aFlags);
 }
 
 #ifdef ACCESSIBILITY
 
 a11y::Accessible*
 nsBaseWidget::GetRootAccessible()
 {
   NS_ENSURE_TRUE(mWidgetListener, nullptr);