-
Notifications
You must be signed in to change notification settings - Fork 1.3k
onMapReady() callback called before style is loaded. #6032
Comments
Thanks for checking @frederoni! The issue probably lies in this callback here then: https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java#L442 We might want to refactor this a bit to make the intention clearer as well. |
This doesn't affect iOS and probably not macOS either. |
Two items impacted that implementation:
Need to do some digging if you need concrete ticket info but these are some items to test for. update: related issue #4393 |
Just confirmed that changing @jfirebaugh Can you confirm the status of this in core. Is it safe to react to |
I'm taking up the testing the offline and marker issue. I kinda remember the use-cases around this. |
The offline case seems to work fine for built-in styles. I still get a onMapReady callback when going into flight mode after downloading a region. |
Noting that #6121 would result in errors when users mutate the style in the callback and it's not fired at the right time. |
Tested changing the timing of the callback to be only after the map has loaded (commit).This works correctly in all online cases, also fixing the issue with manipulating the styles directly in the callback when nothing is cached yet. In offline cases though we need to set the expectations. With this change, the callback is only fired when all sources + the style are loaded for the current viewport. This differs from previous behaviour where the callback is fired as soon as the the map is about to render. The main question is; do we want the callback to fire when at least the style is loaded? (see #4393 for reference on the initial change) |
From what I understand, this is not a regression like in #4393 when no callback was fired, and it's also consistent with the current behavior on iOS. I think this is an acceptable solution, we need to make sure this is documented and pointed out in the examples. |
I added a PR (#6371) to add a signal when the style is loaded like @tmpsantos suggests in #4527. This enables us to reliably fire the |
When using the runtime style api to manipulate layers / sources it seems that the
onMapReady
callback is called to early when the style is not yet in cache. For example, in the following snippet the fill layer will not be colored when the cache is cleared for the app (and thus all cached resources, incl the style are cleared). However, once the style is cached, the example works properly.cc @jfirebaugh
The text was updated successfully, but these errors were encountered: