scrollTo performance issues on the New Architecture when multiple views are animated at the same time #6999
Labels
Area: Performance
Maintainer issue
Issue created by a maintainer
Platform: Android
This issue is specific to Android
Platform: iOS
This issue is specific to iOS
Repro provided
A reproduction with a snippet of code, snack or repo is provided
Description
Problem description
I was looking into possible improvements of auto scroll performance in my react-native-sortables library. Performance is fine on the Old Architecture, but on the New Architecture it is horrible. Apart from massive FPS drops and noticeably higher memory usage (might be related to RN, memory is not a big problem), there are also a some other problems:
scrollTo
runs synchronously, whilst style updates are asynchronous, which results in the noticeable delay betweenScrollView
position update and the view position update,Example recording
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-09.at.15.02.03.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-09.at.15.00.26.mp4
What I tried
To fix the problem with delay between view update and the
ScrollView
position update I tried to read the view position with the synchronousmeasure
function from Reanimated and scroll theScrollView
only after the view was transitioned. This approach also doesn't work as, likely, the new view position is applied somewhere between frames in theuseFrameCallback
and there is still some delay between transformation of the view and scrolling theScrollView
.Final remarks
The issue is less visible in the release build on the real device, likely because of more FPS, which result in more frequent commits and lower delays.
Steps to reproduce
Copy this code to your app and run it on the Old and the New Architecture:
Snack or a link to a repository
https://github.com/MatiPl01/react-native-sortables <- you can test it here as well on the Auto Scroll example screen
Reanimated version
3.16.6
React Native version
0.76.5
Platforms
iOS, Android
JavaScript runtime
None
Workflow
None
Architecture
Fabric (New Architecture)
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: