react-native-maps: Custom markers slow performance with reproduceble demo
I was experiencing high CPU usage and lags on the map with what I consider a lot of markers - 400. To my surprise however the map was fast with 300 markers. So, it wasn’t really making sense. After debugging this for several hours I managed to come with a reproducible demo of the issue.
https://github.com/compojoom/react-native-maps/tree/high_cpu
launch the examples and switch to google maps as provider and open the “custom markers” example.
in xCode one should see

If you go into
example/examples/CustomMarkers.js
and remove the dsafasdf on line 81 and refresh the example you will see that the CPU usage goes to 1-2%

if one changes the width of the custom marker to 100 px for example, then we get again CPU usage of 100%
I’ve tested this currently only on iOS and I’m not sure if the issue apply to Android.
Environment
“react”: “16.5.0”, “react-mixin”: “^2.0.2”, “react-native”: “0.57.1”, react-native-maps: > 0.21.0 Target Platform: eg: iOS - 12.1 Simulator/iPhone 6
Steps to Reproduce
Use the reproducible demo. The issue is hard to reproduce as one needs a lot of markers and the “correct” styling…
Expected Behavior
I would expect CPU to go down once the markers are rendered
Actual Behavior
CPU stays at 100%
Reproducible Demo
https://github.com/compojoom/react-native-maps/tree/high_cpu
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 23
- Comments: 37 (5 by maintainers)
Hello guys, the slowness issue isn’t anymore an issue for me hihi !!!
Well it is an easy job, just don’t use the props onRegionChange
This is what causes the android google map slowness issue
Instead you can just simply use the props onRegionChangeComplete
Cheers. !!
Solution: Native development
This did help us a little though:
tracksViewChanges={false}Any updates on this issue? I am experiencing the same: cpu spikes with just a handful of custom markers and callouts(text only).
100% cpu in iOS using the google provider map. Switching to apple maps fixes the performance issue, but is not preferred.
Tried both tracksViewChanges=false and using onRegionChangeComplete, both did not help with google maps on iOS.
Any news on this?
with the new architecture of react-native we can get much better performance and get closer to native performance by avoiding serializing map data (markers).
hopefully with RN supporting typescript for Turbo Modules we can start working on that
#4156
Still experiencing extreme performance degradation on Android when using custom markers when not setting trackViewChanges to false. Any update on a potential fix or workaround?
guys, any news here?
My steps:
Also:
But I cannot use icon prop because I really need to set different width/height depends on business logic.
I have: react-native: 0.61.2 react-native-maps: 0.27.1
bump
Bump! Please fix
Hello, has anyone found a solution regarding the custom marker making the app really slow (android only) Indeed when I test with the google map marker it’s really fast !
i have issue styling my map i want to implement border raduis on my map ,if i add border radius it does work
On Sun, Nov 11, 2018, 13:36 Daniel Dimitrov notifications@github.com wrote:
bump
I am facing the same issue. What is going on after the markers have been rendered. If I replace the custom markers with the default ones it works really well. However when I replace the markers with ImageBackgroud and Text inside it, with little to no styling it just starts going slowly.
@cklinx - this bug report has nothing to do with tracksViewChanges. If you look at the example code you’ll see that tracksViewChanges is already set to false: https://github.com/compojoom/react-native-maps/blob/d60402e2c62f26f3be91023381bdb0cafc9c8318/example/examples/CustomMarkers.js#L73
updated