3.33: `TypeError: Cannot read properties of undefined (reading 'fill')` in `appendZOffset` during symbol placement (zero-vertex symbols)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- frontend
Research direction
Search for appendZOffset and updateZOffset in the symbol placement/bucket code; updateZOffset calls appendZOffset even when a vertex count is zero. Read the StructArray resize behavior to confirm that resize(0) leaves float32 undefined, then add the suggested guard for zero vertices. Done means an icon-only symbol layer with symbol-z-elevate over fill-extrusion layers renders without the fill TypeError.
Written by the indexing model from the issue text.
Description
mapbox-gl-js version
v3.33
Browser and version
Chrome 13x on macOS; also headless Chrome (SwiftShader).
Expected behavior
No response
Actual behavior
Error
TypeError: Cannot read properties of undefined (reading 'fill')
at appendZOffset
at SymbolBucket.updateZOffset
at Placement.placeLayerBucketPart
at PauseablePlacement.continuePlacement
at Style._updatePlacement
at Map._render
Cause
3.33 added z-offset scratch arrays and frees zOffsetVertexArray after upload:
function appendZOffset(array, numVertices, value) {
const start = array.length;
array.resize(start + numVertices);
array.float32.fill(value, start, start + numVertices);
}
A newly constructed StructArray has capacity = 0 and no arrayBuffer or typed views until a
resize grows it. updateZOffset() calls appendZOffset for every symbol instance, including
counts that are 0 (numVerticalGlyphVertices for almost every symbol, and
numHorizontalGlyphVertices for icon-only symbols).
When the target array has never been allocated and the first call passes numVertices === 0,
resize(0) allocates nothing. array.float32 is then undefined, and .fill throws.
The bucket's text.zOffsetVertexArray is used when no zOffsetVertexBuffer exists yet, so the
array is fresh in exactly that case. It's data dependent: a tile whose first z-elevated symbol has
no text glyphs throws on most frames.
Reproduction
- A symbol layer with
'symbol-z-elevate': trueoverfill-extrusionlayers. - Some symbols are icon-only (no text), e.g.
text-fieldevaluates to''for some features. - Pan or switch filters so placement re-runs and z-offsets change. In our app (indoor maps with
icon-only POIs on extruded floors) it fires on most loads for one venue and rarely for another.
Suggested fix
Skip the fill when there's nothing to fill:
function appendZOffset(array, numVertices, value) {
if (!numVertices) return;
const start = array.length;
array.resize(start + numVertices);
array.float32.fill(value, start, start + numVertices);
}
(We're applying the equivalent guard to the dist builds as a workaround. It stopped the crash in
our tests: 1–2 errors per run before, 0 after.)
Link to the demonstration
No response
Steps to trigger the unexpected behavior
No response
Relevant log output
- Dominant language
- TypeScript
- Stars
- 12.5k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/mapbox-gl-js
-
TypeError: Cannot read properties of undefined (reading 'get') when a map is removed while a color-theme LUT is decodingPossibly taken @Piyush495 claimed this 22 days ago. Openauto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
mapbox/mapbox-gl-js#13737 · 1 comment ·
-
auto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mapbox/mapbox-gl-js#13723 · 2 comments ·
-
auto-triaged bug :lady_beetle:
Difficulty 1/5 Under an hour Newbie friendliness 86/100
mapbox/mapbox-gl-js#13717 ·
-
>= v3.21 Symbol layer without feature-state expression crash the mapPossibly taken @liueric-dev claimed this 63 days ago. Openauto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
mapbox/mapbox-gl-js#13714 · 1 reaction ·
-
auto-triaged feature :green_apple:
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
mapbox/mapbox-gl-js#13676 · 2 comments ·
All issues in mapbox/mapbox-gl-js
Similar issues
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrorsPossibly taken @as992949791 claimed this today. Opengood first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
reticlehq/reticle#2033 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:quality p3-medium ready-for-agent type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
fderuiter/deruiter.dev#3589 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
manfredsteyer/angular-oauth2-oidc#1514 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
marmelab/react-admin#11431 ·
Maintainers usually reply within 1 day