You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
[Android] - Satellite Map Style (or any style) Causes Crash with Layers #8144
Hey there folks, got one for ya that I can't seem to solve. I'm just trying to add some Fill/Line layers to a map that has the Satellite style set. Without that style, everything works perfectly - layers are showing their sources, filters work, etc. However, setting the style causes problems. Layers don't show, and even interacting with the layers in simple ways like getId() causes a native crash. This appears to happen on any device I've tested with (API 16 emulator, S3, Nexus 4, S4).
In onMapReady() callback, set MapboxMap style to Style.SATELLITE.
Add a geoJson source to the map with an id of "A"; make sure it contains at least one valid Polygon feature.
Add one (or more) Fill/Line layers to the map that target the geoJson source "A", with unique ids. Set some color properties to make sure you can see them.
(1) The feature is not visible on the map
In a callback of onMapClick(), call getId() on one of the layers you've added.
Crash.
Expected behavior
The added layers should be visible on top of the satellite imagery
Calling getId() should not crash
Actual behavior
The layers are not visible
Calling getId() crashes
I'm also adding a crash log gist to this - I hope it's helpful. Otherwise, I'm at your disposal for more info. Thanks much for your time!
changed the title [-]Crash - Satellite Map Style Causes Crash With Layers[/-][+][Android] - Satellite Map Style Causes Crash With Layers[/+]on Feb 21, 2017
More info for ya - it looks like setting any style breaks layers. For clarification, I'm setting styles with: mapboxMap.setStyleUrl(Style.SATELLITE);
I've iterated through all of the Style constants, and each seems to have a slightly different problem. Sometimes, it works great on the Emulator but fails on a physical device (S3). Other times, it crashes on the emulator (never works on device).
I've also tried this method:
RasterSource rasterSource = new RasterSource("SP_MAP_RASTER_SOURCE", "mapbox://mapbox.satellite");
RasterLayer rasterLayer = new RasterLayer("SP_MAP_LAYER", rasterSource.getId());
mapboxMap.addSource(rasterSource);
mapboxMap.addLayer(rasterLayer);
But the behavior is almost exactly the same. I can try to get a screen recording if you need a visual example of this as well, but it looks like repro is pretty easy.
changed the title [-][Android] - Satellite Map Style Causes Crash With Layers[/-][+][Android] - Satellite Map Style (or any style) Causes Crash with Layers[/+]on Feb 21, 2017
@tobrun
Results! Still looks a little wonky. Here's what it looks like for three test phones, Nexus 4, Galaxy S3, and API 16 emulator using MapView#setStyleUrl:
Notice the N4 and Emulator are lookin' pretty good. The S3 is totally borked though.
After trying as an XML property, the N4 and emulator ran just as well, but the S3 looked like this:
I tried to capture the first frame coming back as almost correctly rendered, but that pinching/zooming borks it up more.
EDIT:
Here's one more look into the S3, this time when using the RasterSource/Layer method. Of note, the url is mapbox://mapbox.satellite, and the map seems to occasionally load up great when it first appears, but again, the pinch/zoom breaks it:
One more bit of info. It turns out that on 4.2.1 and 4.2.2, the RasterSource/Layer mentioned above for satellite imagery does work on the S3, as well as the other devices - N4, Emulator, etc. However, as soon as you bump to 5.0.0-beta.1, you get the problems shown above.
Hey folks! I see that 5.0.0-beta.2 is on the horizon - nicely done! I'm wondering if this has been looked at some more, or perhaps reproduced / fixed in that new build?
@tikimcfee I was able to reproduce the issue shown in the OP. The underlying issue is that loading a style is asynchronous and you need to wait for that style to be loaded before manipulating the layer and sources.
Option 1
Move mapbox.setStyleUrl before the OnMapReady code block. The OnMapReady callback will be invoked when the style has finished loading.
Feel free to open a separate issue for the rendering part, in #8262 I added style loading with a callback. Thank you for reaching out! Closing as handled.
Activity
[-]Crash - Satellite Map Style Causes Crash With Layers[/-][+][Android] - Satellite Map Style Causes Crash With Layers[/+]tikimcfee commentedon Feb 21, 2017
More info for ya - it looks like setting any style breaks layers. For clarification, I'm setting styles with:
mapboxMap.setStyleUrl(Style.SATELLITE);I've iterated through all of the Style constants, and each seems to have a slightly different problem. Sometimes, it works great on the Emulator but fails on a physical device (S3). Other times, it crashes on the emulator (never works on device).
I've also tried this method:
But the behavior is almost exactly the same. I can try to get a screen recording if you need a visual example of this as well, but it looks like repro is pretty easy.
[-][Android] - Satellite Map Style Causes Crash With Layers[/-][+][Android] - Satellite Map Style (or any style) Causes Crash with Layers[/+]tobrun commentedon Feb 22, 2017
@tikimcfee would you be able to do a quick test and set the style through xml or
MapView#setStyleUrland see if this changes the issue shown in OP?tikimcfee commentedon Feb 22, 2017
@tobrun Hey there! Absolutely - just stepped in, so I'll give the programmatic setter and xml property a try right now.
tikimcfee commentedon Feb 22, 2017
@tobrun
Results! Still looks a little wonky. Here's what it looks like for three test phones, Nexus 4, Galaxy S3, and API 16 emulator using
MapView#setStyleUrl:Notice the N4 and Emulator are lookin' pretty good. The S3 is totally borked though.
After trying as an XML property, the N4 and emulator ran just as well, but the S3 looked like this:
I tried to capture the first frame coming back as almost correctly rendered, but that pinching/zooming borks it up more.
EDIT:
Here's one more look into the S3, this time when using the RasterSource/Layer method. Of note, the url is
mapbox://mapbox.satellite, and the map seems to occasionally load up great when it first appears, but again, the pinch/zoom breaks it:tikimcfee commentedon Feb 22, 2017
One more bit of info. It turns out that on 4.2.1 and 4.2.2, the RasterSource/Layer mentioned above for satellite imagery does work on the S3, as well as the other devices - N4, Emulator, etc. However, as soon as you bump to 5.0.0-beta.1, you get the problems shown above.
tikimcfee commentedon Feb 28, 2017
Hey folks! I see that 5.0.0-beta.2 is on the horizon - nicely done! I'm wondering if this has been looked at some more, or perhaps reproduced / fixed in that new build?
tobrun commentedon Feb 28, 2017
Haven't pinpointed the source of this issue yet, adding this to the 5.0.0 milestone to not forget to look into this before an actual release.
tikimcfee commentedon Feb 28, 2017
@tobrun That's awesome - thank you so much for the tag! Also, side note, hope the S3 outage isn't killing you guys...
tobrun commentedon Mar 1, 2017
@tikimcfee I was able to reproduce the issue shown in the OP. The underlying issue is that loading a style is asynchronous and you need to wait for that style to be loaded before manipulating the layer and sources.
Option 1
Move mapbox.setStyleUrl before the OnMapReady code block. The OnMapReady callback will be invoked when the style has finished loading.
Option 2
Listen to an event that the style has finished loading by using the OnMapChangeListener:
Some follow up questions related to rendering on the s3.
tobrun commentedon Mar 10, 2017
Feel free to open a separate issue for the rendering part, in #8262 I added style loading with a callback. Thank you for reaching out! Closing as handled.