React-native: android crash

Created on 16 May 2017  ·  37Comments  ·  Source: facebook/react-native

RN .44, Android is crashing a lot. iOS is fine.

This is the crash report from BugSnag. I have no idea what is happening, or (more importantly) how I can stop these crashes.

Any feedback would be greatly appreciated.

com.facebook.react.uimanager.IllegalViewOperationException Trying to remove a view index above child count 38 view tag: 776
 detail: View tag:776
  children(38): [
15984,777,792,820,834,876,890,905,919,934,948,963,977,1658,1673,1687,
1818,1833,1847,1868,1883,1897,1918,1933,1947,1969,1984,1998,2019,2034,2048,2069,
2084,2098,2119,2134,15998,2148,
 ],
  indicesToRemove(1): [
38,
 ],
  tagsToDelete(1): [
15998,
 ]

    NativeViewHierarchyManager.java:345 com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren
    UIViewOperationQueue.java:179 com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute
    UIViewOperationQueue.java:787 com.facebook.react.uimanager.UIViewOperationQueue$2.run
    UIViewOperationQueue.java:843 com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches
    UIViewOperationQueue.java:48 com.facebook.react.uimanager.UIViewOperationQueue.access$1600
    UIViewOperationQueue.java:889 com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded
    GuardedFrameCallback.java:31 com.facebook.react.uimanager.GuardedFrameCallback.doFrame
    ReactChoreographer.java:129 com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame
    ChoreographerCompat.java:107 com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame
    Choreographer.java:872 android.view.Choreographer$CallbackRecord.run
    Choreographer.java:686 android.view.Choreographer.doCallbacks
    Choreographer.java:618 android.view.Choreographer.doFrame
    Choreographer.java:860 android.view.Choreographer$FrameDisplayEventReceiver.run
    Handler.java:751 android.os.Handler.handleCallback
    Handler.java:95 android.os.Handler.dispatchMessage
    Looper.java:154 android.os.Looper.loop
    ActivityThread.java:6290 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    ZygoteInit.java:886 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
    ZygoteInit.java:776 com.android.internal.os.ZygoteInit.main
Locked

Most helpful comment

This needs to be re-opened.

All 37 comments

Could you also post sample code that reproduces this issue?

No... I can not provide code that reproduces this issue. If I could, I would not have the issue.

This is a random crash, that just happens when using the app. There is not particular screen where this happens, no combination of button presses that causes this. It just happens...

This is why I am throwing up a desperation issues in hopes someone knows what this crash report is saying/doing.

This crash has happened over 200 times on android devices, with only 40 testers.

The iOS app has over 2000 users and no crash reports, which leads me to believe this is an issue with the react-native framework...

It's likely in recycler view: see https://github.com/facebook/react-native/issues/9549

I would try to make certain that you really are deploying with React Native 0.44.0. Please show us the package.json Also check you development directory where package.json is located:

npm list | grep 'react-native@'
npm list | grep 'react@'

if you are not on unix try then:

npm -g ls --depth=0
or
npm -g ls --depth=1 // increase depth slowly until you see the actual packages installed start at 0.

make sure these really match what you have in package.json. It's possible you have older version of react or react-native and did not realize it. Sometimes npm does not really install the correct version even though it is in package.json

Also check your animation code and if any layouts have: shouldAnimateLayoutChildrenInView
which you can try removing and see if app still runs ok. I think it's either recycler view or unnecessary animation. Tell us exactly what kind of animations you are doing and if 'shouldAnimateLayoutChildrenInView' appears anywhere in your code or layouts? Do a search! thanks!

https://github.com/facebook/react-native/issues/9549 also suggest you might be trying to do something with recycler views and RN.

So we have three possibilities:

1) you are doing something funky with Recycler Views.
2) you are doing something funky with Animations.
3) it's just a matter that you are not really running latest react and react-native because npm installation in your development directory or during compilation for release.

Let us know what seems to be the case with your code! Thanks!

@dobrienlzd, thanks for the suggestions...I will remove all reference to the Animated library and test.

I can tell you this

1: Recycler Views do not exist in my project
2: shouldAnimateLayoutChildrenInView does not exist in my project.
3: I am using the Animated library for some very basic animations (I used this on many other production apps with no problems), but I'll try a test without this library.
4: I am running react-native: 0.44.0, and react: 16.0.0-alpha.6,

I guess you are using LayoutAnimation
This issue will be fixed in this PR https://github.com/facebook/react-native/pull/11962

I guess our crash is related also? Do we know cause of this?

com.facebook.react.uimanager.IllegalViewOperationException ViewManager for tag 151 could not be found 
    NativeViewHierarchyManager.java:106 com.facebook.react.uimanager.NativeViewHierarchyManager.resolveViewManager
    NativeViewHierarchyManager.java:314 com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren
    UIViewOperationQueue.java:179 com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute
    UIViewOperationQueue.java:787 com.facebook.react.uimanager.UIViewOperationQueue$2.run
    UIViewOperationQueue.java:843 com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches
    UIViewOperationQueue.java:48 com.facebook.react.uimanager.UIViewOperationQueue.access$1600
    UIViewOperationQueue.java:889 com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded
    GuardedFrameCallback.java:31 com.facebook.react.uimanager.GuardedFrameCallback.doFrame
    ReactChoreographer.java:129 com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame
    ChoreographerCompat.java:107 com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame
    Choreographer.java:793 android.view.Choreographer$CallbackRecord.run
    Choreographer.java:598 android.view.Choreographer.doCallbacks
    Choreographer.java:566 android.view.Choreographer.doFrame
    Choreographer.java:781 android.view.Choreographer$FrameDisplayEventReceiver.run
    Handler.java:810 android.os.Handler.handleCallback
    Handler.java:99 android.os.Handler.dispatchMessage
    Looper.java:189 android.os.Looper.loop
    ActivityThread.java:5535 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    Method.java:372 java.lang.reflect.Method.invoke
    ZygoteInit.java:950 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
    ZygoteInit.java:745 com.android.internal.os.ZygoteInit.main

We are not using LayoutAnimation anywhere is our codebase 🤔

Any dependencies that use it?

Maybe. Well maybe we just update to RN 0.45 when it is available and see if we get this crash anymore :) 14 crashes in total

[Android, RN 0.41.0] The same problem I have encountered. Here are some recent crash reports.

wx20170601-103031 2x

I removed Layout Animation and this stopped.

I am closing this because I know the culprit.

Thank you @stoffern

where did you removed layout animation ?

it happened with me because I make width:"80" instead ofwidth:80

I am still seeing this issue in React Native 0.49.3:-

10-30 10:57:15.239 8499-8499/? E/UncaughtException: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 13
                                                     detail: View tag:24
                                                      children(2): [
                                                    8,10,
                                                     ],
                                                      viewsToAdd(1): [
                                                    [2,13],
                                                     ],

                                                        at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:388)
                                                        at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:180)
                                                        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:815)
                                                        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:922)
                                                        at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(UIViewOperationQueue.java:47)
                                                        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:982)
                                                        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
                                                        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
                                                        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
                                                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:941)
                                                        at android.view.Choreographer.doCallbacks(Choreographer.java:755)
                                                        at android.view.Choreographer.doFrame(Choreographer.java:687)
                                                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:929)
                                                        at android.os.Handler.handleCallback(Handler.java:751)
                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                        at android.os.Looper.loop(Looper.java:154)
                                                        at android.app.ActivityThread.main(ActivityThread.java:6334)
                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Hi all,

I too faced this issue, after commenting this "LayoutAnimation.easeInEaseOut();" the issue got resolved automatically.
If possible can anyone share the reason behind this solution?

Thanks in advance.
D.Raja Sekar

Same issue on RN 49, with LayoutAnimation on Android

We fixed this same issue by removing experimental layout animations

// UIManager.setLayoutAnimationEnabledExperimental(true);

Same on NR 0.50.4 with Oppo A37f and Android 5.1

@solartcc 我们也遇到类似的问题,这个问题在我们使用了react-native-navigation这个导航库之后大量出现

Hi,

Any solution to this problem? It causes random crash on the app.

My workaround is to detect device model (using RN device-info library) and disable layout animations for particular devices.

This issue is occurring for me on RN 0.46.3. Over 2000 users have seen this crash in my app. This is <1% of total users, but still very significant. It is rare and I haven't been able to recreate it in a controlled environment. I am using LayoutAnimation.

@parkerdan Could you please re-open this issue. It has not been resolved. It is good that you found a work-around by not using LayoutAnimation, but this is still a bug that should be addressed, right?

I am also getting this error on Android in RN 0.51.0. Where do I remove LayoutAnimation from? I'm not using LayoutAnimation in my main codebase, but it's referenced many, many times in node_modules.

This needs to be re-opened.

Same issue on RN 50.1, with LayoutAnimation on Android.

I found a workaround for my case. I had lines like these in render:

(this.props.condition && <View><Text>asdf</Text></View>)

And for some reason layout animation cannot remove this View so I just place it with and empty View

(this.props.condition ?
  <View><Text>asdf</Text></View>
  :
  <View></View>
)

Same issue RN 51.0 @Gumija I change all my conditions but not work. Any solution?

For me it seams that bumping compileSdkVersion and targetSdkVersion to 26 seams to fix this issue. Unfortunately I needed to revert back to 25 because other issues.

@paruckerr you can try removing tags from your code to see which one causes the issue and figure out a solution from there

@Gumija Works for me!! Thank you 💃

Can anyone manage to fix this problem?

@Gumija I just remove all items in .babelrc file and fixed the problem, thanks for response.

{
"presets": ["react-native"]
}

com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 236
at com.facebook.react.uimanager.f._61_a(UIImplementation.java:480)
at com.facebook.react.uimanager.UIManagerModule.setChildren(UIManagerModule.java:439)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge._61_q._61_a(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at com.facebook.react.bridge.queue._61_a.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:166)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:784)

Was this page helpful?
0 / 5 - 0 ratings