From 2076ef9768a1b01ea81afafab058aeed94b8b8ef Mon Sep 17 00:00:00 2001 From: Tang Ding Date: Thu, 18 Mar 2021 13:53:13 +0000 Subject: [PATCH] FIx issue: https://issuetracker.google.com/issues/183024999 There's a performance issue during continually scroll listview when listview in Fling state . Consider such scene as blew: 1.Listview holds a lots of data 2.mTouchMode in TOUCH_MODE_FLING state. 3.Touch Event delivery down event to listview , mTouchMode change to TOUCH_MODE_SCROLL , post checkFlyWheel(40ms timeout). move event make checkFlywheel.endFling() delay to execute , before endFling() satisfied to execute up event occured, flingrunnable.start() will post a extra FlingRunnable in onTouchUp(). Finally Choreographer.CallbackQueue will get more and more FlingRunnable animation callback when keep repeating above steps#3, Choreographer#doFrame#animation will execute FlingRunnbale N times per frame , it will greater than vsync period cause jank (N means repeat steps#3 times). Solution: Remove unnecessary FlingRunnable before add FlingRunnable. Change-Id: I2cbab9171ffbaad87a8908eef09f813cf89ad85a --- core/java/android/widget/AbsListView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index a785a1ab9f0e2..51396dbb82041 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -4679,6 +4679,7 @@ public abstract class AbsListView extends AdapterView implements Te 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); mTouchMode = TOUCH_MODE_FLING; mSuppressIdleStateChangeCall = false; + removeCallbacks(this); postOnAnimation(this); if (PROFILE_FLINGING) {