Skip to content

Commit d5baf94

Browse files
romtsnclaude
andcommitted
fix(gestures): Clear VelocityTracker on ACTION_DOWN to prevent stale velocity data
Matches GestureDetector behavior: if consecutive ACTION_DOWN events arrive without an intervening ACTION_UP/ACTION_CANCEL, stale motion data could bleed into fling detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 50ac45b commit d5baf94

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/internal/gestures/SentryGestureDetector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ boolean onTouchEvent(final @NotNull MotionEvent event) {
5050
if (velocityTracker == null) {
5151
velocityTracker = VelocityTracker.obtain();
5252
}
53+
54+
if (action == MotionEvent.ACTION_DOWN) {
55+
velocityTracker.clear();
56+
}
5357
velocityTracker.addMovement(event);
5458

5559
switch (action) {

0 commit comments

Comments
 (0)