-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
IllegalViewOperationException: Trying to add unknown view tag #2892
Comments
I am also experiencing this issue in production, but couldn't reproduce it either. Research pointed to some different solutions (see facebook/react-native#17178):
One comment also suggested to apply a patch to react-native-navigation, however it seems that the specified line is not present in the current version of react-native-navigation anymore (see facebook/react-native#14944 (comment)). |
|
Is anyone else also using this code? Maybe it's related to this issue? #2043 (comment) @Override
public boolean clearHostOnActivityDestroy() {
return false;
} Navigation.isAppLaunched().then((appLaunched) => {
if (appLaunched) {
app();
}
new NativeEventsReceiver().appLaunched(() => {
app();
});
} |
@brunolemos I am indeed using this code. I did observe the "Trying to add unknown view tag" error in versions before using this code, but it seems like it is occuring more frequently recently. |
This appears to be a tough one to crack. We're seeing this crash as well in the Wix app which uses v1. |
If you ever figure the cause of this please ping me, that's something I've been struggling with for a while now. Looks like a child view that is not created yet by I think that's a timing issue, where the view is not created yet (or it's destroyed for some reason) but setChildren runs prematurely, but that is just my guess. |
@SudoPlz I just encountered this problem, and after a few minutes of digging, I realized that I was using raw text, instead of containing them inside of a render(){
return (
<Container>
<Grid>
<Row>
<Col>
Cell 1
</Col>
<Col>
Cell 2
</Col>
</Row>
</Grid>
</Container>
)
} vs render(){
return (
<Container>
<Grid>
<Row>
<Col>
<Text>Cell 1</Text>
</Col>
<Col>
<Text>Cell 2</Text>
</Col>
</Row>
</Grid>
</Container>
)
} |
I really don't believe I have that on my code, I use In my case, based on my screen change logs, I'd guess it's related to react-native-gifted-chat or react-native-vector-icons. |
I have one line like this: |
After taking a closer look on bugsnag, it seems it happens when the device stays in background for some time and then crashes when trying to go to foreground. In my case, when in background, the chat screen keeps updating with new messages, so that may be related. Anyone have a similar situation? |
@jshearer I wonder if we could build a script to detect those cases.. I can't think of a smart way to do that. Though I think raw text outside a Text element might be ONE thing that causes it, I'm sure there are other causes too. |
@brunolemos We've observed this error running Detox e2e tests on v2. It seems like a synchronisation issue... but we really hit a wall trying to debug this. |
i solved it by changing this: |
@fcaride That's brilliant. You just made me realize that |
Yes you are right. Glad it helps! 😄 |
@guyca I managed to spot exactly what's causing that problem in So what happens behind the scenes is, Specifically UIImplementation manipulates that list with the following methods
so if any of those get invoked at the same time, there's a really high chance that the app will crash. In our app we fixed that issue by providing a new UIImplementation that looks like this: https://gist.github.com/SudoPlz/23ea2dee9772cb39e1e742034cdf8b98 as you can see we don't allow those UIImplementation methods to run unsynchronised anymore. We could constantly reproduce the issue on our end, but now that's totally fixed. I had to expose it manually here to make this all work. I hope this post helps others, because it really took me A CRAZY amount of time to figure this out. |
@SudoPlz Can you make a PR? |
@brunolemos I can definitely do that, but it won't be accepted. No pr's are accepted on v1 since the team is focusing on v2, and I don't think many people are using v2 at the moment. (I know we aren't) The |
@SudoPlz they may accept this one as they faced this issue themselves
That's a bad combination |
I'll wait for @guyca to comment on this, since I'm 99% sure they won't be accepting such a PR at the moment. (I already have 2 other pr's waiting that won't be accepted either) |
It seems Android doesn't like converting non-Boolean values into booleans. So I'm now ensuring that all values which I'm using as booleans are in fact, booleans. I have changed all occurrences similar to this where
…into one of these which converts
|
@guyca NavigationApplication's |
…lstack#469) reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
@guyca The removal of UIImplementationProvider in 0.57 means this solution is no longer valid correct? Unless this issue is no longer present in RN0.57? We're both trying to deal with this problem and also upgrade an app to RN0.57 and it's unclear to me how to do both. |
Summary: @public This diff deprecates and deletes the UIImplementationProvider class. It is not required to create an UIImplementation provider anymore, from now on the UIImplementation is created inside the UIManagerModule. If you are using the UIImplementationProvider to create a ReactInstanceManager e.g.: ``` ReactInstanceManager = getReactInstanceManagerBuilder() ... .setUIImplementationProvider(...) ... .build(); ``` Then you should just remove that line: ``` ReactInstanceManager = getReactInstanceManagerBuilder() .set..... .build(); ``` Reviewed By: achen1 Differential Revision: D8650376 fbshipit-source-id: 8d883295d8bf6578a99685edf6a2a84c6d0df0cf
@dev6james We're planning on migrating to RN 0.57 during the month of Octobre, hope to have an answer soon. |
May be it was fixed in this commit facebook/react-native@dc83678#diff-e40bcf61507821200dcf1f573eb717e3 |
I doubt it. It's been a long time since I last worked on this, but I remember it wasn't just That means |
@SudoPlz how do you re-create that crash? I have upgraded to 0.57.2 with a patched version of RNN 2.0.2555 and not seen any reports of this crash? |
I'm afraid I don't have a way of re-creating that crash in a simple react-native project. In our project, we can re-create that by synchronously/manually creating |
You can also run RNN's e2e tests, after one or two runs you'll encounter the crash |
Oh what @guyca suggests is sooooo much better, I didn't know there were tests for that as well. Awesome! |
@makirby also I think there's this replication project here https://github.com/Frank1234/RNViewPager (I didn't create it, but looks like you can steadily replicate the crash by tapping the button a couple of times) |
Oh by the way, the guys in react-native are adding back the UIImplementation overwrites so v2 can work with 0.57 and above (at least until the fabric re-architecture goes live). |
@SudoPlz Thanks for that, good news to hear. I am worried as to why I haven't been able to re-create with our codebase. Anyway I guess i will just hold tight until it gets re-implemented in React Native. |
@guyca Looks like UIImplementation was re-added in this commit facebook/react-native@b002df9 but it's only available in the master branch for the time being. |
Yup, we're trying to have FB publish a patch with this fix but everybody is too busy at React Conf 😅 |
Just in case someone else lands here and none of the above works I will add what worked for me. |
the re-addition of |
I also faced this issue, and figured it was caused by having a conditional statement resulting in '#000' OR null, which was used to define backgroundColor on the style of a View. Changing the false result from null to '#fff' solved the issue. |
I believe @SudoPlz had a fix merged to React Native Core for this in a recent patch version? Is that correct? |
Yep, that was merged but I believe it will go live with RN .60 |
reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
reference: wix/react-native-navigation#2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
I meet same error with RN 0.72.5. I have no idea to deal with it, pls help ! |
Issue Description
1% of the users are facing this crash. Do you have any idea what could it be?
I noticed most of these users had this weird behavior of
ActivityLifecycle
being triggered multiple times at the same time (onDestroy()
,onStop()
,onResume()
,onStart()
,onCreate()
, etc). What could cause this?Stack points to https://github.com/facebook/react-native/blob/353c070be9e9a5528d2098db4df3f0dc02d758a9/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java#L479 but I didn't have this before migrating to react-native-navigation afaik.
Steps to Reproduce / Code Snippets / Screenshots
Could not reproduce, but maybe you could give some insights.
Environment
The text was updated successfully, but these errors were encountered: