Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #320, "Unsupported top level event type "onGestureHandlerEvent"" #792

Closed
wants to merge 2 commits into from

Conversation

paddlefish
Copy link

hook up one NativeEventEmitter to whitelist our event types

This fixes #320

@solidfox
Copy link

I'm also seeing the same behavior for onGestureHandlerStateChange. Do we need to add a dummy listener for that as well?

@mikehardy
Copy link

Hello everyone :-), honest question: has anyone done a pure test on this without the workaround of importing react-native-gesture-handler early, and can reliably crash, then apply this fix and never crash? Just curious if this has been tested rigorously.

If not, I could try that, and hopefully it could at least be provisionally merged until there was a good solution, as I'd like to remove the workaround in my own project and it would help new users I'm sure.

@paddlefish I assume this nailed the problem for you? @kmagiera @solidfox have you tried it for onGestureHandlerStateChange?

@tomtargosz
Copy link

tomtargosz commented Oct 30, 2019

@mikehardy I gave this a shot by using this fix locally on react-native 0.61.3 and gesture handler 1.5.0 but replacing onGestureHandlerEvent with onGestureHandlerStateChange without the import workaround and I'm still still getting the same error. 😞

[fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched

@solidfox
Copy link

solidfox commented Oct 31, 2019

@mikehardy I also tried adding listeners for both events and still got the error.

@paddlefish
Copy link
Author

I think there is a deeper problem for sure. I thought maybe this workaround would be a band aid... but perhaps just like real band aids they sometimes come off :-/

I did notice that the core react-native code has special case handling for gesture handler events. Maybe there is a newer better way events are supposed to be sent that would mean that this workaround isn’t needed AND that react-native doesn’t need to have special cases either.

@omnikron
Copy link

omnikron commented Nov 1, 2019

We are currently upgrading to React Native 0.61.3 and as part of that have upgraded to react-native-gesture-handler 1.5.0 to fix facebook/react-native#26626 (comment).

I only started seeing this 'Unsupported top level event type "onGestureHandlerEvent"' crash after upgrading from react-native-gesture-handler 1.4.1 to 1.5.0.

I can't offer any more repro steps than have already been mentioned in the various tickets but maybe this helps to narrow it down...?

Edit: very anecdotally, but moving import "react-native-gesture-handler"; to the top of my index.ios.js and index.android.jsfiles seems to have fixed it.

@kmagiera
Copy link
Member

Hey @paddlefish – Thanks for working on this.

Have you maybe tried your workaround when running on iOS in release mode? I think currently the main issue is with the release setup as otherwise the gesture handler events are whitelisted in RN core.

@kmagiera
Copy link
Member

I checked this PR and it appears not to be fixing the issue in release mode. Can you double check or confirm whether you tried release mode on iOS?

@kmagiera
Copy link
Member

I think I managed to find yet another workaround and submitted #845

@paddlefish
Copy link
Author

Hey @paddlefish – Thanks for working on this.

Have you maybe tried your workaround when running on iOS in release mode? I think currently the main issue is with the release setup as otherwise the gesture handler events are whitelisted in RN core.

I discovered it only in release builds (TestFlight). After my patch my TestFlight builds have been working. 🤷

@slorber
Copy link
Contributor

slorber commented Jan 30, 2020

Hey, for what it's worth, I can confirm I only see this issue in iOS release mode, and see it in an Expo ejected 36 app despite using 1.5.3 JS, while it's supposed to be fixed in 1.5.1 in https://github.com/software-mansion/react-native-gesture-handler/pull/845/files

I guess Expo might use 1.5.0 native so upgrading just the JS is not enough (but at least does not crash anyway)

@kmagiera
Copy link
Member

kmagiera commented Feb 5, 2020

@slorber for versioning gesture-handler libs we use this scheme where patch numbers are only JS updates. This is specifically to make it possible for expo users to receive some updates that does not require native code. It also means that 1.5.1 is compatible with 1.5.0 native code. Also note that the fix from #845 did not include any native changes

@slorber
Copy link
Contributor

slorber commented Feb 5, 2020

Ah I see, I thought I had seen some native in the PR when I looked.

Was already on 1.5.3 (with Expo SDK36), and still had the problem, and that was fixed by importing RNGH at the entry point in the app. My app is perhaps particular in that it's like uber driver + uber customer in one app, so I require("./uberDriverApp") only after knowing the user type to avoid initializing js unnecessary, that may be a reason.

@mnzaki
Copy link

mnzaki commented Jul 21, 2020

Thanks @omnikron!

Edit: very anecdotally, but moving import "react-native-gesture-handler"; to the top of my index.ios.js and index.android.jsfiles seems to have fixed it.

Can confirm, adding import 'react-native-gesture-handler' somewhere near the beginning of the bundle resolved the issue for me

RN 0.59
react-native-gesture-handler 1.3.0

@jkadamczyk
Copy link
Contributor

I'll close this PR as from what I understand, RNGH events are whitelisted in RN core.
If you still experience any issues of the kind described in this PR, we can reopen it or work on a new solution.

@jkadamczyk jkadamczyk closed this Oct 20, 2020
@jkadamczyk jkadamczyk self-assigned this Oct 20, 2020
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.

Unsupported top level event type "onGestureHandlerStateChange" dispatched
9 participants