Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

3.33: `TypeError: Cannot read properties of undefined (reading 'fill')` in `appendZOffset` during symbol placement (zero-vertex symbols)

Open Beginner friendly
#13,746 0 comments 0 reactions 0 assignees View on GitHub

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
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

auto-triaged bug :lady_beetle:
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': true over fill-extrusion layers.
  • Some symbols are icon-only (no text), e.g. text-field evaluates 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/mapbox-gl-js

All issues in mapbox/mapbox-gl-js

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.