Bug 1502638 - If the velocity tracker can't compute a velocity, zero out the axis velocity. r=kats a=jcristau
authorBotond Ballo <botond@mozilla.com>
Fri, 02 Nov 2018 17:55:09 +0000
changeset 498367 063b9e4ccceb439d3ec795da08924c6a70f9cd6f
parent 498366 035ea5732599008612558e023ba5e84d43e43fd9
child 498368 0bf8a52ad207c50853d48a1ba11999f5f67b2a54
push id10127
push userncsoregi@mozilla.com
push dateWed, 07 Nov 2018 14:23:59 +0000
treeherdermozilla-beta@663b37581fef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, jcristau
bugs1502638
milestone64.0
Bug 1502638 - If the velocity tracker can't compute a velocity, zero out the axis velocity. r=kats a=jcristau The previous value of the axis velocity could be stale, e.g. in the opposite direction. Depends on D10449 Differential Revision: https://phabricator.services.mozilla.com/D10450
gfx/layers/apz/src/Axis.cpp
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -236,21 +236,23 @@ ParentLayerCoord Axis::PanDistance(Paren
   return fabs(aPos - mStartPos);
 }
 
 void Axis::EndTouch(uint32_t aTimestampMs) {
   // mVelocityQueue is controller-thread only
   APZThreadUtils::AssertOnControllerThread();
 
   mAxisLocked = false;
-  // If the velocity tracker wasn't able to compute a velocity, use the
-  // previous value of |mVelocity| (expected to be set during the last call
-  // to AddPosition()) as a fallback.
+  // If the velocity tracker wasn't able to compute a velocity, zero out
+  // the velocity to make sure we don't get a fling based on some old and
+  // no-longer-relevant value of mVelocity.
   if (Maybe<float> velocity = mVelocityTracker->ComputeVelocity(aTimestampMs)) {
     mVelocity = *velocity;
+  } else {
+    mVelocity = 0;
   }
   AXIS_LOG("%p|%s ending touch, computed velocity %f\n",
     mAsyncPanZoomController, Name(), mVelocity);
 }
 
 void Axis::CancelGesture() {
   // mVelocityQueue is controller-thread only
   APZThreadUtils::AssertOnControllerThread();