software-mansion / react-native-reanimated

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

Android App crash on scrollTo With PanGesture #6418

Closed DonBrowny closed 2 months ago

DonBrowny commented 3 months ago

Description

I am trying to trying to create a Drag-Sort component with react-native-reanimated and react-native-gesture-handler. I came across this old snack - https://snack.expo.dev/@stewartarmbrecht/apple-music-drag-and-sort-working?platform=android and try to use it with the latest version of react-native and the app crashed when the scrollTo is triggered.

https://github.com/user-attachments/assets/7de221bd-4261-4642-a289-3db9fc6c0613

Steps to reproduce

yarn start --reset-cache and open the app in android-emulator

Snack or a link to a repository

https://github.com/DonBrowny/AnimationTest

Reanimated version

3.15.0

React Native version

0.75.1

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

Fabric (New Architecture)

Build type

None

Device

Android emulator

Device model

No response

Acknowledgements

Yes

MatiPl01 commented 3 months ago

I encountered the same issue. Thanks for reporting. I will forward the issue to the person who has been working on this recently.

DonBrowny commented 3 months ago

@bartlomiejbloniarz To narrow down the suspects for you, this issue occurs even on react-native-74.1 so this not specific to React Native update and i have also tried replacing the deprecated API with the alternatives/new way of handling gesture and faced the same issue. Let me know if you need any help in debugging this.

bartlomiejbloniarz commented 2 months ago

Hi @DonBrowny. This problems occurs, because when the user is moving an item, it triggers an update. This update synchronously triggers the logic responsible for scrolling the list (so it triggers another update). This means that there is a recursive call to the ShadowTree::commit function in RN. Currently such recursive calls lead to a deadlock (on Android). The issue seems to have been noticed by the RN team and had been addressed in this PR, but the fix is currently behind a feature flag. I tested it, and it seems to resolve our issue. I'm not sure when this behavior will be made default.

DonBrowny commented 2 months ago

@bartlomiejbloniarz Thanks for digging into this. Can you please let me know how to enable the FF and test this?

bartlomiejbloniarz commented 2 months ago

I just changed the invocation of the FF getter to a true value. For this I also had to build RN from source.

DonBrowny commented 2 months ago

Got it, Thanks. I will close this issue since it's a issue in the react-native framework and not on this library.

dppo commented 2 weeks ago

@DonBrowny I encountered the same problem, is there any solution?