mapbox-maps-android
mapbox-maps-android copied to clipboard
Warning spam in log when animating point annotations after style change (memory leak)
Environment
- Android OS version: 10
- Devices affected: DJI RC Pro
- Maps SDK Version: 11.0.0-beta.5
Observed behavior and steps to reproduce
I am animating point annotations (using PointAnnotationManager), but after I load a new style the log gets spammed with
13:01:10.665 14950-15184 chatty I uid=10079 GEOJSON_PARSER identical 11 lines
13:01:10.668 14950-15184 Mapbox W [maps-android\Mbgl-Style]: Style object (accessing setStyleGeoJSONSourceData) should not be stored and used after MapView is destroyed or new style has been loaded.
13:01:10.672 14950-15184 Mapbox W [maps-android\Mbgl-Style]: Style object (accessing setStyleGeoJSONSourceData) should not be stored and used after MapView is destroyed or new style has been loaded.
Expected behavior
No log spam.
Notes / preliminary analysis
The animations are constantly moving the annotations on the map. I use Android's ValueAnimator which calls
annotation.point = valueAnimator.animatedValue as Point
annotationManager.update(annotation)
I am not calling setStyleGeoJSONSourceData anywhere by myself.
As soon as I stop the animations, the log spam stops.
If I never load a new style, there is no log spam.
This warning logging is caused by the annotation manager's source, it does not update the style delegate when a new style is loaded.
Workaround for this is to remove and recreate the annotation manager and all its annotations when the style changes.
If you use clustering, do not pass clustering options when recreating the manager. Associated bug: https://github.com/mapbox/mapbox-maps-android/issues/2209