Skip to content
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

Crash due to useNativeDriver true for tab animations with android 12 devices #11890

Open
3 of 11 tasks
vibhor-d11 opened this issue Mar 13, 2024 · 6 comments
Open
3 of 11 tasks

Comments

@vibhor-d11
Copy link

vibhor-d11 commented Mar 13, 2024

Current behavior

Dear Maintainers,

I hope this message finds you well. I am writing on behalf of Dream11 to bring to your attention an issue we've encountered while using react-native-tab-view library.

Issue Overview:

Currently their is no provision to enable/disable useNativeDriver for react native tab view. For tab animations useNativeDriver is set to true i.e they run on UI thread by default. We encountered some crashes related to Animated node that occurred only on Android 12 devices and after digging into it we get to know it is related to useNativeDriver set to true for tab animations. Also their is an open issue in react-native related to this crash: Link. So we added a patch in react-native-tab-view library for disabling useNativeDriver for devices having Android 12 and that reduces the crash rate for that crash with very few instances now. We have been using this for almost a year and haven't faced any issue with our app exposed to more than 20 million users. So we though of adding support for enable/disable useNativeDriver for react-native-tab-view as a prop exposed from material-top-tabs as it internally uses react-native-tab-view

Expected behavior

Following PR addresses the fix to add optional prop useNativeDriver for material-top-tabs which internally passes it to react-native-tab-view to enable/disable useNativeDriver for tab animations.

Reproduction

Their is not defined steps to reproduce it but we have many instances of this crash on our firebase portal. Many were related to react native tab view, after adding the patch for setting useNativeDriver to false, its instances reduced to none. This is the stacktrace for the crash.

Screenshot 2024-03-18 at 2 58 12 PM

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-tab-view

Environment

  • [] I've removed the packages that I don't use
package version
@react-navigation/native 6.1.7
@react-navigation/bottom-tabs 6.5.1
@react-navigation/material-top-tabs 6.2.1
@react-navigation/stack 6.2.1
@react-navigation/native-stack 6.9.13
react-native-safe-area-context 3.3.2
react-native-screens 3.25.0
react-native-gesture-handler 2.9.0
react-native-reanimated 3.4.0
react-native-tab-view 3.1.1
react-native-pager-view 5.4.25
react-native 0.72.5
node 18
npm or yarn 1.22.19
@vibhor-d11 vibhor-d11 added the bug label Mar 13, 2024
Copy link

Hey @vibhor-d11! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro.

The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue.

You can provide a repro using any of the following:

A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected.

Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information.

You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro.

Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 6.1.7, latest: 6.1.16)
  • @react-navigation/bottom-tabs (found: 6.5.1, latest: 6.5.19)
  • @react-navigation/material-top-tabs (found: 6.2.1, latest: 6.6.12)
  • @react-navigation/stack (found: 6.2.1, latest: 6.3.28)
  • react-native-tab-view (found: 3.1.1, latest: 3.5.2)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@hurshore
Copy link

hurshore commented Apr 3, 2024

@vibhor-d11 how did you disable useNativeDriver for android 12 devices only? Users are experiencing this issue in random parts of my app. But I think it happens when navigating to a screen. There is an open issue for it here.

This is the crash I get:

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)

@vibhor-d11
Copy link
Author

vibhor-d11 commented Apr 15, 2024

@vibhor-d11 how did you disable useNativeDriver for android 12 devices only? Users are experiencing this issue in random parts of my app. But I think it happens when navigating to a screen. There is an open issue for it here.

This is the crash I get:

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)

We disabled it using Platform api from react native to identify if the os is android and version is 12. Here is code snippet for same to check if android version is above 12 or not

const isAndroidVersionAbove12 = Platform.OS === 'android' && Platform.Version >= 31

@lucasoliveiraw00
Copy link

lucasoliveiraw00 commented Apr 30, 2024

I am going through the same situation, with over 42 thousand errors in a short period.
299676322-37c9957c-4a0a-48dd-9ac5-2b8c4e3089b9
Updated:
Users: 6.3k
Events: 21k
Captura de Tela 2024-04-30 às 10 03 30

@lucasoliveiraMM
Copy link

lucasoliveiraMM commented May 2, 2024

The error is related to the Animated component of React Native. Wouldn't it be better to remove its usage and utilize the Animated from react-native-reanimated? After all, there's still no solution for the error in the Animated component of React Native.

Link to the issue in react-native-reanimated

@satya164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants