software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.03k stars 1.3k forks source link

TurboModuleRegistry NativeReanimated error #1127

Closed Eli-Nathan closed 4 years ago

Eli-Nathan commented 4 years ago

Description

Using this package along with React Native Reanimated Bottom Sheet, I get this error on Android. (ios works great!)

Dismissing the error on my android emulator results in a blank white screen.

client_log | Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

[3] cllient_log | Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
Screen Shot 2020-08-15 at 1 14 37 PM

Screenshots

Steps To Reproduce

  1. Install and link Reanimated v2
  2. Install React native Bottom Sheet Lib (Uses reanimated v2)
  3. Add any components that have a Reanimated v2 dependency

Expected behavior

App is usable

Actual behavior

App fails with the above error

Package versions

Eli-Nathan commented 4 years ago

Completely removing the android device from my AVD manager and adding it again fixed the issue suggesting that it was something to do with my caching.

Closing now

rpavlovs commented 4 years ago

Same problem on iOS, removing android simulators from AVD didn't help

jakub-gonet commented 4 years ago

IIRC this should be resolved on newest alpha, have you tried updating?

rpavlovs commented 4 years ago

Yea, I've actually just installed alpha-8 following instructions and got this. I've only configured for iOS since that's the only platform I'll be building for - so no config other than Babel plugin

wanderSX commented 4 years ago

Getting the same when trying to enable remote debugger. IOS, alpha-8, RN 62.0

sanpoChew commented 4 years ago

am also getting this with alpha-8 when trying to run on iOS

harrysayers commented 4 years ago

I too am getting this issue on IOS

marionoratoRN commented 4 years ago

Same here with alpha8 when trying to start the debugger

mdcone commented 4 years ago

I'm in the same boat.

terrysahaidak commented 4 years ago

All the people who report it could you please tell us the environment you're using?

mdcone commented 4 years ago

XCode 12.1 React 16.13.1 React Native 0.63.3 React Native Reanimated 2.0.0-alpha.8 Node 12.18.2 npm 6.14.5 Pod RNReanimated 2.0.0-alpha.8

I can see ReanimatedModule in the NativeModules list, but not NativeReanimated (not sure if it's supposed to show up there at all). My Podfile.lock lists RNReanimated 2.0.0-alpha.8.

I also didn't follow the other version instructions dealing with TurboModules, and only have looked at the instructions for installing alpha 8. Perhaps there's something subtle I missed?

terrysahaidak commented 4 years ago

Did you upgrade or it's clean install of Reanimated?

mdcone commented 4 years ago

This was an upgrade from 1.4.0.

mdcone commented 4 years ago

I'm not familiar with the way TurboModules are supposed to get registered or appear to the RN runtime, so pardon my ignorance here, but I started stepping through RN's TurboModuleRegistry implementation and see that the turboModuleProxy constant (which is set by global.__turboModuleProxy is undefined.

Again, I haven't done anything in my app to turn them on explicitly, so I'm not sure if this is undefined from something I did (or didn't do), or if it's supposed to be undefined if no TurboModules have been properly registered in the app.

Thanks for any insights!

terrysahaidak commented 4 years ago

Did you enable TurboModules on Android as it explained in the installation guide?

mdcone commented 4 years ago

Sorry, to be clear, my problem is specifically iOS. I haven't attempted to build for Android yet. I realize this ticket was created originally in the Android context, but the rest of the comments were talking about iOS, so I joined in. Tomorrow I can try to get Android running and get back to you.

MurphDirt879 commented 4 years ago

I am having the same issue with iOS. Andriod is working fine.

mdcone commented 4 years ago

More developments: I downloaded the playground application, fired it up, everything worked well. I turned on debugging and now I'm seeing the error.

So, I turned debugging off on my app and we're back in business. This occurs in both iOS and Android for me. So it appears to be something with having the debugger enabled that is causing the issue.

Digging in further, it looks like when we are externally debugging global.__reanimatedModuleProxy is undefined so then we go to ask for the module from the TurboModuleRegistry.getEnforcing() method, which bombs out in both scenarios. When not attached to the debugger global.__reanimatedModuleProxy is set.

I'm using the latest production version of Chrome - 86.0.4240.193

mdcone commented 4 years ago

I'm looking at the UIResponder+Reanimated.mm code and started stepping through. What's interesting to me is that when I am not attached to the debugger, the code runs. When I switch to attaching to the debugger, it doesn't run. Then when I switch back, it runs again.

mdcone commented 4 years ago

I've been digging into RN's RCTCxxBridge it look as if the code which would register the __reanimatedModuleProxy variable is wiped out if connected to the debugger.

Line 336 of the bridge code checks to see if the executorClass is set, and if not, will call the code in UIResponder+Reanimated.mm. Otherwise, it hits the else branch which wipes out the executorFactory and constructs a new one generated with respect to the executorClass, thus removing the code which is executed during runtime initialization to register the __reanimatedModuleProxy global. This executorClass is only set if in a debug mode and is of type RCTWebSocketExecutor.

Does that seem like a reasonable diagnosis? Thanks for the help!

koktavy commented 3 years ago

XCode 12.1 React 16.13.1 React Native 0.63.2 React Native Reanimated 2.0.0-alpha.8 Node 12.14.1 npm 6.14.7 Pod RNReanimated 2.0.0-alpha.8

After upgrading, the issue persists when trying to downgrade to reanimated 1.13.1

mdcone commented 3 years ago

@kotavy , did you run the bundler with --reset-cache after you downgraded? I had to so that in both an upgrade and downgrade scenarios.

koktavy commented 3 years ago

Thanks for the tip. I do have 1.13.1 working again after adding that to my all-in-one reset command: watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start --reset-cache Followed by running the sim again: yarn react-native run-ios --simulator 'iPad Air 2'

I'll test upgrading in a similar way next.

koktavy commented 3 years ago

When loading with 2.0.0-alpha.8 I'm still running into ExceptionsManager.js:179 Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary.

mdcone commented 3 years ago

That's the issue I'm running into as well. In my comments above, I detailed what I think is the reason, which is that the module registration mechanism the library is using in alpha.8 has a flaw in it. That flaw being, it doesn't work when the debugger is connected. I am unfamiliar with react-native's underlying native code registration mechanisms, especially with the new JSI system that Reanimated2 uses, but I stepped through the code yesterday and that was my conclusion. I'm just waiting on comments from the maintainers on if that's the case and if there is anything that can be done to patch it before a new version is release.

In the meantime, I have resorted to turning my debugging off and have resorted to print statements. Not optimal, and not a long term strategy, but it is allowing me to proceed.

koktavy commented 3 years ago

It seems like a solid lead, thank you for investigating. That's the issue that lead me here in the beginning. I'm trying alpha.6.1 now but if I'm stuck there I'll have to wait it out.

Edit: Using 6.1 and following the turbo install instructions is working for me.

jakub-gonet commented 3 years ago
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

This says that TurboModuleRegistry cannot find our turbo module. This can be coming from the wrong configuration of Reanimated or using a debugger. Debugging RN works by running JS in the browser (v8 engine) and making remote calls via bridge to the native side. Turbomodules work by sharing JS engine context on the native side, so when you run JS in the other engine it loses that context. Note that this is a limitation coming from RN and not Reanimated. This comment may give some more insight into that.

If disabling debugger fixes your problem then it works like intended. If not, please create a repro repository to allow us to investigate this issue.

mdcone commented 3 years ago

Thanks @jakub-gonet! Do you think that there would be some value in allowing the debugger to be enabled, but if so, returning a mock of reanimated2? For those of us using reanimated2 is specific parts of our apps, doing do could enable us to debug non-reanimated dependent code.

Using alpha 8 allows us to not enable TurboModules at all, which gives us the debugger option in the developer menu again. So I think it would be possible to achieve.

terrysahaidak commented 3 years ago

I would rather suggest to just disable the code which uses Reanimated instead

Benzer1406 commented 3 years ago

Have the same issue with: Xcode: 12.0.1 RN: 0.63.3 react-native-reanimated: 2.0.0-alpha.8

matinzd commented 3 years ago

I don't know why this issue is closed!

Rizialdi commented 3 years ago

I just had the same issue. Also wondering why this issue is closed.

pkbiswal321 commented 3 years ago

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary.

"react": "~16.13.1",
"react-dom": "~16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.0.tar.gz",
"react-native-gesture-handler": "~1.7.0",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-reanimated": "^2.0.0-alpha.9.2",

I just had the same issue

surgeharb commented 3 years ago

Please stick to this version "react-native-reanimated": "2.0.0-alpha.6",. I had the same issue, so make sure you have 2.0.0-alpha.6 and implemented the following instructions https://docs.swmansion.com/react-native-reanimated/docs/2.0.0-alpha.7/installation/#ios

P.S.: Notice #import <RNReanimated/REATurboModuleProvider.h>, REATurboModuleProvider is renamed from RETurboModuleProvider (this module is used somewhere in the code it needs rename as well) and it seems that this file is not available in the newer version of reanimated.

aprilmintacpineda commented 3 years ago

I get this when I Shake Device -> Debug the app.

Ebeldev commented 3 years ago

I do have the same problem. I had the "react-native-reanimated": "^2.0.0-alpha.9.2" version. I did reinstalled the version "react-native-reanimated": "^2.0.0-alpha.6". Flush the node_modules and the package-lock.json. Rebuild the app. And I still get the same error.

yleclanche commented 3 years ago

Same here. The issue arise when I'm in debug mode with expo. And if the app is in debug mode, the only way to revert it is to reinstall the expo app because the menu to disable the debug mode is not available when there is an error.

592da commented 3 years ago

still happening, 2.0.0-rc.1, xcode 12.3

huy-lv commented 3 years ago

@yleclanche you are right, if anyone got this problem, try to re install app and do not turn debug on :))

dandre-hound commented 3 years ago

I'm confused about the status of debugging with react-native-reanimated. In the alpha versions, we couldn't debug because turbo modules were enabled. Now in the release candidates the debug menu is enabled, but it kills react native as described above. Should the debug menu still be disabled? I would really like to use chrome debugging for why-did-you-render, but I'm unable to because of the reanimated integration.

bneigher commented 3 years ago

This is blocking me from moving to react native 0.64.0 as Hermes is getting first-class treatment

cyberdude commented 3 years ago

I'm having this problem. It's unfortunate.

2.0.0-rc.2, xcode 12.3, RN-0.63.4

ionflow commented 3 years ago

Same issue here:

TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary.

xcode: 12.1 DevTools 4.10.1-3a8c04e3b2

"dependencies": { "@react-native-async-storage/async-storage": "^1.13.3", "expo": "~40.0.0", "expo-status-bar": "~1.0.3", "react": "16.13.1", "react-dom": "16.13.1", "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz", "react-native-reanimated": "2.0.0-rc.0", "react-native-web": "~0.13.12" }, "devDependencies": { "@babel/core": "~7.9.0", "babel-preset-expo": "8.3.0" },

keyboardshotgun commented 3 years ago

Check Hermes engine is enabled and add some codes for RNA v2. https://docs.swmansion.com/react-native-reanimated/docs/installation/

canberkardic commented 3 years ago

Same problem here when using debugging.

TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary.

"react": "16.13.1", "react-native": "0.63.3", "react-native-reanimated": "^2.0.0-alpha.9.2", Xcode 12.2

Hermes is enabled. Turbo modules was set as described in the documentation.

L-A commented 3 years ago

I hope this is helpful and I'm not stating the obvious to everyone here:

The current (rc.2) docs specify that RN's remote debugging will not work alongside JSI.

For people looking to keep using Reanimated V2 and continue logging to a console, the current solution is to use Flipper to connect to the device instead of enabling the in-browser remote debugger. It's already part of react-native on the device, so all you're missing is to run the desktop application to receive the app's logs:

https://fbflipper.com/

Yandamuri commented 3 years ago

@L-A I am getting this error even though I didn't enable the debug mode. I am using "react-native-reanimated": "2.0.0-rc.3" Can you please help me on this?

BTW, It's working fine in IOS. issue with android only.

Skr1pt1k commented 3 years ago

I have this error on my m1 macbook pro...

kg-currenxie commented 3 years ago

Same in debug mode only..

itzmestar commented 3 years ago

i had the same error.

Solution: uninstalled current version for: @react-navigation/drawer @react-navigation/native @react-navigation/stack

then installed: "@react-navigation/drawer": "^5.12.3", "@react-navigation/native": "^5.9.2", "@react-navigation/stack": "^5.14.2",

this fixed the error