facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.06k stars 24.19k forks source link

java.lang.AssertionError: Root node with tag 1 doesn't exist #29998

Closed ulbekovad closed 7 months ago

ulbekovad commented 3 years ago

Description

This bug was received through Bug reporting tool. I see the same one reported before, but there is no solution provided - #26272 I got below stacktrace: `Fatal Exception: java.lang.RuntimeException Could not invoke UIManager.createView

Caused by java.lang.AssertionError: Root node with tag 1 doesn't exist at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:35) at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:239) at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:469) at java.lang.reflect.Method.invoke(Method.java) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:216) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:784)`

React Native version:

Run react-native info in your terminal and copy the results here. System: OS: Windows 10 10.0.18363 CPU: (4) x64 Intel(R) Core(TM) i3-4100M CPU @ 2.50GHz Memory: 439.28 MB / 15.88 GB Binaries: Node: 10.19.0 - C:\dev\tool\nodejs\node.EXE Yarn: Not Found npm: 6.13.4 - C:\dev\tool\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 25, 26, 27, 28, 29 Build Tools: 28.0.3, 29.0.3, 30.0.0, 30.0.0, 30.0.1, 30.0.2 System Images: android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.6010548 Languages: Java: 1.8.0_211 Python: 2.7.17 npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: ^0.62.2 => 0.62.2 npmGlobalPackages: react-native: Not Found

Badjessa-git commented 3 years ago

Seeing something similar: Error was reported through Bugsnag

Stacktrace:

`java.lang.RuntimeException Could not invoke UIManager.createView JavaMethodWrapper.java:382 com.facebook.react.bridge.JavaMethodWrapper.invoke JavaModuleWrapper.java:150 com.facebook.react.bridge.JavaModuleWrapper.invoke NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run Handler.java:883 android.os.Handler.handleCallback Handler.java:100 android.os.Handler.dispatchMessage MessageQueueThreadHandler.java:26 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage Looper.java:237 android.os.Looper.loop MessageQueueThreadImpl.java:225 com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run Thread.java:919 java.lang.Thread.run

Caused by: java.lang.reflect.InvocationTargetException Method.java:-2 java.lang.reflect.Method.invoke JavaMethodWrapper.java:371 com.facebook.react.bridge.JavaMethodWrapper.invoke JavaModuleWrapper.java:150 com.facebook.react.bridge.JavaModuleWrapper.invoke NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run Handler.java:883 android.os.Handler.handleCallback Handler.java:100 android.os.Handler.dispatchMessage MessageQueueThreadHandler.java:26 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage Looper.java:237 android.os.Looper.loop MessageQueueThreadImpl.java:225 com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run Thread.java:919 java.lang.Thread.run

Caused by: java.lang.AssertionError Root node with tag 11 doesn't exist Assertions.java:35 com.facebook.infer.annotation.Assertions.assertNotNull UIImplementation.java:238 com.facebook.react.uimanager.UIImplementation.createView UIManagerModule.java:465 com.facebook.react.uimanager.UIManagerModule.createView Method.java:-2 java.lang.reflect.Method.invoke JavaMethodWrapper.java:371 com.facebook.react.bridge.JavaMethodWrapper.invoke JavaModuleWrapper.java:150 com.facebook.react.bridge.JavaModuleWrapper.invoke NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run Handler.java:883 android.os.Handler.handleCallback Handler.java:100 android.os.Handler.dispatchMessage MessageQueueThreadHandler.java:26 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage Looper.java:237 android.os.Looper.loop MessageQueueThreadImpl.java:225 com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run Thread.java:919 java.lang.Thread.run`

React Native Info System: OS: macOS 10.15.6 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 17.43 MB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.6.0 - ~/n/bin/node npm: 6.14.6 - ~/n/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 28 Build Tools: 28.0.3 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64 IDEs: Xcode: 12.0/12A7209 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5

github-actions[bot] commented 3 years ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.
ulbekovad commented 3 years ago

Hello,

We see that there are 721 crashed for 599 users. 48% of crashes are in the background. 68% cases are for Android 10 and 26% of crashes are for Android 9.

We are working on reproducing the issue. Please inform if any more information is required. Thanks!

chrisglein commented 3 years ago

Hello,

We see that there are 721 crashed for 599 users. 48% of crashes are in the background. 68% cases are for Android 10 and 26% of crashes are for Android 9.

We are working on reproducing the issue. Please inform if any more information is required. Thanks!

Without a repro there's nothing we're going to be able to do from the core React Native perspective. If you get this reduced to a min repo let us know.

SamuelBrucksch commented 2 years ago

I don't have a reproducable sample but i can reproduce it in an app with code like this, maybe someone else can make a reproducable sample out of it:

in index.ts:

AppRegistry.registerComponent("appName", () => AppComponent);

And in Android:

            CatalystInstance catalystInstance = reactContext.getCatalystInstance();
            String jsAppModuleName = "appName";

            WritableNativeMap appParams = new WritableNativeMap();
            appParams.putInt("rootTag", 1);
            @Nullable Bundle appProperties = Bundle.EMPTY;
            if (appProperties != null) {
                appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
            }

            catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);

I'm currently trying to start the app component from within Android Auto if the app is not started yet. Maybe that helps in identifying the other issues a bit. Not sure if my code should be able to work...

SamuelBrucksch commented 2 years ago

I just noticed this also happen when calling AppRegistry.runApplication() from JS, if the app is not started yet and thus no root component mounted yet. This happens for example if the app is closed, and then from an Android Service the RN part of the app is started.

So what is the correct way of starting the RN app from a Service in the same way as the app starts? For example I have following index.js:

AppRegistry.registerComponent("app", () => App);

AppRegistry.registerRunnable("androidAuto", () => {
  if (app is not running) {
    AppRegistry.runApplication("app", {rootTag: 1})
  }
  // ... do some android auto specific stuff that re-uses logic in app
})

From Android Service code we then invoke runApplication("androidAuto") which starts the runnable, which should also start the app logic to send data to Android Auto display.

If the app is already started, this works (not sure if runApllication does anything specific in that case). But if you force close the app or swipe it away and then start Android Auto (or any other native Andriod service) and then from the Service you want to get access to the logic of the app, as Android Auto is just another component to be drawn with the same app logic, the app crashes with the same error as above.

So is there a way to start the App in background when display is off, but started from somewhere else? When i push the app to the phone for the first time, the app also starts, so i guess there should be some way to do this.

github-actions[bot] commented 1 year ago

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

ulbekovad commented 1 year ago

Hello @SamuelBrucksch , Thank you for provided example. This seems to be valid one. It may occur when the mobile application is opening via URL and the application itself is not running at the time when the link is clicked. Please continue investigation on the root cause and possible fix resolution.

Thanks!

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 7 months ago

This issue was closed because it has been stalled for 7 days with no activity.