Search code examples
androidtouchlatencydispatchtouch-event

ACTION_UP Event in dispatchTouchEvent is Getting Triggered Late


I make a swipe gesture and track it from dispatchTouchEvent in a ScrollView. However, end of the swipe gesture is being detected one frame later. See the last two events below, last two gestures are ACTION_MOVE and ACTION_UP. But their touch points are exactly the same, however their eventTimes are different.

action=ACTION_MOVE, x[0]=734.165, y[0]=1241.4056, historySize=2, eventTime=136103401 action=ACTION_MOVE, x[0]=747.8897, y[0]=1077.508, historySize=2, eventTime=136103418 action=ACTION_UP, x[0]=747.8897, y[0]=1077.508, historySize=0, eventTime=136103432

136103432 - 136103418 = 14. So ACTION_UP is being retrieved 14 ms later. This is preventing some smooth effects I do right after finger leaves the screen.

You can check the full log from here: https://zerobin.net/?a71539bf3862abdb#xXjCPrjk/Fi7l+N++9oivQkieFRQ3KA6gwQ0pU2NTYc=

So, how can I detect ACTION_UP earlier in dispatchTouchEvent?


Solution

  • This problem has been fixed in Android P. Looks like Google decided to make some real UI animation improvements.