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

Adding/removing a GeoJSON source doesn't show in layer till map is zoomed in/out #6612

Closed

Description

@cammace

Platform: Nexus 5x running Nougat
Mapbox SDK version: 4.2.0-beta.3

Steps to trigger behavior

  1. Have a map style with a GeoJSON source that is visible.
  2. Replace the GeoJSON source with a new one.
  3. The layer won't show update till you zoom in/out

Expected behavior

Updated source shows up instantly when added to map

Actual behavior

new Source won't show up till after zooming map in or out (invalidating the map?)

cc: @ivovandongen @zugaldia

Activity

  1. added
    Android
    on Oct 6, 2016
  2. added this to the android-v4.2.0 milestone on Oct 6, 2016
  3. rmnblm commented on Oct 7, 2016

    @rmnblm

    Might be the same issue as I had with iOS, see #6177 (comment)

  4. 1ec5 commented on Oct 7, 2016

    @1ec5
    Contributor

    This sounds different than #6177. As of beta 3, we’re correctly invalidating the map when a layout or paint property or filter is set; however, swapping out a source is probably distinct from changing a filter.

    @jfirebaugh, does this sound like something that should’ve been fixed by #6201, or is it another special case?

  5. ivovandongen commented on Oct 7, 2016

    @ivovandongen
    Contributor

    @cammace Just to clarify, this issue is not about updating a GeoJsonSource (like the title suggests), but replacing it all together with add/removeSource right?

  6. jfirebaugh commented on Oct 7, 2016

    @jfirebaugh
    Contributor

    This is exposing some lax behavior in our runtime styling APIs -- it's not actually intended to be possible to remove a source that's currently in use by one or more layers, add another source with the same ID but different data, and have the layers update to the new data. (Doing so potentially violates numerous invariants that the style attempts to enforce.)

    Instead, removing an in-use source should either:

    • Produce an error indicating that the layers that use it need to be removed first, or
    • Automatically remove those layers
  7. changed the title [-]Updated GeoJSON source changes don't show in layer till map is zoomed in/out[/-] [+]Adding/removing a GeoJSON source doesn't show in layer till map is zoomed in/out[/+] on Oct 11, 2016
  8. removed this from the android-v4.2.0 milestone on Oct 11, 2016
  9. ivovandongen commented on Oct 11, 2016

    @ivovandongen
    Contributor

    @jfirebaugh Agreed. I would prefer an error in this situation to make it abundantly clear that this is an unsupported operation.

    I removed this from the upcoming release milestone as it is not a blocker.

  10. sddamico commented on Oct 18, 2016

    @sddamico

    It should be noted that the same behavior is seen if one changes the backing data in a geojson source
    (e.g. layers not not invalidating until the map is invalidated by zoom or some other event)

    String serializedGeoJsonData = getNewGeoJsonData();
    final GeoJsonSource source = mapboxMap.getSourceAs("geoJsonData");
    source.setGeoJson(serializedGeoJsonData);
    
  11. sddamico commented on Oct 18, 2016

    @sddamico

    My current workaround is mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(0.0001f));

  12. jfirebaugh commented on Oct 18, 2016

    @jfirebaugh
    Contributor

    @sddamico That's #5906, and should be fixed in v4.2.0-beta.3.

  13. sddamico commented on Oct 18, 2016

    @sddamico

    @jfirebaugh I'm using v4.2.0-beta.3 and the issue as I described is present.

  14. jfirebaugh commented on Oct 19, 2016

    @jfirebaugh
    Contributor

    Ok, please open a fresh issue.

  15. sddamico commented on Oct 19, 2016

    @sddamico
  16. damianflannery commented on Nov 9, 2016

    @damianflannery

    I am also facing this issue with beta4. I call removeLayer(layerId) before adding a new layer (with different id).

    I recorded a short recording here (glitch happens at 11 seconds from start)
    https://dl.dropboxusercontent.com/u/27007357/mapbox_geojsonsource_glitch.mp4

  17. ivovandongen commented on Nov 9, 2016

    @ivovandongen
    Contributor

    @damianflannery Could you share some code (minimal case) so we can see how you're doing this? The original issue was about removing/adding a source to get layers updated, you seem to be doing something else.

  18. damianflannery commented on Nov 10, 2016

    @damianflannery

    @ivovandongen Sure, I created a sample project here:
    https://github.com/damianflannery/MapboxGlitch

    I also created another recording of the issue using this sample and log output below (Nexus 5X, Adnroid 6.0.1):
    https://dl.dropboxusercontent.com/u/27007357/navenio/glitch.mp4

    11-10 11:29:58.703 14144-14144/glitch.com.glitch D/Glitch: in showPolygon old:outer_polygon.geojson, new:floor_0.geojson
    11-10 11:29:58.720 14144-14144/glitch.com.glitch D/Glitch: read polygons in floor_0.geojson
    11-10 11:29:58.721 14144-14144/glitch.com.glitch D/Glitch: removing old polygons / polylines outer_polygon.geojson
    11-10 11:29:58.744 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:29:58.758 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:29:58.759 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:29:58.759 14144-14144/glitch.com.glitch D/Glitch: adding fillLayer floor_0.geojson_venue
    11-10 11:29:58.760 14144-14144/glitch.com.glitch D/Glitch: adding linesLayer floor_0.geojson_lines
    11-10 11:29:58.760 14144-14144/glitch.com.glitch D/Glitch: --------
    11-10 11:30:03.561 14144-14144/glitch.com.glitch D/Glitch: in showPolygon old:floor_0.geojson, new:floor_1.geojson
    11-10 11:30:03.583 14144-14144/glitch.com.glitch D/Glitch: read polygons in floor_1.geojson
    11-10 11:30:03.584 14144-14144/glitch.com.glitch D/Glitch: removing old polygons / polylines floor_0.geojson
    11-10 11:30:03.602 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:03.612 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:03.612 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:03.613 14144-14144/glitch.com.glitch D/Glitch: adding fillLayer floor_1.geojson_venue
    11-10 11:30:03.613 14144-14144/glitch.com.glitch D/Glitch: adding linesLayer floor_1.geojson_lines
    11-10 11:30:03.614 14144-14144/glitch.com.glitch D/Glitch: --------
    11-10 11:30:06.649 14144-14144/glitch.com.glitch D/Glitch: in showPolygon old:floor_1.geojson, new:floor_0.geojson
    11-10 11:30:06.672 14144-14144/glitch.com.glitch D/Glitch: read polygons in floor_0.geojson
    11-10 11:30:06.673 14144-14144/glitch.com.glitch D/Glitch: removing old polygons / polylines floor_1.geojson
    11-10 11:30:06.698 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:06.712 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:06.713 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:06.713 14144-14144/glitch.com.glitch D/Glitch: adding fillLayer floor_0.geojson_venue
    11-10 11:30:06.714 14144-14144/glitch.com.glitch D/Glitch: adding linesLayer floor_0.geojson_lines
    11-10 11:30:06.714 14144-14144/glitch.com.glitch D/Glitch: --------
    11-10 11:30:13.162 14144-17317/glitch.com.glitch W/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a permanent error: Canceled
    11-10 11:30:13.340 14144-17317/glitch.com.glitch W/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a permanent error: Canceled
    11-10 11:30:13.526 14144-17317/glitch.com.glitch W/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a permanent error: Canceled
    11-10 11:30:13.555 14144-17318/glitch.com.glitch W/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a permanent error: Canceled
    11-10 11:30:20.011 14144-14144/glitch.com.glitch D/Glitch: in showPolygon old:floor_0.geojson, new:floor_1.geojson
    11-10 11:30:20.029 14144-14144/glitch.com.glitch D/Glitch: read polygons in floor_1.geojson
    11-10 11:30:20.029 14144-14144/glitch.com.glitch D/Glitch: removing old polygons / polylines floor_0.geojson
    11-10 11:30:20.048 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:20.058 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:20.058 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:20.059 14144-14144/glitch.com.glitch D/Glitch: adding fillLayer floor_1.geojson_venue
    11-10 11:30:20.059 14144-14144/glitch.com.glitch D/Glitch: adding linesLayer floor_1.geojson_lines
    11-10 11:30:20.059 14144-14144/glitch.com.glitch D/Glitch: --------
    11-10 11:30:26.626 14144-20203/glitch.com.glitch D/GzipRequestInterceptor: Compressing
    11-10 11:30:26.882 14144-20203/glitch.com.glitch D/MapboxEventManager: response code = 204 for events 97
    11-10 11:30:29.023 14144-14144/glitch.com.glitch D/Glitch: in showPolygon old:floor_1.geojson, new:floor_0.geojson
    11-10 11:30:29.046 14144-14144/glitch.com.glitch D/Glitch: read polygons in floor_0.geojson
    11-10 11:30:29.046 14144-14144/glitch.com.glitch D/Glitch: removing old polygons / polylines floor_1.geojson
    11-10 11:30:29.071 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:29.086 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:29.086 14144-14144/glitch.com.glitch W/art: Attempt to remove non-JNI local reference, dumping thread
    11-10 11:30:29.087 14144-14144/glitch.com.glitch D/Glitch: adding fillLayer floor_0.geojson_venue
    11-10 11:30:29.087 14144-14144/glitch.com.glitch D/Glitch: adding linesLayer floor_0.geojson_lines
    11-10 11:30:29.087 14144-14144/glitch.com.glitch D/Glitch: --------
    

    Thanks for taking a look.

  19. ivovandongen commented on Nov 10, 2016

    @ivovandongen
    Contributor

    @damianflannery Thanks for the example code. That cleared things up a lot.

    There is a slight issue in your code that triggers this behaviour. You add sources, but never remove them. The issues start appearing when a source is added twice for the same id it seems. If your remove your source, just as the layers. It works as expected. See this patch for details.

    If you want to get the most out of it in your real application btw, it might be worth toggling the opacity or visibility on layers instead of remove/adding them. This often gives a smoother transition.

  20. damianflannery commented on Nov 10, 2016

    @damianflannery

    Ah, now works perfectly. Thank you @ivovandongen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Androidbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions