Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[Android] UI thread checking in android-v6.2.0 #12054

Closed
ychescale9 opened this issue Jun 4, 2018 · 1 comment
Closed

[Android] UI thread checking in android-v6.2.0 #12054

ychescale9 opened this issue Jun 4, 2018 · 1 comment
Labels
Android Mapbox Maps SDK for Android

Comments

@ychescale9
Copy link

Platform: Android
Mapbox SDK version: android-v6.2.0-beta.1

Version 6.2 now enforces setGeoJson(...) to be called from the main thread.
I understand based on previous discussions that these operations should not be run from the background thread and that rendering large maps blocks the main thread is a known issue.

What would be your recommended approach for projects that are already using background thread to call setGeoJson(...) to workaround the performance issue going forward? Thanks.

@LukasPaczos LukasPaczos added the Android Mapbox Maps SDK for Android label Jun 4, 2018
@tobrun
Copy link
Member

tobrun commented Jun 5, 2018

Thank for reaching out @ychescale9 , updating a GeoJsonSource from a worker thread is not supported and can result in crashes. As flagged, we are aware of the performance around this and will be tackling it as part of #8484.

If you need to dynamically change the underlying geometry of a source with calculating that geometry on a workerthread. You can do this with a CustomGeometrySource and the GeometryTileProvider. The latter component will be executed on a worker thread:

/**
 * Interface that defines methods for working with {@link CustomGeometrySource}.
 */
public interface GeometryTileProvider {

  /***
   * Interface method called by {@link CustomGeometrySource} to request features for a tile.
   *
   * @param bounds {@link LatLngBounds} of the tile.
   * @param zoomLevel Tile zoom level.
   * @return Return a @{link FeatureCollection} to be displayed in the requested tile.
   */
  @WorkerThread
  FeatureCollection getFeaturesForBounds(LatLngBounds bounds, int zoomLevel);
}

Closing this issue, follow up will happen in #8484.
Let us know if you have any follow questions!

@tobrun tobrun closed this as completed Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants