Skip to content

Fix Android pinch pointer lift handling#4215

Open
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/android-end-pinch-when-pointer-lifts
Open

Fix Android pinch pointer lift handling#4215
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/android-end-pinch-when-pointer-lifts

Conversation

@sorinc03
Copy link
Copy Markdown
Contributor

Summary

  • end an active Android pinch when a pointer lift leaves fewer than two tracked pointers
  • fail a begun-but-not-active pinch in the same case
  • avoid emitting an extra active pinch update with stale numberOfPointers / focal data after one finger is lifted

Fixes #3435.

Test plan

  • yarn workspace react-native-gesture-handler lint:android
  • ./gradlew :app:assembleDebug --console=plain -PreactNativeArchitectures=arm64-v8a from apps/basic-example/android

Copilot AI review requested due to automatic review settings May 31, 2026 21:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes pinch gesture handler on Android to end/cancel when the pointer count drops below the minimum required (2) due to a pointer being lifted, not just on the final ACTION_UP.

Changes:

  • Detect when a pointer-up event reduces active pointers below MIN_POINTERS.
  • Trigger state transition (cancel/end) in that case alongside ACTION_UP.
  • Introduce MIN_POINTERS companion constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki
Copy link
Copy Markdown
Member

Hey! Thanks for bringing it to our attention. Your PR would cause Pinch gesture to fail when left with a single pointer, which would cause its behavior to diverge from iOS and Web implementations.

I've looked a bit more into this, and it's a general issue with all handlers where, on ACTION_POINTER_UP, Android includes the lifted pointer in the event's pointerCount. I've opened #4218 to address the underlying problem. If this was affecting you, I'd appreciate if you could check whether that PR solves the problem for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android pointer number remains 2 when lifting one finger during pinch gesture

3 participants