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

ANR caused in performOperations #2251

Closed
1 of 3 tasks
heroic opened this issue Aug 4, 2021 · 26 comments
Closed
1 of 3 tasks

ANR caused in performOperations #2251

heroic opened this issue Aug 4, 2021 · 26 comments
Labels
Bug bug-bash-jan22 Issues visited during Bug Bash Jan 2022 🏠 Reanimated 2

Comments

@heroic
Copy link
Contributor

heroic commented Aug 4, 2021

Description

We are seeing multiple ANRs with reanimated at the top of the stacktrace. These are not showing in bugsnag either, only on Play Store which is now penalising our app.

Expected behavior

No ANR

Actual behavior & steps to reproduce

"main" prio=5 tid=1 Waiting
  at sun.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:868)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1023)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1334)
  at java.util.concurrent.Semaphore.acquire (Semaphore.java:318)
  at com.swmansion.reanimated.NodesManager.performOperations (NodesManager.java:230)
  at com.swmansion.reanimated.NodesManager.onAnimationFrame (NodesManager.java:259)
  at com.swmansion.reanimated.NodesManager.access$000 (NodesManager.java:65)
  at com.swmansion.reanimated.NodesManager$1.doFrameGuarded (NodesManager.java:153)
  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:1063)
  at android.view.Choreographer.doCallbacks (Choreographer.java:889)
  at android.view.Choreographer.doFrame (Choreographer.java:812)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1050)
  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:7830)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1040)

Snack or minimal code example

None available

Package versions

  • React Native: 0.63.4
  • React Native Reanimated: 2.2.0
  • NodeJS: 16.0.0
  • Xcode:
  • Java & Gradle: openjdk 11.0.8 gradle 6.5

Affected platforms

  • Android
  • iOS
  • Web
@github-actions
Copy link

github-actions bot commented Aug 4, 2021

Issue validator

The issue is valid!

@beetlebum
Copy link

I am experiencing exactly the same issue since upgrading to 2.3 in production.

Input dispatching timed out (9fff00a [My app Activity] (server) is not responding. Waited 10002ms for FocusEvent(hasFocus=false))

"main" prio=5 tid=1 Waiting

 at sun.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:868)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1023)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1334)
  at java.util.concurrent.Semaphore.acquire (Semaphore.java:318)
  at com.swmansion.reanimated.NodesManager.performOperations (NodesManager.java:249)
  at com.swmansion.reanimated.NodesManager.onAnimationFrame (NodesManager.java:278)
  at com.swmansion.reanimated.NodesManager.access$000 (NodesManager.java:63)
  at com.swmansion.reanimated.NodesManager$1.doFrameGuarded (NodesManager.java:168)
  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:970)
  at android.view.Choreographer.doCallbacks (Choreographer.java:796)
  at android.view.Choreographer.doFrame (Choreographer.java:727)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:957)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:250)
  at android.app.ActivityThread.main (ActivityThread.java:7868)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:592)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)

image
image

@joy-betterhalf
Copy link

Hey @heroic

Did you find any solution for it? We started facing a similar issue when we moved from APK to App bundle.

Thanks.

@kmagiera kmagiera added the bug-bash-jan22 Issues visited during Bug Bash Jan 2022 label Jan 28, 2022
@kmagiera
Copy link
Member

Hi all, thanks for reporting. The ANR is likely cause by a deadlock due to the code we use for making synchronizing UI updates. However, w/o more details it is very little we can do about it. It'd be important for us to get some more information about what kind of animations run when this occurs, or get traces from other threads if available. Any kind of additional detail that you may share may be helpful in getting to the bottom of this issue.

@kmagiera kmagiera added the Close when stale This issue is going to be closed when there is no activity for a while label Jan 28, 2022
@heroic
Copy link
Contributor Author

heroic commented Jan 28, 2022

From what I can tell the only animations that are happening are the React Navigation screen changes. We're seeing this when going from one Screen to a Screen containing Tabs, and also when going from one simple Screen to another Screen.

Here's a pastebin from one of the crash logs: https://pastebin.com/pxBRCn63

@github-actions github-actions bot removed the Close when stale This issue is going to be closed when there is no activity for a while label Jan 28, 2022
@joy-betterhalf
Copy link

@heroic

Can you please confirm your react navigation version?

We are also seeing similar behavior at the same place where we are using Stack navigation > Tab navigation

@heroic
Copy link
Contributor Author

heroic commented Jan 29, 2022

@joy-betterhalf RN v5

@joy-betterhalf
Copy link

joy-betterhalf commented Feb 3, 2022

@kmagiera In our case, we have tried removing every place where we directly use react-native-reanimated for animation and kept the library as a dependency for other modules such as https://gorhom.github.io/react-native-bottom-sheet/ still we are getting many ANRs with the same error everyone facing here and we are not sure what causes the ANR and that's why I asked @heroic on React navigation version since I thought it's old and could be causing this problem. We were using V4 which now migrated to V5 but still, we are facing the same issue.

@geroale
Copy link

geroale commented Mar 10, 2022

Same issue here

@marf
Copy link

marf commented Mar 10, 2022

We have the same issue.

@ohheyitskartik
Copy link

can we merge this ? still facing this issue..

@marf
Copy link

marf commented Sep 7, 2022

Yes, please merge the PR #3440 in the master and release an update to hopefully fix this issue. Thanks!

@viv3kk
Copy link

viv3kk commented Sep 22, 2022

Facing same issue on android multiple devices:
React-native : 0.66.4
react-native-reanimated : 2.9.1 (^2.2 on package.json)

"dependencies": { "@ptomasroos/react-native-multi-slider": "^2.2.2", "@react-native-async-storage/async-storage": "^1.15.4", "@react-native-community/art": "https://github.com/react-native-art/art.git", "@react-native-community/blur": "^3.6.0", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/slider": "^3.0.3", "@react-native-firebase/analytics": "^11.5.0", "@react-native-firebase/app": "^11.5.0", "@react-native-firebase/crashlytics": "^11.5.0", "@react-native-firebase/messaging": "^11.5.0", "@react-native-firebase/perf": "^11.5.0", "@react-navigation/bottom-tabs": "^5.11.9", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.4", "@reduxjs/toolkit": "^1.5.1", "@sentry/react-native": "^3.1.1", "@shopify/restyle": "^1.4.0", "@snowplow/react-native-tracker": "^1.2.1", "axios": "^0.21.1", "babel-plugin-module-resolver": "^4.1.0", "babel-plugin-transform-remove-console": "^6.9.4", "clevertap-react-native": "^0.8.1", "launchdarkly-react-native-client-sdk": "^5.1.0", "lodash": "^4.17.21", "lottie-ios": "3.4.0", "lottie-react-native": "^5.1.3", "moment": "^2.29.1", "query-string": "^7.0.0", "react": "17.0.2", "react-native": "0.66.3", "react-native-branch": "^5.5.0", "react-native-code-push": "^7.0.4", "react-native-dash": "^0.0.11", "react-native-dropdown-picker": "5.0", "react-native-fast-image": "^8.3.4", "react-native-fbsdk-next": "^7.0.1", "react-native-flipper": "^0.91.2", "react-native-geocoding": "^0.5.0", "react-native-geolocation-service": "5.2.0", "react-native-gesture-handler": "^2.4.0", "react-native-image-pan-zoom": "^2.1.12", "react-native-in-app-review": "^3.2.3", "react-native-linear-gradient": "^2.5.6", "react-native-modal": "^13.0.1", "react-native-modal-dropdown": "^1.0.0", "react-native-neomorph-shadows": "^1.1.2", "react-native-otp-verify": "^1.0.4", "react-native-pager-view": "^5.1.9", "react-native-progress": "^5.0.0", "react-native-radial-gradient": "^1.0.9", "react-native-reanimated": "2.6.0", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.1.1", "react-native-shimmer-placeholder": "^2.0.7", "react-native-simple-toast": "^1.1.3", "react-native-size-matters": "^0.4.0", "react-native-smooth-picker": "^1.1.5", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^12.1.1", "react-native-svg-transformer": "^0.14.3", "react-native-tab-view": "^3.0.1", "react-native-tracking-transparency": "^0.1.1", "react-native-ultimate-config": "^3.3.4", "react-native-version-info": "^1.1.0", "react-native-video": "^5.2.0", "react-native-walkthrough-tooltip": "^1.3.0", "react-native-webview": "^11.4.0", "react-native-wheel-scrollview-picker": "^2.0.0", "react-redux": "^7.2.3", "redux-flipper": "^1.4.2", "redux-logger": "^3.0.6", "redux-persist": "^6.0.0", "yup": "^0.32.9" },

@androideveloper
Copy link
Contributor

Did anyone tried this change #3440 in prod?

@HilSny
Copy link

HilSny commented Nov 2, 2022

We're seeing this as well and it started when we integrated react-native-reanimated-carousel. If we show a carousel right away after app launch, the app hangs and never recovers. I don't know if that helps you but we had to disable our tutorial carousel as a result and are still seeing ANRs as a result. The crash happens before there is any interaction with the carousel.

@androideveloper
Copy link
Contributor

androideveloper commented Nov 3, 2022

We don't use react-native-reanimated-carousel but this ANR started increasing for us once we added more animations on the same screen using reanimated.

Quick update from our side. We patched this fix (using rn-patch) and shipped on prod #3440 and number of ANRs decreased significantly! 🚀 In order to patch it properly, we needed to force rebuild reanimated from source by passing reanimated = [ buildFromSource: true ] to gradle config.

There's a small issue with this approach, but overall the app is more stable

@gollobo
Copy link

gollobo commented Jan 17, 2023

Same ANRs in production here! This is by far the most common ANR cause in our apps at the moment (+60%)
Any workarounds while the bug is fixed?

@androideveloper
Copy link
Contributor

See my comment above

@jedashford
Copy link

Following. We are also seeing significant crashes for iOS that appear related to this, thousands daily.

@pavangoyal42
Copy link
Contributor

@androideveloper is your fix working well so far in production app ? any issues you see like animation is starting with delay ? we are also seeing same ANRs on play console.

@androideveloper
Copy link
Contributor

No major issues so far 👍

@prince-housing
Copy link

Thanks for the help @androideveloper, we had added the patch #3440 in our app.
This helps us to fix the ANR issue on the app 👍

But using the above fix we facing an increase in user crashes, below is the crash log for the same.

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:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:257)
       at android.app.ActivityThread.main(ActivityThread.java:8218)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1016)

We are using react-native version 0.69.4 and react-native-reanimated version 2.12.0.

@pavangoyal42
Copy link
Contributor

@androideveloper we have also applied the patch. no anr or issue so far.
@prince-housing we were also facing this crash. I can confirm react-native-reanimated 3.0.0 solved the issue for us. no instances seen after 3.0.0.

@prince-housing
Copy link

@pavangoyal42 did you also use the patch with react-native-reanimated 3.0.0?

@pavangoyal42
Copy link
Contributor

@prince-housing yes I have used patch with 3.0.0. this solved the crash and ANR. so side effects as of now.

@piaskowyk
Copy link
Member

Fixed with #4239, the fix is available since 3.+ versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug bug-bash-jan22 Issues visited during Bug Bash Jan 2022 🏠 Reanimated 2
Projects
None yet