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

React Native App crashes without error message when GestureDetector appears #2840

Closed demenik closed 1 month ago

demenik commented 1 month ago

Description

I am coding a React Native App that uses react-native-gesture-handler.

My initial setup where I first discovered the crash was a @react-navigation/native-stack NativeStack with two screens. When I show the screen with a GestureHandlerRootView at its root and a GestureDetector with a simple Gesture.Tap() gesture, the app crashes without any logs.

Steps to reproduce

I tried to simplify the app to see what causes the crash, so I changed my app to just the following code:

export default (): React.JSX.Element => {
  const test = Gesture.Tap().onBegin(() => console.log("Begin"));

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <GestureDetector gesture={test}>
        <View style={{ flex: 1, backgroundColor: "green" }} />
      </GestureDetector>
    </GestureHandlerRootView>
  );
};

Now the app crashes on launch, so I think the crash is caused by react-native-gesture-handler.

I'm using the new react-native architecture, installed all dependencies with CocoaPods, and included import "react-native-gesture-handler"; at the top of my index.js file.

Snack or a link to a repository

https://github.com/demenik/Muse

Gesture Handler version

2.16.0

React Native version

0.73.6

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

None

Device

Real device

Device model

iPhone 13 Pro (iOS 17.4)

Acknowledgements

Yes

RalissonMattias commented 1 month ago

I think we have the same or similar problem here #2839

j-piasecki commented 1 month ago

I believe the changes necessary to support RN 0.74 on the new arch cause it to crash on 0.73. Would it be possible for you to check if it still crashes for you on 0.74?

demenik commented 1 month ago

Updating to react-native@0.74.0-rc.5 solved the issue. Thank you!

Ever-It-Lazy commented 1 month ago

I sought out this bug, because I've been running into a similar problem all this past week.

My specs are a bit different:

Is Expo complicating React-Native's response, you think?

demenik commented 1 month ago

@Ever-It-Lazy I think your issue is a different one, as my 0.73 app already crashed on when a GestureDetector appeared and yours crashes when using one. Have you included the import 'react-native-gesture-handler'; at the top of your index.js file?

Ever-It-Lazy commented 1 month ago

I've replaced my App.js with your "green screen" example code in my environment.

You appear to be correct: I must be dealing with something different. It seems similar, because my actual app began much like yours: a NativeStack with two screens. I guess I need to spawn a separate bug report for investigation.