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

Implement 'smart' setStyle using diff-and-patch technique #7893

Closed
7 tasks
anandthakker opened this issue Jan 28, 2017 · 4 comments · Fixed by #9256
Closed
7 tasks

Implement 'smart' setStyle using diff-and-patch technique #7893

anandthakker opened this issue Jan 28, 2017 · 4 comments · Fixed by #9256
Assignees
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS performance Speed, stability, CPU usage, memory usage, or power usage

Comments

@anandthakker
Copy link
Contributor

anandthakker commented Jan 28, 2017

tl;dr: port smart setStyle from GL JS.

@jfirebaugh @lucaswoj @mapbox/gl here's my thinking after my (very) initial digging around the gl-native world. Feedback of course very welcome -- my hope is to dive in and start making a mess mid-next week.

Motivation

  • Force a helpful refactor making mbgl::Style independent of mbgl::Map
  • Provide an alternate path for paint-class-specific properties, which are now deprecated in the style spec, GL JS, and the iOS SDK.

Plan

  • Make mbgl::Style independent of mbgl::Map
  • Introduce 'nested styles', or some alternative.
    • Reason: on its own, a smooth setStyle implementation is not a complete replacement for paint classes. The problem is that the Style can accumulate state--e.g., by way of runtime styling or GeoJSONSource#setData()/mbgl::GeoJSONSource::setGeoJSON. With paint classes, it's very easy to have a set of basemap layers with alternative styling for, say, 'day' and 'night' and some interactive layers on top of it. Nested styles doesn't address the GeoJSON source part, but see below under "Design mbgl::Map::setStyle".
  • Expose means to create independent style in SDKs
  • Design mbgl::Map::setStyle(Style, ...?)
  • Implement mbgl::Map::setStyle() using diff-and-patch method and expose it in SDKs
    • Not having dug into this yet, it seems like a clean way to do this would be to diff the given Style against the map's current one, and then apply the necessary operations to the current one. But doing it this way, it might be weird that after calling map->setStyle(nextStyle), nextStyle won't refer to the map's actual style object.

Related: Efficiently apply style changes #2445

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Jan 30, 2017

Are "nested styles" necessarily a dependency of the other work here? If possible let's decouple that. They're both going to be pretty challenging on their own.

it might be weird that after calling map->setStyle(nextStyle), nextStyle won't refer to the map's actual style object.

What would it take to make that happen? It seems like it might be possible to transfer ownership of the internal data that sticks around (tile and bucket objects) to nextStyle.

How should this handle Sources that carry state?

For now I don't think we should try to preserve any GeoJSON state that isn't present in the incoming style.

@anandthakker
Copy link
Contributor Author

For now I don't think we should try to preserve any GeoJSON state that isn't present in the incoming style.

I think this may present a performance issue. If a GeoJSON source has a large literal value, then setStyle would have to either (a) do a fresh setData() every time or (b) do a deep equality check to determine whether or not the call to setData() is needed.

@anandthakker
Copy link
Contributor Author

Update: per chat w/ @jfirebaugh and @lucaswoj , removed "nested styles", to be discussed/developed separately.

This was not a strict prerequisite for 'smart setStyle', but this or some alternative would be necessary in order for setStyle to be a genuine, reasonably-usable replacement for paint classes -- particularly when used in conjunction with a lot of runtime styling or dynamic data.

@friedbunny friedbunny added Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS performance Speed, stability, CPU usage, memory usage, or power usage labels Feb 11, 2017
@jfirebaugh jfirebaugh self-assigned this May 3, 2017
@jfirebaugh
Copy link
Contributor

Looks like we're going to get this as a byproduct of #8820.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants