Performance drop on marker rendering
Summary
With the new arch enabled, there is a performance drop in the rendering of markers. I created a branch for this for everyone to test it because this might be a me thing or even react-native new arch thing, I don't know.
https://github.com/metkm/markers/tree/performance
Reproducible sample code
const markers = [...Array(50).keys()].map((item) => ({
id: item,
coordinate: {
latitude: 38 + item / 4,
longitude: 16,
},
}));
export default function App() {
const [showMarkers, setShowMarkers] = useState(false);
return (
<>
<Button title="Toggle Markers" onPress={() => setShowMarkers((show) => !show)} />
<MapView style={{ flex: 1 }}>
{showMarkers && (
markers.map((marker) => (
<Marker key={marker.id} coordinate={marker.coordinate} tracksViewChanges={false}>
<View
style={{
width: 10,
height: 10,
backgroundColor: "red",
}}
/>
</Marker>
))
)}
</MapView>
</>
);
}Steps to reproduce
I have put a button to toggle the rendering of markers. Open the devtools and record the performance profiler to check how long it took to render.
Expected result
Rendering to be faster.
Actual result
Rendering is slower.
React Native Maps Version
1.24.1
What platforms are you seeing the problem on?
Android
React Native Version
0.76.9
What version of Expo are you using?
SDK 52
Device(s)
Oppo Reno 4 Lite
Additional information
Here are my test results. The first screenshot shows the main branch of the repository I've linked above. New arch disabled and react-native-maps version set to 1.20.1. This was expected.
Here, I have switched to the new arch branch of the repository I've linked above. New arch enabled and react-native-maps version set to 1.24.1. I've run the test multiple times with everytime closing the app and opening it again.
As you can see, the performance is generally slower. Not only markers but the Polyline component was also slower, which ran in milliseconds in older versions. It was instant. For now, I didn't put the Polyline component, but it would be good to test it too after this issue is fixed.
If you want to test it, I suggest doing it on a physical device.
Source: react-native-maps/react-native-maps