From 49b57e955c4cb37e91db77cc4813dd59eaacdc70 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 4 May 2020 14:56:09 -0500 Subject: [PATCH] Fix continueComputingRecentsScrollIfNecessary() running infinitely When continuing a gesture during quick switch, we cancel the previous animation but don't invalidate it (since the gesture isn't fully finished), and the new gesture handler calls mRecentsView.setOnPageTransitionEndCallback(), so the previous handler will never get STATE_RECENTS_SCROLLING_FINISHED. Thus, continueComputingRecentsScrollIfNecessary() will never end. To fix this, also check !mCanceled, since that is set when continuing the gesture. Also use postOnAnimation() instead of post() since that has better guarantees that the next computation will wait for the next animation frame, rather than whenever the message queue is available, which might happen too frequently. Test: quick switch from A to B and back to A before settling on B, ensure we stop calling computeScroll(). Bug: 153589287 Change-Id: I6b4389ef2cf5a818438c7ae36d8807b3e41c8501 --- .../src/com/android/quickstep/LauncherSwipeHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java index 1f78857c2e..633bd13c8f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java @@ -1081,9 +1081,10 @@ public class LauncherSwipeHandler private void continueComputingRecentsScrollIfNecessary() { if (!mGestureState.hasState(STATE_RECENTS_SCROLLING_FINISHED) - && !mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { + && !mStateCallback.hasStates(STATE_HANDLER_INVALIDATED) + && !mCanceled) { computeRecentsScrollIfInvisible(); - mRecentsView.post(this::continueComputingRecentsScrollIfNecessary); + mRecentsView.postOnAnimation(this::continueComputingRecentsScrollIfNecessary); } }