Open cortinico opened 1 year ago
My project also encountered so many crash issues from it every day. When will React Native officially fix it? com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodeToView: Animated node with tag [5] does not exist at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodeToView(Unknown Source:148) at com.facebook.react.animated.NativeAnimatedModule$17.execute(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$3.execute(Unknown Source:8) at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(Unknown Source:8) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(Unknown Source:135) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(Unknown Source:53) at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(Unknown Source:0) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(Unknown Source:31) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(Unknown Source:0) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(Unknown Source:46) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1238) at android.view.Choreographer.doCallbacks(Choreographer.java:1012) at android.view.Choreographer.doFrame(Choreographer.java:917) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1225) 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(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
I also get this error in production. "react-native": "0.73.6"
Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: connectAnimatedNodes: Animated node with tag (child) [3851] does not exist
at com.facebook.react.animated.NativeAnimatedNodesManager.connectAnimatedNodes(NativeAnimatedNodesManager.java:371)
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:926)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1037)
at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches()
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1097)
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: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:7986)
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)
My analysis data shows that all issues occur on Android 12.
react-native: 0.66.4
Solution:
export const USE_NATIVE_DRIVER = Platform.select({
ios: true,
android: Platform.constants?.Release !== '12',
default: true,
});
const { current: opacity } = useRef(
Animated.timing(initValue, {
toValue: 1,
duration: 1000,
easing: Easing.linear,
useNativeDriver: USE_NATIVE_DRIVER,
}),
)
Has anyone managed to resolve this problem? Users: 6.3k Events: 21k
Animated component of React Native
https://github.com/react-navigation/react-navigation/issues/11890#issuecomment-2090294675
@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
I was experiencing the same issue on android 12 Tecno BF6. This fixed it. Are there any performance implications for switching the queues?
@kimjisena : Yes, see https://github.com/facebook/react-native/issues/37267#issuecomment-1847209126. Even though I do not go into details. In short, linked queue is sequential instead of allowing concurrency so by design, it will be slower
@kimjisena : Yes, see #37267 (comment). Even though I do not go into details. In short, linked queue is sequential instead of allowing concurrency so by design, it will be slower
Got it. I see you mention that if you would do the fix, you would only do it for Android 12 users. How can one possibly go about that? Releasing a build that only targets Android 12 users.
See patch-packge and this.
There are many different patches in this thread. I will let you choose the one appropriate to you.
I would recommend keeping the thread for the main topic and redirecting your question to a better place (not sure where, though)
Unfortunately, in the more recent versions of React Native, patch-package
doesn't resolve the issue because the Java code is linked via Maven Central as com.facebook.react:react-android:X.X.X
.
patch-package
doesn't resolve the issue because the Java code
patch-package never worked for React Native Android as of version 0.20 because we shipped prebuilt (@douglasjunior the coordinate change you mentioned is irrelevant). You'll have to build-from-source if you want to apply to apply changes with patch-package.
To provide more data on the error:
In the last 30 days, the failure event occurred only on Android 12 version, on the following devices:
Is this only limited to Android 12 Go Edition? Has there be occurrences on Android 13/14 Go Edition?
I have a same problem with Android 12 with those devices: Tecno POP 7 POP 6 Pro Smart 6 Plus Infinix Smart 7 HD SE668S Itel A60s Galaxy A13 In my case, all version of android are 12. And this problem generate other problem in devices xiaomi.
We also have this issue. Seems that it also happens on Android 7 "react-native": "0.74.3",
@tdn120 long shot probably but is there a chance this is fixed by your PR?
@tdn120 long shot probably but is there a chance this is fixed by your PR?
Hmm I guess it could be, but that was mainly a clean-up, with hopes of resolving a different issue we're seeing with NativeViewHierarchyManager/ViewGroupManager.
I checked with @cortinico and we don't have a good repro for this issue at the moment, so I'll have to defer to the community on whether #45984 helps here.
@tdn120 @efstathiosntonas I can confirm that the PR https://github.com/facebook/react-native/pull/45984 does not resolve the issue.
I patched NativeViewHierarchyManager in our app (react-native: 0.71.8) according to the PR and released it, but the crash still persists.
@pSapien just to be 100% sure, you built Android from source, right?
@efstathiosntonas This is what I did.
NativeViewHierarchyManager.java
in the react native core code.The script is as follows
TARGET_DIR="./node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager"
TARGET_FILE="$TARGET_DIR/NativeViewHierarchyManager.java"
NEW_FILE_PATH="./NativeViewHierarchyManager.java"
rm -f "$TARGET_FILE"
cp "$NEW_FILE_PATH" "$TARGET_DIR"
echo "NativeViewHierarchyManager.java has been replaced successfully."
React Native Version: 0.71.8
Am I missing something?
you need to build from source. Patch package or swiping files right before build won’t work.
more info: https://reactnative.dev/contributing/how-to-build-from-source
@pSapien you can't just use patch-package
or replace files in react-native, that only works with other packages that aren't prebuilt. As @efstathiosntonas mentioned, to patch react-native you'll need to build react-native from source.
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:
But sometimes also with this one:
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