Bug 1285239 - Scrolling can randomly get interrupted and show overscroll effect r=botond
authorRandall Barker <rbarker@mozilla.com>
Thu, 07 Jul 2016 20:05:59 -0700
changeset 304227 26e8e90223c1cf5ac8304e88df00fccab7f34281
parent 304226 d78eccd3f37ca7e96c9755a058c6b60d3aa91276
child 304228 0f3ebce53943e0fa6f45534f73904ec2c30b8df6
push id79275
push userrbarker@mozilla.com
push dateFri, 08 Jul 2016 16:29:13 +0000
treeherdermozilla-inbound@26e8e90223c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1285239
milestone50.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 1285239 - Scrolling can randomly get interrupted and show overscroll effect r=botond
gfx/layers/apz/src/AndroidAPZ.cpp
--- a/gfx/layers/apz/src/AndroidAPZ.cpp
+++ b/gfx/layers/apz/src/AndroidAPZ.cpp
@@ -138,16 +138,17 @@ AndroidFlingAnimation::DoSample(FrameMet
   mFlingDuration += aDelta.ToMilliseconds();
   mOverScroller->ComputeScrollOffset(mFlingDuration, &shouldContinueFling);
 
   int32_t currentX = 0;
   int32_t currentY = 0;
   mOverScroller->GetCurrX(&currentX);
   mOverScroller->GetCurrY(&currentY);
   ParentLayerPoint offset((float)currentX, (float)currentY);
+  ParentLayerPoint preCheckedOffset(offset);
 
   bool hitBoundX = CheckBounds(mApzc.mX, offset.x, mFlingDirection.x, &(offset.x));
   bool hitBoundY = CheckBounds(mApzc.mY, offset.y, mFlingDirection.y, &(offset.y));
 
   ParentLayerPoint velocity = mPreviousVelocity;
 
   // Sometimes the OverScroller fails to update the offset for a frame.
   // If the frame can still scroll we just use the velocity from the previous
@@ -158,19 +159,22 @@ AndroidFlingAnimation::DoSample(FrameMet
       mOverScroller->GetCurrSpeedX(&velocity.x);
       mOverScroller->GetCurrSpeedY(&velocity.y);
 
       velocity.x /= 1000;
       velocity.y /= 1000;
 
       mPreviousVelocity = velocity;
     }
-  } else if (hitBoundX || hitBoundY) {
-    // We have reached the end of the scroll in one of the directions being scrolled and the offset has not
-    // changed so end animation.
+  } else if ((fabsf(offset.x - preCheckedOffset.x) > BOUNDS_EPSILON) || (fabsf(offset.y - preCheckedOffset.y) > BOUNDS_EPSILON)) {
+    // The page is no longer scrolling but the fling animation is still animating beyond the page bounds. If it goes
+    // beyond the BOUNDS_EPSILON then it has overflowed and will never stop. In that case, stop the fling animation.
+    shouldContinueFling = false;
+  } else if (hitBoundX && hitBoundY) {
+    // We can't scroll any farther along either axis.
     shouldContinueFling = false;
   }
 
   float speed = velocity.Length();
 
   // gfxPrefs::APZFlingStoppedThreshold is only used in tests.
   if (!shouldContinueFling || (speed < gfxPrefs::APZFlingStoppedThreshold())) {
     if (shouldContinueFling) {