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

RN 0.61 Release Build - 'Unhandled JS Exception: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched #783

Closed sebqq closed 4 years ago

sebqq commented 4 years ago

Hello I'm encoutering app crashes during release mode on both, iOS and Android after RN 0.60 to 0.61 upgrade.

I'm enclosing error from xCode console:

2019-10-04 08:56:06.922 [error][tid:com.facebook.react.JavaScript] Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched
2019-10-04 08:56:06.924 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched
2019-10-04 08:56:06.926353+0200 eks_golf_ng[5301:1138125] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched', reason: 'Unhandled JS Exception: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched, stack:
extractEvents@171:13016
<unknown>@171:13807
_e@171:89649
ke@171:13544
Re@171:13717
receiveEvent@171:14132
value@56:3662
<unknown>@56:764
value@56:2868
value@56:736
value@<null>:<null>
'
*** First throw call stack:
(0x197f41c30 0x197c5c0c8 0x1006f575c 0x100767644 0x197f48724 0x197e11280 0x197e11e90 0x100728190 0x10072a2a0 0x10072a004 0x100fe1e48 0x100fe32a8 0x100fea938 0x100feb528 0x100ff64e8 0x197c4eaa0 0x197c54c78)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Does anyone encounter same issue? I will do my best to add reproducible demo ASAP.

Thank you so much for any help!

 "react-native": "0.61.2",
 "react-native-gesture-handler": "^1.4.1",
 "react-native-reanimated": "^1.3.0",
 "react-native-redash": "^8.1.2",
 "react-native-screens": "^2.0.0-alpha.3",
 "reanimated-bottom-sheet": "^1.0.0-alpha.14",
sebqq commented 4 years ago

I've opened a new issue before research and I'm so sorry for that...

I added

import 'react-native-gesture-handler'

at top of index.js file as suggested in #320 and it works now 😸

Annihil commented 4 years ago

I love those kind of magic fix, it ensures me that no one will ever take my place in the company, thank you again for that. Please do not ever document this.

sostenesg7 commented 4 years ago

I've opened a new issue before research and I'm so sorry for that...

I added

import 'react-native-gesture-handler'

at top of index.js file as suggested in #320 and it works now 😸

this is working for me! thanks!!

saadqadeercenseo commented 4 years ago

I had the same issue , does anyone knows the reason behind this ? Pardon if its really basic thing and idk :P

sostenesg7 commented 4 years ago

@saadqadeercenseo, you tried this?

 import 'react-native-gesture-handler'

at top of index.js file as suggested in #320 and it works now

saadqadeercenseo commented 4 years ago

@saadqadeercenseo, you tried this?

 import 'react-native-gesture-handler'

at top of index.js file as suggested in #320 and it works now

Yup it solved my issue I'm not sure why and why the issue occur in the first place after I upgraded to RN 0.61

arhmnsh commented 4 years ago

Also with above solutions, make sure to update to the latest version of react-native-gesture-handler: https://github.com/kmagiera/react-native-gesture-handler#react-native-support

JeremyBradshaw7 commented 4 years ago

Suggested fix doesn't work for me.

jordibruin commented 4 years ago

Same here, now it just crashes as soon as you open the app

MrSucik commented 4 years ago

For me, it crashes as soon as I touch or swipe PanGestureHandler from react-native-gesture-handler. The above solution does NOT work for me

zackify commented 4 years ago

i had to put it at the very root index.js. i wish this could get a real fix, maybe requiring an import in other libraries so that this doesnt get dropped from the code?

LucasYver commented 4 years ago

Same problem, I have many crash in my Firebase Crashlytics. It's difficult to reproduce on simulator. But before RN 0.61 i hadn't this crash. Capture d’écran 2019-11-18 à 11 27 42

anthonyhumphreys commented 4 years ago

Just to add to the noise in this thread...The proposed fix works for me, but it has to literally be the very first thing imported in root index.js or the crashing behaviour persists. If it wasn't clear above, make sure the import is the first line of index.js!

phyuthinkyi commented 4 years ago

I already add import 'react-native-gesture-handler' in index.js at the first line. But it doesn't work. gesture

JeremyBradshaw7 commented 4 years ago

@phyuthinkyi I think the import fixes iOS only. For Android, I found something else was necessary, detailed here, though for me I only got the crash in production, you're getting it in a simulator, so the circumstances may not be the same.

toxicsebastian commented 4 years ago

I've opened a new issue before research and I'm so sorry for that...

I added

import 'react-native-gesture-handler'

at top of index.js file as suggested in #320 and it works now 😸

This works perfectly, thank you!

jordaofs commented 4 years ago

Hello!

Added import "react-native-gesture-handler"; and solved my problem. I was having this issue only on release, and who still has the issue after add the import, try to clean the cache of the apk. I had this problem and stook on it after the add because of the cache, when I generate a clean apk, the problem was solved =)

ntkzwane commented 4 years ago

According to this comment, this issue has been fixed by react-native-gesture-handler: 1.5.2. I can confirm that this version works for me on Android 😄(the import 'react-native-gesture-handler' workaround is no longer needed).

bitcrumb commented 4 years ago

This issue has idd been addressed in a new release. No need to share workarounds. Just update to the latest version.

Sc4ramouche commented 4 years ago

Hey @bitcrumb, you mean latest version of react-native-gesture-handler or react-native itself?

bitcrumb commented 4 years ago

@Sc4ramouche Latest version of react-native-gesturehandler. More specifically it was patched release 1.5.1.

ainalem commented 4 years ago

We're still seeing this problem. RN 0.61.5 and react-native-gesture-handler 1.6.0. Our app is crashing randomly when testing. The problem even occurs when the app is in the background. Production only and low repeat frequency, it takes about 30m -1h30m to reproduce. We're using the react-native-gusture-handler for a custom bottom sheet implementation.

JetPlaneJJ commented 2 years ago

Also still seeing this problem, but only on iOS. The adding of import 'react-native-gesture-handler' in index.js did the fix for me on. However... I am still curious as to why this is needed/how this works?? Something about navigators being created asynchronously as the original poster said?

I am also using react-native-gesture-handler for a custom bottom sheet as well, paired with react-navigation for bottom tabs and a stack.

Versions: react-native: 0.66.0, react-native-gesture-handler: 1.10.3, @react-navigation/native: ^6.0.4

EliyaFerdinand commented 2 years ago

Also still seeing this problem, but only on iOS. The adding of import 'react-native-gesture-handler' in index.js did the fix for me on. However... I am still curious as to why this is needed/how this works?? Something about navigators being created asynchronously as the original poster said?

I am also using react-native-gesture-handler for a custom bottom sheet as well, paired with react-navigation for bottom tabs and a stack.

Versions: react-native: 0.66.0, react-native-gesture-handler: 1.10.3, @react-navigation/native: ^6.0.4

Try following installation instructions, this worked for me: https://docs.swmansion.com/react-native-gesture-handler/docs/