mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.35k stars 1.33k forks source link

Add a sync version of `setGeoJson` function in `GeoJsonSource` #16482

Open mirrajabi opened 4 years ago

mirrajabi commented 4 years ago

Platform: Android

Mapbox SDK version: v8.5.0-beta.1

Request

A sync version of setGeoJson function in GeoJsonSource.

Request details

Hi there,

MR #15871 introduces an improvement which for us turned out to be a huge problem.
We've made some apps that update the GeoJsonSources multiple times per second in some specific scenarios. (specific scenario being: replaying feature movements in the past few minutes with increased speed)
In these apps, It's important, not to lose any "updates", but fps drop is not a problem.
Before this release, our "replay" feature was working fine. It could render all the updates that were being fed to it. but now, we don't have a way to get notified when the source is updated (and even having that wouldn't be ideal). so the result is that we call setGeoJson on GeoJsonSources very fast and it won't render all of the updates.

Current solutions are to either keep the SDK version always below v8.5.0-beta.1 which is not going to work. Or, drop parts of the functionality which also isn't great! :)

Steps to trigger behavior

[Android instructions]

  1. Make a GeoJsonSource and a Symbol layer
  2. Use any sort of delay mechanism and feed about 50 features to the source with a ratio of just more than 3 times per second (or try something faster, like 10, if you have a very high-end device :D)
  3. Run it!

Expected behavior

All the sources updates should be rendered. (I know this might defeat the purpose of #15871, but having the option is helpful)

Actual behavior

Map draws the sources in random times depending on how heavy the feature collection passed to setGeoJson function is.

Thanks in advance!