Skip to content
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

[iOS] Low performance with 100+ markers with identical image #1176

Closed
ericapply opened this issue Mar 29, 2017 · 14 comments
Closed

[iOS] Low performance with 100+ markers with identical image #1176

ericapply opened this issue Mar 29, 2017 · 14 comments

Comments

@ericapply
Copy link
Contributor

ericapply commented Mar 29, 2017

Description

I am using react-native-maps to draw about 100 markers on the map.
Each marker is using same Image

Reproduction Steps and Sample Code

export default class Main extends Component {
  render() {
    return (
      <MapView style={StyleSheet.absoluteFill}>
        { coordinates.map(coordinate => {
              return (
                <Marker
                  key={coordinate.id}
                  coordinate={coordinate}
                  image={images.marker}
                />
              );
            })}
      </MapView>
    )
  }
}

Possible Solution

Re-using UIImage
http://stackoverflow.com/questions/25555778/optimising-custom-marker-image-performance-with-google-maps-sdk-for-ios

Currently AIRMapMarker.m and AIRGoogleMapMarker.m does not re-use UIImage and constantly allocates a new one. This is a huge performance hit when you want to cluster markers and want to pan around (constant allocation and garbage collection of UIImage).

Currently there is a way to provide 'image' prop directly to Marker (the way I am doing in the code above). There should be a dictionary of <NSString, UIImage> for MapView and re-use the UIImage when imageSrc is same.

Additional Information

  • React Native version: ["0.41.2"]
  • react-native-maps: ["^0.13.0"]
  • Platform: [iOS]
  • Development Operating System: [MacOS]
  • Dev tools: [Xcode: 8.3, iPhone 7(10.3)]

image

image

@ericapply ericapply changed the title Running out of memory when using hundreds of same Image [iOS] Running out of memory when using hundreds of same Image Mar 30, 2017
@ericapply ericapply changed the title [iOS] Running out of memory when using hundreds of same Image [iOS][Performance] Low performance when using 100+ identical image markers Mar 31, 2017
@ericapply ericapply changed the title [iOS][Performance] Low performance when using 100+ identical image markers [iOS] Low performance when using 100+ identical image markers Mar 31, 2017
@ericapply ericapply changed the title [iOS] Low performance when using 100+ identical image markers [iOS] Low performance when using putting 100+ markers with identical image Mar 31, 2017
@ericapply ericapply changed the title [iOS] Low performance when using putting 100+ markers with identical image [iOS] Low performance when using 100+ markers with identical image Mar 31, 2017
@ericapply ericapply changed the title [iOS] Low performance when using 100+ markers with identical image [iOS] Low performance with 100+ markers with identical image Mar 31, 2017
@hughvidos
Copy link

#1031

@hughvidos
Copy link

#1125

@ericapply
Copy link
Contributor Author

@hughvidos I have found and confirmed that the lagging is due to the sheer number of UIViews being created for every marker regardless of rather they were using same image or not. I have tried re-using UIImage and 750+ markers gives me solid 55+ FPS even when panning around.

@ericapply
Copy link
Contributor Author

#1187

@vinceyuan
Copy link
Contributor

@ericapply Could you please take a look at this issue? #1031 Thanks

@ericapply
Copy link
Contributor Author

@vinceyuan Can you try to use my PR and try to see if it still causes high CPU %?
"react-native-maps": "ericapply/react-native-maps#d6e86de",
You must use following way in order to take advantage of my optimization
<MapView.Marker coordinate={coordinate} anchor={{x: 0.65, y: 1}} image={imageSrc}/>

@vinceyuan
Copy link
Contributor

@ericapply I tried it. CPU % is still high. Because there is only one marker, reusing view does not help #1031
Anyway, thanks!

@mtt87
Copy link

mtt87 commented Apr 9, 2017

Even with a few markers it's using a >75% of CPU.
I'm in the same situation where I need to use custom map style and I need to use Google Maps.

Did anyone find a workaround?

Thank you

@grundmanise
Copy link

Same here.. even with 1 marker <MapView.Marker coordinate={coordinate} image={imageSrc}/> the UI is noticeably lagging.

@juergengunz
Copy link

same for me, only laggy when using custom markers, even one marker makes it laggy

@krabbypattified
Copy link

+1

@alvelig
Copy link
Contributor

alvelig commented Dec 13, 2017

Are you re-rendering map? Could someone provide a test repo reproducing performance problem?

@alvelig
Copy link
Contributor

alvelig commented Dec 15, 2017

Follow in #369

@alvelig alvelig closed this as completed Dec 15, 2017
@AngelVenchev
Copy link

Hey, I solved my problem and this could help somebody else too. I ended up using the image prop on the marker component to display whatever custom component I need. In my usecase I was implementing clustering using supercluster, I wanted to display a number of clusterized pins. I generated my images from here: https://dummyimage.com - about a hundred. Then a designer converted them to circles with a transparent background automatically with a Photoshop action and I loaded them in my application. 100 images were as small as 60kB so it's not a big hit that I have them all in the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants