-
-
Notifications
You must be signed in to change notification settings - Fork 932
Description
maplibre-gl-js version: 5.13.0
browser: Chrome
Steps to Trigger Behavior
- In the JSBin linked below, click anywhere to trigger updateData with an undefined property.
More generally this issue occurs when using updateData on a GeoJSON source and any of the feature's properties are undefined.
Link to Demonstration
https://jsbin.com/hiwawahida/edit?html,console,output
Expected Behavior
Using updateData updates the features, working with undefined features just like setData does.
This should work because the GeoJSON properties types allow it. The fact that maplibre is using MVT which don't allow undefined properties under the hood should be considered an implementation detail, and maplibre should be responsible for stripping out invalid properties so that this case doesn't throw. This would match the behavior in the setData case. More detail on the reason this broke below.
Actual Behavior
Using updateData with an undefined property results in an uncaught error (unknown feature value).
Console error:
at index.js:361:15
at Mu (index.js:339:44)
at wc.readFields (index.js:42:13)
at new Eu (index.js:307:13)
at Fu (index.js:385:23)
at wc.readFields (index.js:42:13)
at new ku (index.js:374:27)
at wf.loadVTLayers (feature_index.ts:122:19)
at ee.shouldReloadTile (geojson_source.ts:519:48)
at Ie.reload (tile_manager.ts:282:91)
This is because we're hitting the case in mapbox/vector-tile's readValueMessage where the value read is null. In the 2.0.4 dependency, this case throws. Check out the code here at index.js line 360. Maplibre upgraded to this dependency in 5.6.2 via this PR #6131. The previous version, 1.3.1, did not throw when encountering a null value (see https://www.npmjs.com/package/@mapbox/vector-tile/v/1.3.1?activeTab=code lib/vectortilelayer.js line 50).
At a higher level, this likely happens because of the difference in how the "data" case is handled here vs the "diff" case (corresponding to setData vs updateData).