-
Notifications
You must be signed in to change notification settings - Fork 1.3k
style revalidation vs. runtime styling #5665
Comments
This would require the developer to maintain their own representation of the sources, layers, and styles independently of the platform wrappers around
Either of these sounds great to me. The main use case for refreshing a style would be that the developer has published an update to their style in Studio and wants to see it reflected in the client application. (But anyways, the real answer for that need would be an explicit reload mechanism rather than an implicit one that runs on a timer.) |
Sounds good to me. This will also align with the behavior of |
Good insight @jfirebaugh - I ought to prefer this option as it involves less complexity and avoids corner cases. |
I think adding a "style reloaded" event is a mistake, since it seems redundant and just bloats the API. "Turn off midstream revalidation of styles entirely...", makes the most sense to me for exactly the reasons you mention. Revalidate upon initial load, but I think relying on periodic revalidation is a mistake. If the goal is to support live-authoring styles, or to support live-updating customer maps, then I think that feature should be implemented explicitly, not hidden in the request handler for the style asset. "Diff and patch" is really more of an optimization on top of reloading the style. It doesn't really answer the question of "should we be reloading the style on revalidation?". If the answer to that question is "we should reload only what changed", then i think the "correct" thing to do is probably reload the whole style now, and optimize the style updates later. |
Sounds like the consensus is converging on revalidating the style once, at load, and then not revalidating while in use. @kkaefer does this strategy sound ok to you? |
I don't think this is the way to go either, since it means users have to keep track of all of their edits.
This sounds good, but one thing to consider is the fully-offline use case: We are currently relying on loading expired/outdated/stale styles from the cache with the expectation that they could be updated later one once the user gained internet connectivity. Disabling style modifications until the refresh succeeded is awkward since that could potentially never happen, and allowing style modification before the initial refresh happens puts us into the same position. |
I don't think we would wait for the revalidation to succeed. We would attempt a reload when the style is first loaded, but if it fails then we would not retry when the user gets connectivity. I don't think we should ever disable runtime edits to the style, but if we can't guarantee that we can replay changes on top of a refreshed style due to potential differences, then we should never implicitly cause a style reload that would destroy runtime changes by the user. If the user made their own changes to the style, I think it's safe to say that for that particular user the local changes are more important than any possible remote changes. An explicit style change would initiate a new request, which would cause the correct didFinishLoading events to fire, so if the user wanted to try to update their style they have the option of re-requesting it manually. |
OK, so:
|
I like it. FWIW I also lean towards revalidating once. |
Another vote for:
Wasn't this:
Because of wanting the ability to refresh annotation-like objects on the map midstream by way of backend data updates changing the style? If so, is that use case met sufficiently by the runtime style API now? |
@incanus Data updates typically happen via revalidation of tiles or (less commonly) GeoJSON source URLs. I'm not aware of any use cases that require style revalidation to update data. |
You are right @jfirebaugh, I was confusing style and tile here. |
Currently, a style loaded via URL is revalidated on a schedule defined by the caching-related headers on the HTTP response. If a revalidation indicates that the style has changed, a new style object is created, replacing the old one wholesale. This poses a challenge for the runtime styling API. In the current naive implementation, any mutations to the style via runtime styling APIs are discarded when revalidation results in a new style:
Source
orLayer
objects in the existing style are invalidatedAll of these effects are likely to vex SDK users, many of whom are unaware of the revalidation behavior, and often not in control of the caching headers in any case. See #5581 for an early example.
To mitigate this, there are several approaches we could pursue:
I currently lean toward one of the two middle options.
The text was updated successfully, but these errors were encountered: