Bug 1642884 - Ensure calls to Axis::CancelGesture() are protected by the APZC lock. r=kats
☠☠ backed out by a765142bf1d3 ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Wed, 03 Jun 2020 16:56:45 +0000
changeset 533727 02f8daecd98e4aaeb0eb2101725b49bd515764f9
parent 533726 79c2788498a8a636a7e64d899cbff590f2304cd0
child 533728 393a6ff847ce341fbe0e86f1bccfbea5ed8c3157
push id37477
push userdluca@mozilla.com
push dateThu, 04 Jun 2020 04:19:27 +0000
treeherdermozilla-central@6fd265574f27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1642884
milestone79.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 1642884 - Ensure calls to Axis::CancelGesture() are protected by the APZC lock. r=kats Differential Revision: https://phabricator.services.mozilla.com/D78086
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2473,18 +2473,17 @@ nsEventStatus AsyncPanZoomController::On
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnPanCancelled(
     const PanGestureInput& aEvent) {
   APZC_LOG("%p got a pan-cancelled in state %d\n", this, mState);
 
-  mX.CancelGesture();
-  mY.CancelGesture();
+  CancelGesture();
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnPanBegin(
     const PanGestureInput& aEvent) {
   APZC_LOG("%p got a pan-begin in state %d\n", this, mState);
 
@@ -2723,18 +2722,17 @@ nsEventStatus AsyncPanZoomController::On
   APZC_LOG("%p got a pan-momentumend in state %d\n", this, mState);
 
   // Call into OnPan in order to process any delta included in this event.
   OnPan(aEvent, false);
 
   // We need to reset the velocity to zero. We don't really have a "touch"
   // here because the touch has already ended long before the momentum
   // animation started, but I guess it doesn't really matter for now.
-  mX.CancelGesture();
-  mY.CancelGesture();
+  CancelGesture();
   SetState(NOTHING);
 
   RequestContentRepaint();
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnLongPress(
@@ -3553,16 +3551,22 @@ void AsyncPanZoomController::StartTouch(
 }
 
 void AsyncPanZoomController::EndTouch(TimeStamp aTimestamp) {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
   mX.EndTouch(aTimestamp);
   mY.EndTouch(aTimestamp);
 }
 
+void AsyncPanZoomController::CancelGesture() {
+  RecursiveMutexAutoLock lock(mRecursiveMutex);
+  mX.CancelGesture();
+  mY.CancelGesture();
+}
+
 void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
   ExternalPoint extPoint = GetFirstExternalTouchPoint(aEvent);
   ScreenPoint panVector = PanVector(extPoint);
   HandlePanningUpdate(panVector);
 
   ParentLayerPoint prevTouchPoint(mX.GetPos(), mY.GetPos());
   ParentLayerPoint touchPoint = GetFirstTouchPoint(aEvent);
 
@@ -5067,18 +5071,17 @@ void AsyncPanZoomController::ResetTouchI
   // Clear overscroll along the entire handoff chain, in case an APZC
   // later in the chain is overscrolled.
   if (TouchBlockState* block = GetCurrentTouchBlock()) {
     block->GetOverscrollHandoffChain()->ClearOverscroll();
   }
 }
 
 void AsyncPanZoomController::CancelAnimationAndGestureState() {
-  mX.CancelGesture();
-  mY.CancelGesture();
+  CancelGesture();
   CancelAnimation(CancelAnimationFlags::ScrollSnap);
 }
 
 bool AsyncPanZoomController::HasReadyTouchBlock() const {
   return GetInputQueue()->HasReadyTouchBlock();
 }
 
 bool AsyncPanZoomController::CanHandleScrollOffsetUpdate(PanZoomState aState) {
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -808,16 +808,22 @@ class AsyncPanZoomController {
   void StartTouch(const ParentLayerPoint& aPoint, TimeStamp aTimestamp);
 
   /**
    * Register the end of a touch or pan gesture at the given time.
    */
   void EndTouch(TimeStamp aTimestamp);
 
   /**
+   * Register the forceful end of a touch or pan gesture, such as when a
+   * touch-cancel event is received.
+   */
+  void CancelGesture();
+
+  /**
    * Utility function to send updated FrameMetrics to Gecko so that it can paint
    * the displayport area. Calls into GeckoContentController to do the actual
    * work. This call will use the current metrics. If this function is called
    * from a non-main thread, it will redispatch itself to the main thread, and
    * use the latest metrics during the redispatch.
    */
   void RequestContentRepaint(
       RepaintUpdateType aUpdateType = RepaintUpdateType::eUserAction);