Avoid loading style source if its layer(s) are not shown#3095
Conversation
There was a problem hiding this comment.
Rename this to isVisible and reverse the boolean, for consistency with "visibility" as from the style spec.
|
Instead of introducing more state, can we use |
871d08c to
e939d94
Compare
Indeed, enabling the source only if the layer is visible in |
0194d2f to
f57e025
Compare
|
There are some corner cases where a layer with a zero-opacity color still renders something, e.g. symbols with halo but transparent fill, background-pattern, outline-only fill layers. Can we limit the check to |
|
Can we make |
670287a to
b52d195
Compare
There was a problem hiding this comment.
Should be a one liner: return !loaded && req.operator bool();
3999815 to
919ef3b
Compare
This is used in I had to fix/modify some style unit tests to adapt to the new scheme for source loading - instead of immediately load sources upon style JSON parsing, we wait to check whether a layer actually needs it. |
There was a problem hiding this comment.
Is this change necessary? I would expect Source:isLoaded() to return true in the case that at some zN, it was enabled and loaded, and then at zM the only layer that used it becomes hidden and the source was therefore disabled.
There was a problem hiding this comment.
Agreed about enabled, but I believe we also should check if there is a pending request, which indicates the source is in loading state.
There was a problem hiding this comment.
Doesn't req imply !loaded though? loaded only gets set to true after all the requests are successful.
There was a problem hiding this comment.
Yes 🎯 Good catch, indeed!
b37a4af to
f270ef6
Compare
f270ef6 to
9d3fe01
Compare
This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two.
This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two.
This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two.
This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two.
Given https://github.com/mapbox/mapbox-gl-styles/blob/master/styles/satellite-hybrid-v8.json as example of a style containing 2+ sources, if all layers related to a specific source are either disabled (e.g. due to class selections) or invisible, we should avoid loading the style source entirely. This saves processing time and network bandwidth.
When the layers related to a specific style source are re-enabled, the burden of loading the style source could be reduced by using a cache file source.
/cc @mapbox/gl @mapbox/mobile