Mapbox-gl-js: `map.setLayoutProperty('layerID', 'visibility', 'none')` will trigger duplicate http request

Created on 22 Oct 2018  路  6Comments  路  Source: mapbox/mapbox-gl-js

mapbox-gl-js version: 0.49.0

Question

simple hidden a raster layer map.setLayoutProperty('layerID', 'visibility', 'none') will duplicate http request`

Is it a special feature or something need improved?

step

  1. add a raster layer with google map source.and clear network console
    image

  2. hidden raster layer by map.setLayoutProperty('layerID', 'visibility', 'none'),and you will find it trigger duplicate http
    image

performance

Most helpful comment

Hey, we have the same issue with the latest version (1.1.0), I see it was mentioned this was fixed by #7459, but #7459 is actually this issue...

All 6 comments

Is it a special feature or something need improved?

I think visibility should not trigger source reload. Could somebody identify which ones layout property should trigger sourceCache.reload like paint property.
image

visibility is a layout property and source reloads are generally necessary for layout property changes. However, the case you describe is a little bit special because by setting the visibility to none, you're removing the last layer that uses the source. The code in Style#update triggers a reload of the source first, and then after triggering the reload it does the calculation to determine which sources are used, at which point it clears out the tile set for the hidden source. Although the tile set is cleared out almost immediately after the reload is triggered, the first messages get sent to the workers and they trigger the network activity you see (although it should be pretty cheap since the tiles are already loaded and they haven't expired).

https://github.com/mapbox/mapbox-gl-js/blob/1d734caa57d9b591ad93bfa569b150d8c7b3671f/src/style/style.js#L343-L395

I found that the branch of 0.20.0 version of the same code, the request is not made, the new code on request

This was likely fixed by #7459. I'll reopen if it's not the case.

Hey, we have the same issue with the latest version (1.1.0), I see it was mentioned this was fixed by #7459, but #7459 is actually this issue...

Oh, I meant #8005. Let's reopen and check again then.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BernhardRode picture BernhardRode  路  3Comments

rigoneri picture rigoneri  路  3Comments

aaronlidman picture aaronlidman  路  3Comments

foundryspatial-duncan picture foundryspatial-duncan  路  3Comments

aendrew picture aendrew  路  3Comments