-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
0.76: TurboModuleRegistry.getEnforcing error when creating a new bridge (iOS - new Arch) #48760
Comments
cc @cipolleschi 🙏 |
Hey @fbp93 You should read about Turbo Modules, the new module system: https://reactnative.dev/docs/next/turbo-native-modules-introduction you are currently using legacy APIs in your |
@okwasniewski I know about TurboModules, but I think they can be used to interact with native code. My goal is slightly different, I need to load a different js bundle into a new react context and they the two react instances are gonna talk each others. Am I missing something? Also the RCTBridge API is not marked as deprecated |
This setup is incompatible with the New Architecture. One of the new architecture principle is being Bridgeless. We are tearing down the bridge because it was a bottleneck for many applications and it prevented from running stuff on different threads. In fact, people developed solutions like yours, creating multiple bridges to get around that limitation. With the New Architecture, you don't need to have multiple React Native instances. As @okwasniewski was mentioning, you can have turbomodules that shares memory directly between JS and native so the serialization bottleneck is gone. Alternatively, there is still the possibility to have multiple instances of React Native running, but in the New Architecture you'll have to replicate all the initialization code that is in the RCTAppDelegate to initialize a new RCTHost and a new RCTInstance. In 0.78, this will be dramatically simplified by the RCTReactNativeFactory. The RCTBridge is not deprecated (yet) because we are still supporting the old architecture until most the ecosystem migrates away from it. In fact, we have interop layers that mimics the old architecture to support the migration of most app. |
@cipolleschi Thanks for the explanation 🙏 |
Description
Hi 👋
My app needs to perform a series of operations on a separate thread, and for this reason, during the setup phase, we generate an additional
RCTBridge
by passing it ajsbundle
. After updating to version 0.76 and enabling the new architecture, this setup stopped working, as if the bundle is "broken."I created an example project that reproduces the setup flow, I'll try to give you here more context:
If I opt-out the new arch with
RCT_NEW_ARCH_ENABLED=0 bundle exec pod install
everything seems working fine. Also using an empty bundle seems fine, but importing react native breaks everything.Looking in the web I found a discussion for a similar issue with android (different context but same error) so I was wondering if something is broken also iOS side.
Can you help me to understand if there is any issue or we are doing something wrong with the additional bridge creation? Thanks 🙏
Steps to reproduce
RCT_NEW_ARCH_ENABLED=0 bundle exec pod install
React Native Version
0.76.6
Affected Platforms
Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/fbp93/rn0.76-bridge-issue/tree/main
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: