facebook / react-native

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

Seems to fix the issue: App crashes randomly on Android 12 with JSApplicationIllegalArgumentException: Animated node with tag ### does not exists #36921

Closed Heavn13 closed 1 year ago

Heavn13 commented 1 year ago

Description

--------- beginning of crash 04-12 19:49:52.991 E/AndroidRuntime(14081): FATAL EXCEPTION: main 04-12 19:49:52.991 E/AndroidRuntime(14081): Process: com.mobileapprn.selfcare, PID: 14081 04-12 19:49:52.991 E/AndroidRuntime(14081): com.facebook.react.bridge.JSApplicationIllegalArgumentException: Animated node with tag 2869 does not exists 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.animated.m.h(Unknown Source:83) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.animated.NativeAnimatedModule$f.a(Unknown Source:38) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.animated.NativeAnimatedModule.executeAllOperations(Unknown Source:75) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.animated.NativeAnimatedModule.access$400(Unknown Source:0) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.animated.NativeAnimatedModule$p.a(Unknown Source:8) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.w0$t.execute(Unknown Source:8) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.w0$a.run(Unknown Source:135) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.w0.U(Unknown Source:53) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.w0.s(Unknown Source:0) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.w0$j.c(Unknown Source:31) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.uimanager.f.a(Unknown Source:0) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.modules.core.g$d.a(Unknown Source:46) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.facebook.react.modules.core.a$a$a.doFrame(Unknown Source:2) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1447) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.view.Choreographer.doCallbacks(Choreographer.java:1165) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.view.Choreographer.doFrame(Choreographer.java:1049) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1417) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.os.Handler.handleCallback(Handler.java:966) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.os.Handler.dispatchMessage(Handler.java:110) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.os.Looper.loopOnce(Looper.java:205) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.os.Looper.loop(Looper.java:293) 04-12 19:49:52.991 E/AndroidRuntime(14081): at android.app.ActivityThread.main(ActivityThread.java:9596) 04-12 19:49:52.991 E/AndroidRuntime(14081): at java.lang.reflect.Method.invoke(Native Method) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586) 04-12 19:49:52.991 E/AndroidRuntime(14081): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1204)

React Native Version

0.64.2

Output of npx react-native info

System: OS: Windows 10 10.0.19044 CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz Memory: 12.29 GB / 31.84 GB Binaries: Node: 14.9.0 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 28, 29, 30, 31 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-30 | Google API s Intel x86 Atom, android-31 | Intel x86 Atom_64, android-31 | Google TV Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64, android-32 | Google APIs Intel x86 Atom_64 Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 4.1.0.0 AI-201.8743.12.41.6858069 Visual Studio: Not Found Languages: Java: 1.8.0_262 - C:\Program Files\Huawei\jdk1.8.0_262\bin\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.64.2 => 0.64.2 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

App crashes randomly in Android

Snack, code example, screenshot, or link to a repository

Our team analyze lots of crash log, found that:

  1. Every UIThreadOperation will be added to mOperations, and then execute all UIThreadOperation in the executeAllOperations method.
  2. Normally, mOperations will poll the createAnimatedNode UIThreadOperation first and then poll the connectAnimatedNodes UIThreadOperation. But for the crash scenario, the createAnimatedNode UIThreadOperation is lost strangely. Like this:

executeAllOperations current operationQueue: [ mBatchNumber: 1154, nodeId: 2712, addFrom: createAnimatedNode] ... [ mBatchNumber: 1154, nodeId: 2869, addFrom: createAnimatedNode][ mBatchNumber: 1154, nodeId: 2869, addFrom: connectAnimatedNodes]...

UIThreadOperation polledOperation = operationQueue.poll();
if (polledOperation == null) {
  return;
}

When polling UIThreadOperation from mOperations, only got:

04-12 19:49:52.991 D/NativeAnimatedModule(14081): executeAllOperations polledOperation nodeId: 2869 addFrom: connectAnimatedNodes but lost the createAnimatedNode UIThreadOperation which cause the crash, the lost log like this: 04-12 19:49:52.991 D/NativeAnimatedModule(14081): executeAllOperations polledOperation nodeId: 2869 addFrom: createAnimatedNode

When finding the root cause, we tried many methods to fix this issue, finally, we seems to use this method can fix this issue:

image

I hope this can help everyone who faced this crash issue.

related to #33375

github-actions[bot] commented 1 year ago
:warning: Unsupported Version of React Native
:information_source: It looks like your issue or the example you provided uses an unsupported version of React Native. Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.
bhavzie commented 1 year ago

We are on 0.69.7 and are still facing this crash on Android 12

cortinico commented 1 year ago

Closing as a duplicate of: