addSource / updateGeoJSON slow performance on Android
When loading a 1 megabyte GeoJSON source to a map style and measure the time, I see a huge performance difference between Android and iOS.
var dateTimeNow = DateTime.now();
await mapboxMap?.style.addSource(
GeoJsonSource(
id: "my_source",
data: jsonEncode(myGeoJSON)
)
);
print(DateTime.now().difference(dateTimeNow).inMilliseconds);
Android: 1500ms (sometimes even more) iOS: 130ms
I tested on Emulators as well as physical devices, the results are the same.
The same behaviour also occurs when using source.updateGeoJSON(...).
When building a native Android app, working with large GeoJSON sources in Mapbox did not result in performance issues like this.
Here you can find the full sample project: flutter_mapbox.zip
Hi @felixkrautschuk, thank you for the report! I see you are also measuring json encoding in your test: jsonEncode(myGeoJSON), could you perform the same test with encoding being out of the scope of measurement?
@evil159 thanks for your reply!
I put the json encoding outside the measurement, but the result is still the same.
I have the same issue for my app. Adding a geojson source on iOS takes between 90ms and 150ms, whereas on Android it takes between 500ms and 900ms.
I have a map on the home page of my application that loads 15 geojson without performance issues, but when i push a new page, instanciate a new map and load those same geojson on the new map, it takes 5 times longer than the first map (which is still in memory)
We used to be on a fork of the repo matching the 0.5.0 and there was no performance issue regarding geojson source loading.
I tried to change the androidHostingMode on the second map (to either AndroidPlatformViewHostingMode.TLHC_HC or AndroidPlatformViewHostingMode.VD) and the performances are much better
For updating features, a fix is provided in version 2.3.0:
mapboxMap.style.updateGeoJSONSourceFeatures(sourceId, dataId, features);
This is working on my side.
For updating features, a fix is provided in version 2.3.0:
mapboxMap.style.updateGeoJSONSourceFeatures(sourceId, dataId, features);This is working on my side.
When I add source by :
await mapboxMap.style.addSource( GeoJsonSource( id: 'focus', data: jsonEncode(transToFeature(spotList)), cluster: focusMenu.type != MapConst.trip, clusterMaxZoom: MapConst.clusterMaxZoom, clusterRadius: 50, ), )
And update by:
await mapboxMap.style.updateGeoJSONSourceFeatures('focus', 'data', features);
but not working for me.