fix(gestures): Replace GestureDetectorCompat with lightweight detector to fix ANR (#5138)
* fix(android): Replace GestureDetectorCompat with lightweight SentryGestureDetector to fix ANR GestureDetectorCompat internally uses Handler.sendMessage/removeMessages which acquires a synchronized lock on the main thread MessageQueue, plus recordGestureClassification triggers IPC calls. This caused ANRs under load (SDK-CRASHES-JAVA-596, 175K+ occurrences). Replace with a minimal custom detector that only detects click, scroll, and fling without any Handler scheduling, MessageQueue contention, or IPC overhead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(android): Add unit tests for SentryGestureDetector Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * changelog Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * 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> * fix(gestures): Remove stale GestureDetectorCompat class availability check UserInteractionIntegration gated itself on GestureDetectorCompat being available via classloader check, but SentryGestureDetector only uses Android SDK classes. Remove the check so the integration works without androidx.core. Also remove the stale proguard -keep rule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move changelog entry * ref(gestures): Simplify SentryGestureDetector resource lifecycle Keep VelocityTracker alive across gesture cycles instead of obtain/recycle churn on every gesture. Add release() method called from SentryWindowCallback.stopTracking() to prevent native resource leaks when activity is destroyed mid-gesture. Also fix broken Javadoc @link to removed dependency, change onTouchEvent return to void, and remove redundant null check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(gestures): Handle multi-touch to prevent spurious tap detection When a second finger touches the screen (ACTION_POINTER_DOWN), cancel tap detection by setting isInTapRegion to false. Previously, pinch-to-zoom gestures where the first finger stayed still would incorrectly trigger onSingleTapUp, producing false click breadcrumbs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: Register btrace-perfetto skill in agents.toml Add local btrace-perfetto skill for capturing and comparing Perfetto traces on Android devices using btrace 3.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: Add btrace-perfetto skill for Perfetto trace capture Workflow skill that automates capturing and comparing Perfetto traces using btrace 3.0 on Android devices. Includes a Perfetto UI viewer template with SQL query deep-linking via postMessage API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: Update btrace skill with release builds and sound cues Use release builds for accurate profiling, add ProGuard keep rules for btrace and Sentry class names, increase trace duration to 30s, and play a Ping sound synced to the actual trace start. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: Update btrace-perfetto skill with debug builds and trace comparison Prefer debug builds for richer tracing instrumentation (Handler, MessageQueue, Lock slices). Add trace_processor prerequisite for local querying. Add Step 6 with SQL queries and comparison table generation. Include sampling rate reference and additional troubleshooting entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(gestures): Suppress fling after multi-touch to prevent misclassified swipes The ACTION_POINTER_DOWN handler suppressed taps but not flings. When the last finger lifts quickly after a pinch-to-zoom, the velocity check in ACTION_UP could fire onFling, causing SentryGestureListener to misclassify the gesture as a swipe breadcrumb. Add ignoreUpEvent flag mirroring GestureDetector's mIgnoreNextUpEvent to skip the entire UP handler after multi-touch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
R
Roman Zavarnitsyn committed
de6a178ca26079db56d6b52388281e87621c91df
Parent: ce4b2c1
Committed by GitHub <noreply@github.com>
on 4/16/2026, 12:35:13 PM