software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.85k stars 954 forks source link

iOS app crash on tap onTouchesUp/onTouchesDown #2782

Closed anatoolybinerals closed 2 months ago

anatoolybinerals commented 2 months ago

Description

On Andoid all work fine, iOS app crash when call method onTouchesUp/onTouchesDown of Tap()

Create default RN project, add reanimated, geasture, add some code like this:

    "react": "18.2.0",
    "react-native": "0.73.4",
    "react-native-gesture-handler": "^2.15.0",
    "react-native-reanimated": "^3.7.1"
const gesture = Gesture.Tap().onTouchesUp(() => {});

<GestureDetector gesture={gesture}>
<Animated.View>
  <Section title="Step One">
    Edit <Text style={styles.highlight}>App.tsx</Text> to change
    this screen and then come back to see your edits.
  </Section>
</Animated.View>
</GestureDetector>

When tap block, app crash log:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITouchesEvent locationInView:]: unrecognized selector sent to instance 0x6000039184e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff80048d28d __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff800057894 objc_exception_throw + 48
    2   CoreFoundation                      0x00007ff8004a23a3 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
    3   CoreFoundation                      0x00007ff800491a20 ___forwarding___ + 1459
    4   CoreFoundation                      0x00007ff800493c28 _CF_forwarding_prep_0 + 120
    5   NOA                                 0x000000010049514a -[RNGestureHandlerPointerTracker extractPointerData:forTouch:] + 186
    6   NOA                                 0x00000001004957a2 -[RNGestureHandlerPointerTracker touchesBegan:withEvent:] + 450
    7   NOA                                 0x00000001004a1470 -[RNBetterTapGestureRecognizer interactionsBegan:withEvent:] + 144
    8   NOA                                 0x00000001004a1c24 -[RNBetterTapGestureRecognizer touchesBegan:withEvent:] + 180
    9   UIKitCore                           0x000000011a16b86a -[UIGestureRecognizer _componentsBegan:withEvent:] + 133
    10  UIKitCore                           0x000000011a893fb0 -[UITouchesEvent _sendEventToGestureRecognizer:] + 307
    11  UIKitCore                           0x000000011a15ac84 -[UIGestureEnvironment _updateForEvent:window:] + 483
    12  UIKitCore                           0x000000011a831c3e -[UIWindow sendEvent:] + 5262
    13  UIKitCore                           0x000000011a806e6c -[UIApplication sendEvent:] + 772
    14  UIKitCore                           0x000000011a8b3b99 __dispatchPreprocessedEventFromEventQueue + 8406
    15  UIKitCore                           0x000000011a8b6455 __processEventQueue + 8414
    16  UIKitCore                           0x000000011a8ac8d6 __eventFetcherSourceCallback + 163
    17  CoreFoundation                      0x00007ff8003e9d0f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x00007ff8003e9c51 __CFRunLoopDoSource0 + 157
    19  CoreFoundation                      0x00007ff8003e944e __CFRunLoopDoSources0 + 215
    20  CoreFoundation                      0x00007ff8003e3b83 __CFRunLoopRun + 919
    21  CoreFoundation                      0x00007ff8003e3409 CFRunLoopRunSpecific + 557
    22  GraphicsServices                    0x00007ff80a650187 GSEventRunModal + 137
    23  UIKitCore                           0x000000011a7e63a2 -[UIApplication _run] + 972
    24  UIKitCore                           0x000000011a7eae10 UIApplicationMain + 123
    25  NOA                                 0x00000001000041d0 main + 96
    26  dyld                                0x00000001052023ee start_sim + 10
    27  ???                                 0x000000010bb0b3a6 0x0 + 4491096998
)
libc++abi: terminating due to uncaught exception of type NSException

Steps to reproduce

  1. Install default RN project
  2. Install Reanimated
  3. Install Gesture
  4. Call Gesture.Tap().onTouchesUp(() => {}); or Gesture.Tap().onTouchesDown(() => {});

Snack or a link to a repository

Gesture Handler version

2.15.0

React Native version

0.73.4

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Real device

Device model

Simulator or iPhone devices

Acknowledgements

Yes

github-actions[bot] commented 2 months ago

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

github-actions[bot] commented 2 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

RRaideRR commented 2 months ago

Hey,

I have this problem as well. It worked well in 2.14.0, so it was introduced in 2.15.0.

m-bert commented 2 months ago

Hi @anatoolybinerals, @RRaideRR! I will look into it tomorrow, but I before I do this, could you please check if this PR helps? It was merged, but not released yet.

RRaideRR commented 2 months ago

Hey @m-bert ,

thanks a lot for looking into this 🙏.

If I haven't done anything wrong in my project setup and correctly applied your PR, then...

... 🥁🥁🥁 ...

it works 👏🎊🎉

m-bert commented 2 months ago

That's great! I've also tried to reproduce this issue on our current main and I haven't had that problem.

I'm closing this, but feel free to reopen it in case if it wasn't actually fixed.