mapbox-gl-js version: v1.2.1
browser: Chrome Version 70.0.3538.77 (Official Build) (64-bit)
https://jsbin.com/yuruvibiqa/edit?html,js,output
I removed my mapboxgl.accessToken.
The error occurs after the setTimeout function removes a layer.
setFeatureState works as intended.
setFeatureState throws the following error:
Uncaught TypeError: Cannot read property 'queryRadius' of undefined
at Ou.setFeatureState (tile.js:464)
at Vu.coalesceChanges (source_state.js:154)
at i.prepare (source_cache.js:170)
at ao.render (painter.js:340)
at r._render (map.js:1753)
at map.js:1837
@econ24 Thank you for reporting this issue. I am not able to reproduce the bug in the jsfiddle. It looks like the style used in the demo is private and cannot be accessed by other access tokens.
Could you provide a demo with a public style or one that uses a mapbox style or other simplified style where this issue can be reproduced.
I updated the fiddle with a public style. I don't believe the mapbox account I am using is an enterprise account so the tileset should be public.
I experience this bug too. It is very annoying when switching between layers by adding and removing them.
We are experiencing the same issue. Appears to be happening through switching layers and use of feature state.
I'm facing this issue as well, under the same conditions of @econ24.
Mapbox GL version I'm using is v0.54.0 but I've tried also with v1.6.0 which presents the same behavour...

Did a little investigation to understand what is causing this issue.
When a layer is removed, it is marked for removal and then processed on the next render by updating the grouping of layers in the works by these two chunks
The update layer index is not re-applied to the tiles though, so existing buckets on the main thread continue to hang on to removed layer ids and are being processed unneccesarily at:
The shortcut to fix this would be to add a null guard on painter.style.getLayer(id) before further processing for that layer id. But this does not solve the root cause, which is that tiles and buckets on the main thread have not been notified of removed layers. This may also be true of updated layers, but I have not confirmed that as of yet.