software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.87k stars 1.29k forks source link

app crashes when navigating trough screens "Fatal Exception: com.facebook.jni.CppException: bad_weak_ptr" #4470

Closed mohamedziadjabbad closed 1 year ago

mohamedziadjabbad commented 1 year ago

Description

Fatal Exception: com.facebook.jni.CppException: bad_weak_ptr at com.swmansion.reanimated.Scheduler.triggerUI(Scheduler.java) at com.swmansion.reanimated.Scheduler$1.run(Scheduler.java:24) at com.swmansion.reanimated.Scheduler$2.runGuarded(Scheduler.java:43) at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:31) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:7948) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Steps to reproduce

  1. navigate to the screen and press goBack on react native navigation.

Reanimated version

2.17.0

React Native version

0.67.0

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Real device

Device model

samsung galaxy j6

Acknowledgements

Yes

github-actions[bot] commented 1 year ago

Hey! šŸ‘‹

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

github-actions[bot] commented 1 year ago

Hey! šŸ‘‹

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

Dr-LYK commented 1 year ago

Hi there, We are facing the same crashes since 5 months. Unfortunately, we could not reproduce it manually but crashes are stored in Firebase Crashlytics reports.

Please find below the production environment where last crash occurred.

Reanimated version

2.17.0

React Native version

0.71.6

Platforms

Android

Device

Samsung Galaxy A22 5G

Fatal Exception: com.facebook.jni.CppException: bad_weak_ptr
       at com.swmansion.reanimated.Scheduler.triggerUI(Scheduler.java)
       at com.swmansion.reanimated.Scheduler$1.run(Scheduler.java:24)
       at com.swmansion.reanimated.Scheduler$2.runGuarded(Scheduler.java:43)
       at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:30)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8757)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
freeboub commented 1 year ago

I had also investigate this issue. I wonder if it can be linked to: https://github.com/facebook/react-native/pull/37927 Which has his original root cause here: https://issuetracker.google.com/issues/261481042?pli=1 Notice that reanimated also uses: ConcurrentLinkedQueue

cw-sanjeev commented 1 year ago

@freeboub were you able to resolve this issue?

freeboub commented 1 year ago

I didn't see this issue for a while. Notice two things,

Here is the patch I apply (I don't think this is a risky change)

react-native-reanimated+2.17.0.patch

salik-a commented 6 months ago

Hi there, We are facing the same crashes since 5 months. Unfortunately, we could not reproduce it manually but crashes are stored in Firebase Crashlytics reports.

Please find below the production environment where last crash occurred.

Reanimated version

2.17.0

React Native version

0.71.6

Platforms

Android

Device

Samsung Galaxy A22 5G

Fatal Exception: com.facebook.jni.CppException: bad_weak_ptr
       at com.swmansion.reanimated.Scheduler.triggerUI(Scheduler.java)
       at com.swmansion.reanimated.Scheduler$1.run(Scheduler.java:24)
       at com.swmansion.reanimated.Scheduler$2.runGuarded(Scheduler.java:43)
       at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:30)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8757)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Did you find any solution

Sapnarawat1 commented 1 month ago

@freeboub @salik-a @mohamedziadjabbad getting same issue, i am using react native- 0.71.11, react-native-reanimated-2.14.4, will updating react-native-reanimated help