facebook / react-native

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

Android App Crash with `Animated node with tag (child) [xxxx] does not exists` #37267

Open cortinico opened 1 year ago

cortinico commented 1 year ago

I was able to create a reproducible example in a test build where I added 20 swimlanes of which 2 out of 3 randomly animate, the screen is quite heavy but if you navigate a few times the app eventually crashes quite quickly with little effort.

Mostly with this exception:

04-27 13:20:21.717 27102 27102 E AndroidRuntime: FATAL EXCEPTION: main
04-27 13:20:21.717 27102 27102 E AndroidRuntime: Process: io.evix.reactnativetvexample, PID: 27102
04-27 13:20:21.717 27102 27102 E AndroidRuntime: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [5998] does not exist
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:346)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedModule$16.execute(NativeAnimatedModule.java:751)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:147)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:332)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.view.Choreographer.doCallbacks(Choreographer.java:845)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.view.Choreographer.doFrame(Choreographer.java:775)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7839)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
04-27 13:20:21.717 27102 27102 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

But sometimes also with this one:

04-27 13:18:32.957 26938 26938 E AndroidRuntime: FATAL EXCEPTION: main
04-27 13:18:32.957 26938 26938 E AndroidRuntime: Process: io.evix.reactnativetvexample, PID: 26938
04-27 13:18:32.957 26938 26938 E AndroidRuntime: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mapped property node does not exists
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedModule$1.doFrameGuarded(NativeAnimatedModule.java:230)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.view.Choreographer.doCallbacks(Choreographer.java:845)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.view.Choreographer.doFrame(Choreographer.java:775)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7839)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
04-27 13:18:32.957 26938 26938 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Mapped property node does not exists
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.animated.PropsAnimatedNode.updateView(PropsAnimatedNode.java:100)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedNodesManager.updateNodes(NativeAnimatedNodesManager.java:690)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedNodesManager.runUpdates(NativeAnimatedNodesManager.java:597)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    at com.facebook.react.animated.NativeAnimatedModule$1.doFrameGuarded(NativeAnimatedModule.java:214)
04-27 13:18:32.957 26938 26938 E AndroidRuntime:    ... 15 more

Both seem to originate from NativeAnimatedNodesManager.java.

https://user-images.githubusercontent.com/1210628/234848355-ed5b4d7c-8d4d-43fe-bba7-286567cbc70b.mp4

A reproducible example can be found here: https://github.com/wouterds/react-native-tv-example/tree/bug/animation-crash

I can't attach the .apk because it's above the limits of GitHub file upload, but crashlog, video & apk can be found here: https://drops.evix.io/rn-crash-connectAnimatedNodes/

Originally posted by @wouterds in https://github.com/facebook/react-native/issues/33686#issuecomment-1525541443

JacobFJ commented 1 year ago

@nikhiltekwani09 without reproducer it is impossible to fix this, although this maybe related and limited only for Android 12

freeboub commented 1 year ago

I have been using the patch I have provided for 1 month now. I can assume it fixes the issue. We are 10 people working on android tv 12 ONLY (I don't count customers) we don't see the crash anymore and no 'strange' behavior happens. I can say it is safe.

Note: a similar patch shall be applied on react-native-reanimated

mqueiroz1995 commented 1 year ago

but as I understood from @cortinico that is not good enough as reproducible example.

@wouterds , @cortinico , would you mind expanding on what would be a good enough repro example?

wouterds commented 1 year ago

@wouterds , @cortinico , would you mind expanding on what would be a good enough repro example?

A simple vanilla React Native project, I've tried something but so far unable to reproduce → https://github.com/wouterds/react-native-animated-nodes-crash-example

sebas21 commented 1 year ago

Friends, is there a temporary solution???, we are affecting too many users with this bug..

These are the devices that are affected

image image

LOGS: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [119] does not exist at com.facebook.react.animated.l.h(Unknown Source:53) at com.facebook.react.animated.NativeAnimatedModule$f.a(Unknown Source:4) at com.facebook.react.animated.NativeAnimatedModule.executeAllOperations(Unknown Source:31) at com.facebook.react.animated.NativeAnimatedModule.access$400(Unknown Source:0) at com.facebook.react.animated.NativeAnimatedModule$p.a(Unknown Source:8) at com.facebook.react.uimanager.x0$t.d(Unknown Source:8) at com.facebook.react.uimanager.x0$a.run(Unknown Source:135) at com.facebook.react.uimanager.x0.U(Unknown Source:53) at com.facebook.react.uimanager.x0.s(Unknown Source:0) at com.facebook.react.uimanager.x0$j.c(Unknown Source:31) at com.facebook.react.uimanager.f.a(Unknown Source:0) at com.facebook.react.modules.core.g$d.a(Unknown Source:46) at com.facebook.react.modules.core.a$a$a.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103) at android.view.Choreographer.doCallbacks(Choreographer.java:896) at android.view.Choreographer.doFrame(Choreographer.java:810) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7881) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)


java.lang.IllegalArgumentException: Invalid parent node provided at com.facebook.react.animated.i.c(Unknown Source:12) at com.facebook.react.animated.b.f(Unknown Source:5) at com.facebook.react.animated.l.k(Unknown Source:22) at com.facebook.react.animated.NativeAnimatedModule$g.a(Unknown Source:4) at com.facebook.react.animated.NativeAnimatedModule.executeAllOperations(Unknown Source:31) at com.facebook.react.animated.NativeAnimatedModule.access$400(Unknown Source:0) at com.facebook.react.animated.NativeAnimatedModule$p.a(Unknown Source:8) at com.facebook.react.uimanager.x0$t.d(Unknown Source:8) at com.facebook.react.uimanager.x0$a.run(Unknown Source:135) at com.facebook.react.uimanager.x0.U(Unknown Source:53) at com.facebook.react.uimanager.x0.s(Unknown Source:0) at com.facebook.react.uimanager.x0$j.c(Unknown Source:31) at com.facebook.react.uimanager.f.a(Unknown Source:0) at com.facebook.react.modules.core.g$d.a(Unknown Source:46) at com.facebook.react.modules.core.a$a$a.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103) at android.view.Choreographer.doCallbacks(Choreographer.java:896) at android.view.Choreographer.doFrame(Choreographer.java:810) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7886) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

first of all, Thanks

redpanda-bit commented 1 year ago

Friends, is there a temporary solution???, we are affecting too many users with this bug..

These are the devices that are affected image

image

LOGS: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [119] does not exist at com.facebook.react.animated.l.h(Unknown Source:53) at com.facebook.react.animated.NativeAnimatedModule$f.a(Unknown Source:4) at com.facebook.react.animated.NativeAnimatedModule.executeAllOperations(Unknown Source:31) at com.facebook.react.animated.NativeAnimatedModule.access$400(Unknown Source:0) at com.facebook.react.animated.NativeAnimatedModule$p.a(Unknown Source:8) at com.facebook.react.uimanager.x0$t.d(Unknown Source:8) at com.facebook.react.uimanager.x0$a.run(Unknown Source:135) at com.facebook.react.uimanager.x0.U(Unknown Source:53) at com.facebook.react.uimanager.x0.s(Unknown Source:0) at com.facebook.react.uimanager.x0$j.c(Unknown Source:31) at com.facebook.react.uimanager.f.a(Unknown Source:0) at com.facebook.react.modules.core.g$d.a(Unknown Source:46) at com.facebook.react.modules.core.a$a$a.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103) at android.view.Choreographer.doCallbacks(Choreographer.java:896) at android.view.Choreographer.doFrame(Choreographer.java:810) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7881) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

java.lang.IllegalArgumentException: Invalid parent node provided at com.facebook.react.animated.i.c(Unknown Source:12) at com.facebook.react.animated.b.f(Unknown Source:5) at com.facebook.react.animated.l.k(Unknown Source:22) at com.facebook.react.animated.NativeAnimatedModule$g.a(Unknown Source:4) at com.facebook.react.animated.NativeAnimatedModule.executeAllOperations(Unknown Source:31) at com.facebook.react.animated.NativeAnimatedModule.access$400(Unknown Source:0) at com.facebook.react.animated.NativeAnimatedModule$p.a(Unknown Source:8) at com.facebook.react.uimanager.x0$t.d(Unknown Source:8) at com.facebook.react.uimanager.x0$a.run(Unknown Source:135) at com.facebook.react.uimanager.x0.U(Unknown Source:53) at com.facebook.react.uimanager.x0.s(Unknown Source:0) at com.facebook.react.uimanager.x0$j.c(Unknown Source:31) at com.facebook.react.uimanager.f.a(Unknown Source:0) at com.facebook.react.modules.core.g$d.a(Unknown Source:46) at com.facebook.react.modules.core.a$a$a.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103) at android.view.Choreographer.doCallbacks(Choreographer.java:896) at android.view.Choreographer.doFrame(Choreographer.java:810) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7886) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

first of all, Thanks

@sebas21 There were two temporary solutions provided above 1 and 2 with number 2 having a promising follow up.

if none of those work I would change the UI to not use the animation causing the crash – some users might prefer not to be distracted by motion anyway.

wouterds commented 1 year ago

"Don't use animations" is a ridiculous suggestion, animations are of paramount importance to UX.
Let's think and try to find a solution instead.

Besides that, and as mentioned multiple times before, it's not only *your* animations. It's any animation by any library. Going that route requires you to find every reference of useNativeDriver in your node_modules and patch all your third-party libs.

It also affects the little things like navigation animations. It's a very poor UX, I tried it (in production) and it does reduce the crash rate a lot, but the app feels very cheap & unprofessional.

sebas21 commented 1 year ago

"Don't use animations" is a ridiculous suggestion, animations are of paramount importance to UX. Let's think and try to find a solution instead.

Besides that, and as mentioned multiple times before, it's not only your animations. It's any animation by any library. Going that route requires to to find every reference of useNativeDriver in your node_modules and patch all your third party libs. It also affect the little things like navigation animations. It's a very poor UX, I tried it (in production) and it does reduce the crash-rate a lot, but the app feels very cheap & unprofessional.

@wouterds Okay, I can't change the UI because of this.

But to mitigate this crash I must apply this patch https://github.com/wouterds/react-native-tv-example/commit/7639c26c468a2e4f4f51ee728b040e989a8fff0d#comments, for version 0.69.5 and ¿Do I need to do something else additional?

The truth is that I have not been able to replicate this crash in my tests so I don't know if it solved it or not, but I have many crashes in production.

JacobFJ commented 1 year ago

@sebas21, actually, the suggested fix is not really fixed. As I mentioned in my previous comment, this issue is actually a device-specific issue, and not all Android 12 devices crashed. I will take the suggestion as a monkey patch solution that does not totally resolve the issue. It will only make them invisible to Crashlytics or any crash monitoring tool.

Once you apply it, the user will suffer cause your app will not able to navigate to any screen and it usually it same behavior of having ANR.

https://github.com/wouterds/react-native-tv-example/commit/7639c26c468a2e4f4f51ee728b040e989a8fff0d#comments

CC: @wouterds @carlosalmonte04

wouterds commented 1 year ago

To give a summary from those comments on that commit (https://github.com/wouterds/react-native-tv-example/commit/7639c26c468a2e4f4f51ee728b040e989a8fff0d#comments) where I tried out the patch of @yrichard, it's not good enough. The app still crashes, the crash just occurs somewhere else higher up because we're ignoring it there. It's not a working workaround, nor a fix.

JacobFJ commented 1 year ago

Thanks, @wouterds, for clarification.

@sebas21, I would suggest this: https://github.com/facebook/react-native/pull/37927 since many apps, including mine, are solve the crash totally as we can replicate it on a specific set of real devices, including TVOS. We used it already for one month on a production setup but we tweak it to only use the LinkedBlockingQueue in Android 12, and so far there has been no performance degradation. This is not a totally concrete solution, but it has completely mitigate any crashes related to the animated node.

ref: https://issuetracker.google.com/issues/261481042

Biplovkumar commented 1 year ago

+1

"react": "18.2.0", "react-native": "0.72.4",

1
sebas21 commented 12 months ago

These are the patches applied for RN 0.71.13

react-native-camera+4.2.1.patch react-native-reanimated+2.17.0.patch react-native+0.71.13.patch

any suggestion welcome!

wesvh commented 12 months ago

@sebas21 , you have a patch for "react-native": "0.70.8"?

I try, but public class MountItemDispatcher, on react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java

Its so different in thoose versions

sebas21 commented 12 months ago

@sebas21, ¿tienes un parche para "react-native": "0.70.8"?

Lo intento, pero la clase pública MountItemDispatcher, en react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java

Es tan diferente en esas versiones.

@wesvh Friend no, but you can take the file as a reference or already where they cited the change https://github.com/facebook/react-native/pull/37927

DevHisham commented 11 months ago

i am encounter same issue is there any solution ?

wouterds commented 11 months ago

@cortinico How do we move forward? Clearly, nobody is able to create a simple vanilla app to reproduce the issue. The next best thing we have, at this moment, is the example repository/branch linked in the original post. Isn't that sufficient to get started? It's reproducible within 20 seconds on those cheap $50 Android TV boxes from Amazon (running Android 12).

Biplovkumar commented 11 months ago

@sebas21 Patch is not a solution.solution will come with next version. Will wait. thanks for the quick reply.

RodolfoGS commented 11 months ago

Same issue, react-native 0.72.4, 100% Android 12.

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [66] does not exist
       at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:364)
       at com.facebook.react.animated.NativeAnimatedModule$16.execute(NativeAnimatedModule.java:777)
       at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:171)
       at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:365)
       at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
       at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches()
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103)
       at android.view.Choreographer.doCallbacks(Choreographer.java:896)
       at android.view.Choreographer.doFrame(Choreographer.java:810)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7881)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
skantus commented 11 months ago

Same issue, react-native 0.72.4, 100% Android 12.

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [66] does not exist
       at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:364)
       at com.facebook.react.animated.NativeAnimatedModule$16.execute(NativeAnimatedModule.java:777)
       at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:171)
       at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:365)
       at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
       at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches()
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1103)
       at android.view.Choreographer.doCallbacks(Choreographer.java:896)
       at android.view.Choreographer.doFrame(Choreographer.java:810)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1090)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7881)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

Hey @RodolfoGS, which device model is this one?

RodolfoGS commented 11 months ago

@skantus all are low tech devices, brands:

kamui545 commented 11 months ago

This issue is happening on Android 12 only as well for us, mainly on Vivo devices. Here's the list:

lfrodrigues commented 11 months ago

We operate only in Africa and I can confirm we only see this crash on Android 12.

We are not able to reproduce the crash and from our logs it happens in random places. If a user opens the app after the crash it might not happen again.

Here are the devices in case it helps:

Transsion Mediatek - 27%

Transsion Unisoc — 34%

Transsion other — 27%

Samsung — 7%

sebas21 commented 11 months ago

@sebas21 El parche no es una solución. La solución vendrá con la próxima versión. Esperará. Gracias por la rápida respuesta.

@Biplovkumar This post is from May and I have too many affected clients so I couldn't wait for an official fix, and my fix was the patch.

lucasoliveiracruz commented 11 months ago

@sebas21, I'd like to apply your solution to patch my application. Could you please share if you've noticed any improvement in your production app after applying these patches? Has the problem been resolved for you?

I'm still experiencing a significant number of errors daily, specifically on Android 12 devices like:

Additionally, I attempted to reproduce the crash using an Android 12 emulator, but unfortunately, I wasn't able to replicate it :/.

alzalabany commented 11 months ago

@lucasoliveiracruz thats the patch mentioned in react-native pull request. yet take it with grain of salt better test because it replace the none-blocking Queue with a blocking one


diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
index 76749aa..018c06b 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
@@ -37,7 +37,7 @@ import com.facebook.react.uimanager.common.ViewUtil;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.atomic.AtomicReference;

 /**
@@ -149,7 +149,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
   }

   private class ConcurrentOperationQueue {
-    private final Queue<UIThreadOperation> mQueue = new ConcurrentLinkedQueue<>();
+    private final Queue<UIThreadOperation> mQueue = new LinkedBlockingQueue<>();
     @Nullable private UIThreadOperation mPeekedOperation = null;

     @AnyThread
gnair03 commented 11 months ago

We are also facing this issue throughout our ReactNative Android app. We deduced the screens in which the crash occurred, using Crashlytics and analytic events. The first goal was to zero-in on the component (in the screen) that caused the crash. To do this,

This process of debugging can help you zero-in on the component/prop that causes this crash. And then take the next steps to solve it.

Hope this helps!

carlosvstokkur commented 11 months ago

I'm experiencing this on Android 13, mainly Samsung devices.

React Native: 0.72.3

sagarj-iprogrammer commented 11 months ago

After applying the patch, it still crash exist and patch is not applied in the release build after decompile the release apk

dngconsulting commented 11 months ago

same problem here with Android 12 Redmi A1.

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [686] does not exist at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:369) at com.facebook.react.animated.NativeAnimatedModule$16.execute(NativeAnimatedModule.java:800) at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:191) at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:381) at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026) at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086) at com.facebook.react.uimanager.GuardedFrameCa

lfoliveir4 commented 11 months ago

These are the patches applied for RN 0.71.13

react-native-camera+4.2.1.patch react-native-reanimated+2.17.0.patch react-native+0.71.13.patch

any suggestion welcome!

@sebas21 This patches solve this issue completely?

varunraghu3112 commented 9 months ago

Any working solutions to temporarily fix this crash on Android 12 ?

freeboub commented 9 months ago

@varunraghu3112 the solution is available in the thread. I have used it for 3 months without issue. It really needs to be integrated, but as it is hard to reproduce the core team threatens to integrate it.

varunraghu3112 commented 9 months ago

@freeboub Which thread you are referring to ? so I can try to integrate and see how it behaves for our app, Thanks

React native version: 0.71.12

microinginer commented 9 months ago

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodeToView: Animated node with tag [231] does not exist at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodeToView(NativeAnimatedNodesManager.java:148) at com.facebook.react.animated.NativeAnimatedModule$18.execute(NativeAnimatedModule.java:4) at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:22) at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:14) at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:8) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:135) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:53) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:31) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:46) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1036) at android.view.Choreographer.doCallbacks(Choreographer.java:846) at android.view.Choreographer.doFrame(Choreographer.java:776) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1023) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7976) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Same problem, any solutions?

rezaarifian commented 8 months ago

@varunraghu3112 the solution is available in the thread. I have used it for 3 months without issue. It really needs to be integrated, but as it is hard to reproduce the core team threatens to integrate it.

which thread you are reffer ? we have to try in our project. RN version 0.70.9

freeboub commented 8 months ago

This patch fix the issue: https://github.com/facebook/react-native/issues/37267#issuecomment-1710155795 But you need to apply it manually and build from source.

sagarj-iprogrammer commented 8 months ago

This patch fixes the issue: #37267 (comment) But you need to apply it manually and build from the source.

can you help us with how to build from the source because after extracting the APK the patch disappears

rezaarifian commented 8 months ago

This patch fix the issue: #37267 (comment) But you need to apply it manually and build from source.

this patch still crash on my device testing (vivo Y15s Android 12). Does the patch only reduce crash reports on your project?

rezaarifian commented 8 months ago

This patch fixes the issue: #37267 (comment) But you need to apply it manually and build from the source.

can you help us with how to build from the source because after extracting the APK the patch disappears

you can implement the patch using patch-package

dprevost-LMI commented 8 months ago

This patch fixes the issue: https://github.com/facebook/react-native/issues/37267#issuecomment-1710155795 But you need to apply it manually and build from source.

Be aware that this can change performance significantly; someone already mentioned that, but the fix changes the queue from a concurrent one to a blocking one. Therefore, if you apply that patch, you will affect all users' performance, while you might fix those having the crash on Android 12. I'm waiting for a better fix; if I ever apply the above, I would do the queue change only for Android 12 users, IMHO.

rezaarifian commented 8 months ago

This patch fixes the issue: #37267 (comment) But you need to apply it manually and build from source.

Be aware that this can change performance significantly; someone already mentioned that, but the fix changes the queue from a concurrent one to a blocking one. Therefore, if you apply that patch, you will affect all users' performance, while you might fix those having the crash on Android 12. I'm waiting for a better fix; if I ever apply the above, I would do the queue change only for Android 12 users, IMHO.

no friend, the patch only implement LinkedBlockingQueue on android version 12. Other than that it is not affected. reffer patch on this

shaik41 commented 8 months ago

@freeboub @rezaarifian @sebas21 We're currently testing the patch and have a quick inquiry. Did you notice any performance changes after applying this fix? Have you conducted any profiling? As pointed out by @dprevost-LMI , while it's beneficial for reducing crashes on Android 12, we're concerned about the possibility of overall performance degradation, which may not justify the tradeoff.

We are on v0.69.7

Asad-wego commented 7 months ago

Hi React Native Team, @shaik41 @rezaarifian @redpanda-bit We're encountering a sporadic issue on "react-native": "^0.72.3" with the following error:

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [72] does not exist
       at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:53)
       at com.facebook.react.animated.NativeAnimatedModule$16.execute(NativeAnimatedModule.java:4)
       at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:22)
       at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:14)
       at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:8)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:135)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:53)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:31)

This issue seems to occur randomly and is challenging to reproduce consistently, making it difficult to pinpoint the root cause. We've received suggestions from different developers:

  1. Applying a patch may resolve the issue, but concerns about overall performance have been raised. https://github.com/facebook/react-native/issues/37267#issuecomment-1710155795
  2. Seeking insights on when the React Native team plans to address this. can you suggest any working solutions?
anniewey commented 7 months ago

@sebas21, ¿tienes un parche para "react-native": "0.70.8"? Lo intento, pero la clase pública MountItemDispatcher, en react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java Es tan diferente en esas versiones.

@wesvh Friend no, but you can take the file as a reference or already where they cited the change #37927

@Asad-wego or anyone can help to point out how to apply the patch for older react native version (0.67.4)? as the code is very different from the sample patch changes. and i'm not familiar with native codes. cant afford to upgrade the version as of now.

image
cristiano-linvix commented 7 months ago

Has anyone managed to resolve this problem?

lucasoliveiraw00 commented 7 months ago

I am going through the same situation, with over 42 thousand errors in a short period. Captura de Tela 2024-01-25 às 09 59 38 @cipolleschi

Lawanya-juakali commented 6 months ago

Any update guys ?? Going through a lot of crashes in a short span.

image

wesvh commented 6 months ago

Has anyone managed to resolve this problem?

I have tried multiple patches, like here https://github.com/react-native-tvos/react-native-tvos/pull/657

But, I notice a slow UI, which clearly affects the UX in my preliminary tests, although I have no more unexpected crashes, I feel that it should be something that is verified from the RN library itself, and if it is possible that it was backward compatible with previous versions by RN

TrustDec commented 5 months ago

The production environment on Android devices will crash.

"react-native": "0.71.16"

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: addAnimatedEventToView: Animated node with tag [11] does not exist
       at com.facebook.react.animated.NativeAnimatedNodesManager.addAnimatedEventToView(NativeAnimatedNodesManager.java:507)
       at com.facebook.react.animated.NativeAnimatedModule$21.execute(NativeAnimatedModule.java:924)
       at com.facebook.react.animated.NativeAnimatedModule$ConcurrentOperationQueue.executeBatch(NativeAnimatedModule.java:173)
       at com.facebook.react.animated.NativeAnimatedModule$3.execute(NativeAnimatedModule.java:359)
       at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1226)
       at android.view.Choreographer.doCallbacks(Choreographer.java:1012)
       at android.view.Choreographer.doFrame(Choreographer.java:917)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1213)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:334)
       at android.app.ActivityThread.main(ActivityThread.java:8513)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)