viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

Invariant Violation: Native component for "VRTAmbientLight" does not exist #182

Closed fadani closed 6 years ago

fadani commented 6 years ago

Hey!

In production in some cases we receive this error.

Invariant Violation: Native component for "VRTAmbientLight" does not exist

This error is located at:
    in VRTAmbientLight
    in ViroAmbientLight
    in VRTARScene
    in ViroARScene
    in Unknown
    in VRTARSceneNavigator
    in ViroARSceneNavigator

Do you maybe have a suggestion again to resolve this?

Thank you

VikAdvani commented 6 years ago

Hi @fadani, can you send us the full logs if possible? Is this error on Android only? What device models are you seeing this on? What version of React Native and React Viro are you using? Let us know so we can dive deeper into the issue. Thanks!

almostintuitive commented 6 years ago

Hi!

We can share the sentry link: https://sentry.io/share/issue/8f824444365b4e94975ac6e85b9c2fb5/

We're using react-native 0.51, with viro-react 2.4.0! Device specific info should be available on the sentry link above.

almostintuitive commented 6 years ago

sorry, the device specific parts are omitted with the public link. image

almostintuitive commented 6 years ago

Do you have any updates on this? What kind of info could we provide that'd be useful?

This is currently affecting almost 1% of our users, which I think is equivalent to around 5-10% of users who tried the AR module.

achuvm commented 6 years ago

Hi @itchingpixels,

This is an interesting error because this is normally caused by a misconfiguration of Viro with Android Studio where getPackages() in ReactNativeHost does not create and include the ReactViroPackage class.

ie. in MainApplication.java on a new Viro React project:

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new ReactNativeConfigPackage(),
          new ReactViroPackage(ReactViroPackage.ViroPlatform.valueOf(BuildConfig.VR_PLATFORM))
      );
    }

If that is the case, we would expect all your devices to crash with this error. Are you seeing this issue being reported only on that version of the Samsung Galaxy S8 (Exynos, European model)?

almostintuitive commented 6 years ago

Thank you, I think this is leading us down on the right path of resolving this. We detect run-time if the device is capable of running AR, and only initalize ReactViroPackage if it does - and we may have made a mistake somewhere around there. We'll continue the investigation and close this issue when we verified it's coming from our end!

fadani commented 6 years ago

In the meantime we tried removing the runtime logic that decides if we should initialise the ReacViroPacakage or not, because we can safely decide if we want to enable the AR view in the app or not. But when we did that we got this error on startup:

03-22 11:36:12.261  6070  6119 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.languagedrops.drops.international-1/base.apk”],nativeLibraryDirectories=[/data/app/com.languagedrops.drops.international-1/lib/x86, /data/app/com.languagedrops.drops.international-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]] couldn’t find “libviro_react.so”

On a nexus 9 device.

So this means to me that if there is a device that is not AR compatible we shouldn't even initialise the ReacViroPacakage. Is this true? Af if this is true then what would be the recommended way for deciding runtime if we should initialise it or not?

Thanks again

VikAdvani commented 6 years ago

Hi @fadani it looks like the compilation is looking for an x86 library. The Nexus 9 however doesn't seem to be an intel device, it's running a Nvidia Tegra K1 chipset w/ ARM CPU cores, so it's odd that the linker is looking for an x86 lib. Are you trying to load on the simulator of a Nexus 9?

fadani commented 6 years ago

Oh, yes it's an important detail. Sorry for missing it. You are right, it's a nexus 9 emulator.

fadani commented 6 years ago

Does this mean that we cannot use the simulator if we initialise ReacViroPacakage?

VikAdvani commented 6 years ago

Hi @fadani, yep as of now the simulator won't work for React Viro. We are trying to get this to work for a future release :)

fadani commented 6 years ago

Okay, thank you for confirming! :)

piloulac commented 6 years ago

Hello, I'm new using react native and I was wondering how to import react-viro to my react native project? doing npm install --save react-viro and calling your sample code leads me to this error (the same than just above):

screen shot 2018-04-02 at 22 04 29

Do you have any link on how bring your application to an existing one? Embedding it? I mean other than this one: https://docs.viromedia.com/v2.4.0/docs/starting-a-new-viro-project-1 because I want to embed it to an existing react native app.

Thanking you in advance.

achuvm commented 6 years ago

Hey @piloulac,

Sorry, we don't have explicit instructions for this, but our setup-ide.sh does take a raw react-native project and properly hooks up all our dependencies.

If your project is mostly just React Native components that you have simply npm install -s <component> without many Xcode changes, then that setup-ide.sh script should also work for you. Try try it, follow the instructions below.

  1. Make sure your project changes have been committed in case our script fails to work properly.
  2. Copy our setup-ide.sh script to the root of your project (cp node_modules/react-viro/bin/setup-ide.sh .)
  3. Follow the instructions here: Setup Xcode

Let us know if that doesn't work and we'll work to get you some better instructions.

piloulac commented 6 years ago

Hey @achuvm, thank you for your very quick answer. I tried running setup-ide.sh scripts and it succeeded. The problem is that I'm using react-native-maps and while running the script I had:

screen shot 2018-04-02 at 22 55 59

Where it deleted google map. I'm also using react-native-navigation which gives me a custom AppDelegate. Now, trying to lunch my app it gives:

screen shot 2018-04-02 at 23 08 39 screen shot 2018-04-02 at 23 08 50

Thank you for your help.

ps: my package.json:

  "dependencies": {
    "async": "^2.6.0",
    "react": "^16.2.0",
    "react-native": "0.53.0",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-maps": "^0.21.0",
    "react-native-navigation": "^1.1.396",
    "react-native-vector-icons": "^4.5.0",
    "react-redux": "^5.0.7",
    "react-timer-mixin": "^0.13.3",
    "react-viro": "^2.4.0",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0"
  },
achuvm commented 6 years ago

Hey @piloulac,

That error is because we don't support the iOS simulator just yet (coming VERY soon).

You'll have to build the app to a device for now.

VikAdvani commented 6 years ago

iOS Simulator is now supported. Fixed in latest major release v2.7 -> See release notes and upgrade instructions here -> https://docs.viromedia.com/docs/releases.

lordaltair commented 6 years ago

Hi, I have the same problem here on Android. (IOS works fine) and All the solutions above wont work. Why this problem occurs?

lordaltair commented 6 years ago

The Error is as you can see below: capture _2018-11-19-23-35-15

Adi33-cloud commented 1 year ago

Any update on this error I am using Expo and seeing the same error highlighted in this thread