-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Significant performance degradation from 3.6 to 3.7 #5816
Comments
I was preparing a demo to report the same issue, We had to revert to version 3.6.1. I think this is where the problem is coming from commit. this issue occurs if there is an ongoing animation and the component is unmounted from the screen. You are also using FlastList, so the parts that are not visible on the screen are unmounted. I think this is why the same problem occurs. I'm adding another demo. (v3.6.1 VS v3.8.1) I had to push the limits a bit to show the problem more clearly (with rendering 1000 animated views) v3.8.1.mp4v3.6.1.mp4import React, {useEffect, useState} from 'react';
import {
Text, TouchableOpacity, View,
} from 'react-native';
import Animated, {useAnimatedStyle, useSharedValue, withRepeat, withTiming} from "react-native-reanimated";
const App = () => {
const [screen, setScreen] = useState("A");
const ScreenA = () => {
const rotation = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => {
return {
transform: [{rotate: `${rotation.value}deg`}]
}
})
useEffect(() => {
rotation.value = withRepeat(withTiming(270, {duration: 1000}), -1, true)
}, []);
return(
<View style={{flex:1, justifyContent: "center", alignItems: "center"}}>
<Text>This is Screen A</Text>
<TouchableOpacity style={{backgroundColor: "red"}} onPress={() => setScreen("B")}>
<Text>Go to Screen B</Text>
</TouchableOpacity>
<View style={{flexDirection: "row", marginTop: 100}}>
{[...Array(1000)].map((value, index, array) => {
return <Animated.View key={index} style={[animatedStyle, {width: 50, height: 50, backgroundColor: "blue"}]}/>;
})}
</View>
</View>
);
}
const ScreenB = () => {
const rotation = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => {
return {
transform: [{rotate: `${rotation.value}deg`}]
}
})
useEffect(() => {
rotation.value = withRepeat(withTiming(270, {duration: 1000}), -1, true)
}, []);
return(
<View style={{flex:1, justifyContent: "center", alignItems: "center"}}>
<Text>This is Screen B</Text>
<TouchableOpacity style={{backgroundColor: "red"}} onPress={() => setScreen("A")}>
<Text>Go to Screen A</Text>
</TouchableOpacity>
<View style={{flexDirection: "row", marginTop: 100}}>
{[...Array(1000)].map((value, index, array) => {
return <Animated.View key={index} style={[animatedStyle, {width: 50, height: 50, backgroundColor: "red"}]}/>;
})}
</View>
</View>
);
}
return (
<View style={{flex:1}}>
{screen === "A" && <ScreenA/>}
{screen === "B" && <ScreenB/>}
</View>
);
}
export default App; |
probably related to: #5800 |
I've also noticed the performance loss in my library with the recent versions in particular for low end android devices when executing callbacks with |
@tjzel @piaskowyk @kmagiera I know the whole team is focused on new arch but in the meantime can you please investigate/keep in mind these performance issues while you're on it? There are plenty of issues hanging around in here and in Moti library repo. |
@efstathiosntonas We definitely have this in mind, some time ago I have even been planning some stress tests in Reanimated. Once we are done with current matters we will jump to this. |
This issue blocks our update to Expo 51. |
I have the same issue and it blocks upgrade to RN 0.74. I understand you have a lot of tasks to do, but I hope this issue will not be ignored. |
Just come across this issue also upgrading to Expo 51. |
Isn't this fixed, now that #6083 is fixed? |
It's definitely better. I tried to run my initial test with 3.14.0. However the FPS drops is still greater than version 3.6 |
Thanks for running the tests! At this point it seems that the difference between 3.6.0 and 3.14.0 is of only ~1.7 FPS. From your data we can also see that the average test duration was shorter than in your tests on 3.6.0. I feel like that at this point this could also just be a measurement error? |
Yeah, I think I've might been a bit too fast making the post. I realized that the old tests (I didn't rerun those) were made with a different device, I forgot since it's been so long. I'll redo all the tests with the same device and post the results |
same with me Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. |
Description
As people also have been writing here: #5685 there are serious performance degradations in 3.7 compared to 3.6.
I've made an example to reproduce it. It's a list that has a Gesture, 1 SharedValue, 2 useAnimatedStyle (each with an interpolateColor).
I've ran the example through Flashlight to see the metrics. It's seems that the UI thread is a lot more busy in 3.7. I think the report is a little misleading in regards to the JS thread, since 3.7 lags so much that fewer items are loaded in the list.
I can imagine it has something to do with this commit but I'm not sure.
Steps to reproduce
Also provided in the reproduction:
Setup
npm install
To run for for reanimated 3.6.3
npm install [email protected]
npm run android:release
Not the actual flashlight test
recording_3-6-3.mp4
To run for for reanimated 3.7.2
npm install [email protected]
npm run android:release
Not the actual flashlight test
recording_3-7-2.mp4
Snack or a link to a repository
https://github.com/jacobmolby/reanimated-perf-issue
Reanimated version
3.7.2
React Native version
0.73.6
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client
Architecture
Paper (Old Architecture)
Build type
Release app & production bundle
Device
Real device
Device model
Samsung Galaxy A52G (Android 14)
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: