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

Efficiently apply style changes #2445

Closed
2 tasks
kkaefer opened this issue Sep 29, 2015 · 7 comments
Closed
2 tasks

Efficiently apply style changes #2445

kkaefer opened this issue Sep 29, 2015 · 7 comments
Labels
performance Speed, stability, CPU usage, memory usage, or power usage

Comments

@kkaefer
Copy link
Member

kkaefer commented Sep 29, 2015

In JS, we have a way to compute the difference between two styles, and only selectively reparse tiles. This is very useful in Native as well, as it'd allow us to rapidly switch styles without seeing a flash of an empty map. Also see mapbox/mapbox-gl-js#1341.

  • Figure out a way to reparse individual layers of a tile and how buffer uploads are handled
  • Compute differences between style objects, e.g. by creating a hash of all properties of a layer
@mourner
Copy link
Member

mourner commented Sep 29, 2015

cc @scothis

@jfirebaugh
Copy link
Contributor

Note that style diffing is not currently built in to mapbox-gl-js: it's an external function which produces a set of commands to run in a batch style change.

@jfirebaugh jfirebaugh added the performance Speed, stability, CPU usage, memory usage, or power usage label Sep 29, 2015
@scothis
Copy link

scothis commented Sep 30, 2015

Batching style mutations is what gave us the greatest perf boost, followed by the style diff. Diff'ing without batching is most likely a perf hit rather than a gain (for a non-trivial delta).

I'd like to keep the diff format compatible between JS and native if at all possible, although the JS diff is biased towards the mapbox-gl-js API.

@jfirebaugh
Copy link
Contributor

I'd like to keep the diff format compatible between JS and native if at all possible, although the JS diff is biased towards the mapbox-gl-js API.

Me too, which means the first part of this change is porting all the JS style mutation APIs. It's something we've been meaning to do for quite some time, but a substantial change in and of itself.

@scothis
Copy link

scothis commented Sep 30, 2015

It's also worth mentioning that mapbox-gl-js does not support every diff operation. In studio when we apply the diff, we fall back to a full setStyle if a particular operation is unsupported.

The most important operations to support are:

  • addLayer
  • removeLayer
  • setLayoutProperty
  • setPaintProperty

From there add support for any operation you see that frequently causes a setStyle fallback.

The semantics around add/removeLayer are particularly important to get right as the diff is optimized to avoid unnecessary work. For example, if you move a layer and change a property the diff will be two operations: removeLayer and addLayer.

@jfirebaugh
Copy link
Contributor

Depends on #837, more or less.

@jfirebaugh
Copy link
Contributor

#7893

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

No branches or pull requests

4 participants