From 43bc6e764c0c18a22b8d98e5099c88df348d6a17 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 14 Mar 2018 16:57:41 -0400 Subject: [PATCH] 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 --HG-- extra : rebase_source : 6718944034ec7b7223581e562aa59e9e79b54b53 --- gfx/layers/apz/src/APZCTreeManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 45669622c398..c1ddbc3fbfdf 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1064,7 +1064,7 @@ template static bool WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput) { - if (!NS_IsMainThread()) { + if (!XRE_IsParentProcess() || !NS_IsMainThread()) { return true; } @@ -1795,6 +1795,8 @@ void APZCTreeManager::UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint, EventMessage aEventMessage) { + APZThreadUtils::AssertOnControllerThread(); + WheelBlockState* txn = mInputQueue->GetActiveWheelTransaction(); if (!txn) { return; @@ -1840,6 +1842,8 @@ 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;