Bug 1445662 - Assert that IAPZCTreeManager's helper methods are always on the controller thread. r?rhunt draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 15 Mar 2018 15:10:39 -0400
changeset 768170 7c2df9698c8e96b511378943c838855540eed544
parent 768169 833749e473baac3c09edb924073ed55bf739deed
child 768171 c59901b38d26d325c8736272d9e45f5f0351f73d
push id102813
push userkgupta@mozilla.com
push dateThu, 15 Mar 2018 19:11:06 +0000
reviewersrhunt
bugs1445662
milestone61.0a1
Bug 1445662 - Assert that IAPZCTreeManager's helper methods are always on the controller thread. r?rhunt These two functions (UpdateWheelTransaction and ProcessUnhandledEvent) are only ever called on the concrete APZCTreeManager when the APZ code is living in the GPU process. This is because the calls are made by the IAPZCTreeManager implementation which lives in the UI process, and remoted over PAPZCTreeManager. So the assertion is safe, and will help us guard against inadvertent breakage when we try making a different thread the controller thread in the GPU process. In addition, the WillHandleInput function can be called in the GPU process on the compositor thread, but we will allow it to be called on the main thread as well. In that case we need to ensure we don't try running EventStateManager pref-reading code in the GPU process, and instead preserve the current behaviour of just returning true. MozReview-Commit-ID: LoKuqoL1nzg
gfx/layers/apz/src/APZCTreeManager.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -1059,17 +1059,17 @@ APZCTreeManager::PrepareNodeForLayer(con
   node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId());
   return node;
 }
 
 template<typename PanGestureOrScrollWheelInput>
 static bool
 WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput)
 {
-  if (!NS_IsMainThread()) {
+  if (!XRE_IsParentProcess() || !NS_IsMainThread()) {
     return true;
   }
 
   WidgetWheelEvent wheelEvent = aPanInput.ToWidgetWheelEvent(nullptr);
   return IAPZCTreeManager::WillHandleWheelEvent(&wheelEvent);
 }
 
 void
@@ -1790,16 +1790,18 @@ 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())) {
@@ -1835,16 +1837,18 @@ 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) {