mapbox-maps-android
mapbox-maps-android copied to clipboard
Adding a circle annotation every 100 msec causes significant performance issues
Environment
- Android OS version: 12
- Devices affected: Samsung S20FE
- Maps SDK Version: 10.4.0
Observed behavior and steps to reproduce
We are running an instance of mapbox 10.4.0, using the circleAnnotationManager to display lat/lon points on the map. There is a kotlin sharedflow that delivers and ingests the data and makes it available to the viewmodel for displaying on the map. The data is coming in at a rate of 100 msec a point. Watching the profile in Android studio it shows that GEOJSON_PARSER is eating up nearly 50+% of the available resources. This makes the map unusable.
This image from the Android Studio profiler shows what appears to be taking what is passed through the circleAnnotationManager, converting it to geojson, then doing an http post internally (maybe between the java and native side?) and I assume it must be converting it back from geojson on the native side? This sequence happens every time a new point is added to the circleManager.
This is how I am creating my CircleAnnotationOptions:
fun getCircleAnnotation( point: Point, color: Color, radius: Double = 8.0): CircleAnnotationOptions{
return CircleAnnotationOptions()
.withPoint(point)
.withCircleColor(color.toArgb())
.withCircleStrokeColor(color.toArgb())
.withCircleRadius(radius)
}
Then I add the circle using the circleAnnotationManager:
circleManager.create(circleAnnotationOptions)
Expected behavior
Notes / preliminary analysis
Additional links and references
Can you try to cache the annotations and add them with create(options: List<S>)
? For example, adding 10 annotations every time.
@Chaoba I have done that, which helps a little. I was hoping there was some way to either bypass the geojson parser and get an pass the annotation directly to the native side.
@crroush are you still experiencing this behavior on our most recent release, v10.9.1?