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

[Core] load style URL does not behave correctly #11356

Closed
RomainQuidet opened this issue Mar 1, 2018 · 2 comments
Closed

[Core] load style URL does not behave correctly #11356

RomainQuidet opened this issue Mar 1, 2018 · 2 comments

Comments

@RomainQuidet
Copy link
Contributor

RomainQuidet commented Mar 1, 2018

Platform: all
Mapbox SDK version: ios 3.7.5

Steps to trigger behavior

  1. Set a map style server
  2. Launch your app and use this style
  3. modify the style by adding custom layers
  4. update your server style (same url)

Expected behavior

When the style in cache expires, it must reload it from the web

Actual behavior

the style is never fetched from the server because of conditions (mutated) which cancel the online fetch after the offline fetch.

In style_impl.cpp, the loadURL() method creates a request against an URL. It first fetch the style data from the cache and then launch an online request.
Because we mutated the style by adding layers for our own usage, the load URL falls into the condition "mutated" and then reset the request -> the online data is never received.

I don't understand why when we mutate the map we can not parse new data as it might be a complete different URL.

The faulty timeline:
load Style A
---> load sytle json from cache
---> parse the data
------> set style as loaded
------> call the observer callback onStyleLoaded (Style is loaded, we add our custom layer => mutated = true, loaded = true)

load Style B
---> load style json from cache. Style data are expired.
---> cancel the online fetch with styleRequest.reset() as map is mutated. ==> WHY ?????!

That's it.
The second condition (mutated && loaded) seems also faulty as it can have been through the offline fetch, map is loaded, mutated then the online fetch comes du to slow internet connection. In this case we won't use the updated data to display the map (which will be in cache...).

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Mar 1, 2018

This is expected behavior; see #5665. We did recently adjust the behavior to ensure that an updated style makes it into the cache, such that it will take effect if the map view is re-created or the app relaunched (#11270). Future plans are discussed at the tail end of mapbox/mapbox-gl-js#4225.

@RomainQuidet
Copy link
Contributor Author

Hi,
Glad to see that you made the same findings as I did, thanks for the references.
Choosing not to update the map style freshly fetched from the servers might not fit our use case, but I understand the modifications on maps are not all tracked to be reapplied in this case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants