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
Android events don't get fired using mEventDispatcher.dispatchEvent with the New Architecture and bridgeless off #43635
Comments
@gabrieldonadel Thanks for the reproducer it was extremely valuable for me to isolate the issue. A fix is forthcoming |
Summary: When on bridge-mode, users are reporting that events are not dispatched well on Android. This is happening because `ReactEventEmitter` is checking wether the view is on Fabric or Paper, and dispatching the event properly. When on Bridge mode, on a Paper legacy view, the `uiManagerType` would be `UIManagerType.FABRIC` (as the RootView is set with Fabric Enabled), but the `mFabricEventEmitter` will be null. So this results on events being completely ignored. I've fixed this by checking if the user has enabled Fabric Interop mode, and if so, use the default event emitter. Fixes facebook#43635 Changelog: [Android] [Fixed] - Fix ReactEventEmitter on bridge-mode Differential Revision: D55317418
Summary: When on bridge-mode, users are reporting that events are not dispatched well on Android. This is happening because `ReactEventEmitter` is checking wether the view is on Fabric or Paper, and dispatching the event properly. When on Bridge mode, on a Paper legacy view, the `uiManagerType` would be `UIManagerType.FABRIC` (as the RootView is set with Fabric Enabled), but the `mFabricEventEmitter` will be null. So this results on events being completely ignored. I've fixed this by checking if the user has enabled Fabric Interop mode, and if so, use the default event emitter. Fixes facebook#43635 Changelog: [Android] [Fixed] - Fix ReactEventEmitter on bridge-mode Differential Revision: D55317418
Noticed that in your sample, your accessing the event emitter here.
I don't believe this is safe, as at this point RN will not have initialized the Id field yet, and we'll fall back to the paper event dispatcher even if this is a Fabric view. |
I see, thanks for the explanation. If the |
Yup I've tested this in your repro and it effectively fixes the issue 👍 |
Description
While migrating some libraries to be compatible with the new architecture I notice this problem where on Android, events don't get fired when using mEventDispatcher.dispatchEvent with the New Architecture and bridgeless off, but these same events work fine when running using the old arch or with bridgeless on.
It seems that for some reason
this.mFabricEventEmitter
fromReactEventEmitter
is null when an event is firedSteps to reproduce
mEventDispatcher.dispatchEvent()
React Native Version
0.74.0-rc.4
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer, Bridgeless - The New Initialization Flow
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/gabrieldonadel/react-native-android-event-dispatcher-bug
Screenshots and Videos
Screen.Recording.2024-03-23.at.15.18.39.mov
Screen.Recording.2024-03-23.at.15.12.34.mov
Screen.Recording.2024-03-23.at.15.17.26.mov
The text was updated successfully, but these errors were encountered: