Drop in performance with a lot of objects
See original GitHub issueDescription
Hello dear developers. I just encountered big drop in performance compared with reanimated v1 when you have about 50 Views with own SharedValue and own rotate transformation (especially on android device) . V2 shows about 40 fps, when v1 shows 60. Is v1 more performant? Or I do something wrong?
Screenshots
v2
v1
Steps To Reproduce
Use code below or:
- Add 50 Animated.Views with own Shared value and run rotate transformation
Expected behavior
60fps
Actual behavior
40fps
Snack or minimal code example
import { loop } from "react-native-redash/src/v1";
const dummy = new Array(50).fill(1);
function App() {
return (
<View style={{ flex: 1, flexDirection: "row", flexWrap: "wrap" }}>
{dummy.map((_, i) => {
const val = useSharedValue(0);
val.value = withRepeat(
withTiming(1, { duration: Math.random() * 2000 + 4000 }),
-1
);
const style = useAnimatedStyle(() => {
return {
transform: [
{ rotate: interpolate(val.value, [0, 1], [0, Math.PI * 2]) + "rad" },
],
};
});
//reanimated1 code
// const val = loop({ duration: Math.random() * 2000 + 4000 });
// const style = {
// transform: [
// {
// rotate: concat(
// interpolateNode(val, {
// inputRange: [0, 1],
// outputRange: [0, Math.PI * 2],
// }),
// "rad"
// ),
// },
// ],
// };
return (
<Animated.View
key={i}
style={[
{
width: 60,
height: 60,
borderWidth: 1,
backgroundColor: `hsl(${(360 / dummy.length) * i}, 100%, 40%)`,
},
style,
]}
/>
);
})}
</View>
);
}
Package versions
- React: 16.13.1
- React Native: 0.63.4
- React Native Reanimated: 2.0.0-alpha.9.2
- NodeJS: 14.15.1
- Android 9 (Redmi Note7) but the same on IOS with bigger Views count
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Significant editorloop performance drop when only certain ...
Significant editorloop performance drop when only certain objects are selected in the inspector.
Read more >Are there performance issues from using large numbers of ...
Yes, creating objects is more expensive compared to creating primitives. It also occupies more heap space (memory.)
Read more >Unity Optimization : reducing 3D objects' draw calls - YouTube
This video shows how to improve the 3D game performance in Unity.In this example, I will show you how to reduce draw calls...
Read more >java - Should you minimize the creation of a lot of small objects?
In general, no, you shouldn't avoid creating objects for fear of performance loss. There are several reasons for this.
Read more >Improve Application Performance with These Advanced GC ...
The basic concept of generational GC is based on the idea that the longer a reference exists to an object in the heap,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We improved performance since 2.3.+ version - https://github.com/software-mansion/react-native-reanimated/pull/1879
I also facing this issue, but with just 6 views, transform scale and backgroundColor. Android Samsung Galaxy S8 FPS ~40-50 😞 I use 2.0.0- rc0.