Bug 1445662 - Assert that IAPZCTreeManager's helper methods are always on the controller thread. r?rhunt draft
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 14 Mar 2018 16:57:41 -0400
changeset 767606 0a18bb0b98ff2cbe16cf552e431d837dad1fd1ef
parent 767605 6c870292c2083f2a4399a61ad948864a6b71cfd8
child 767607 5e63a1d7e9e5da8410243ecb8d75ec298547e633
push id102649
push userkgupta@mozilla.com
push dateWed, 14 Mar 2018 20:58:42 +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: JFBX3NSXywn
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) {