Skip to content

fix(mapbox): avoid crash when MapboxOverlay beforeId layer is removed#10425

Open
zbigg wants to merge 1 commit into
masterfrom
zbigg/fix-mapboxoverlay-unknown-layer-crash
Open

fix(mapbox): avoid crash when MapboxOverlay beforeId layer is removed#10425
zbigg wants to merge 1 commit into
masterfrom
zbigg/fix-mapboxoverlay-unknown-layer-crash

Conversation

@zbigg

@zbigg zbigg commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

MapboxOverlay: Skip the attempt to reorder layer with beforeId when layer with beforeId doesn't exist in map instance.

Background:

When a MapboxOverlay layer uses beforeId and the referenced map layer is later removed (e.g. by map.setStyle() unloading it), resolveLayerGroups tried to move the deck layer group before a layer that no longer exists. mapbox-gl's moveLayer throws in that case ("Cannot move layer ... before non-existing layer ..."), and since it splices the group out of the order before throwing, the group is dropped entirely.

Closes #10309

Change List

  • MapboxOverlay: resolveLayerGroups doesn't attempt to move deck layer when it knows beforeId layer is missing

When a MapboxOverlay layer uses `beforeId` and the referenced map layer is
later removed (e.g. by map.setStyle() unloading it), resolveLayerGroups tried
to move the deck layer group before a layer that no longer exists. mapbox-gl's
moveLayer throws in that case ("Cannot move layer ... before non-existing
layer ..."), and since it splices the group out of the order before throwing,
the group is dropped entirely.

Skip the reorder when the beforeId target is not in the current layer order,
leaving the group in place until the reference reappears.
@zbigg zbigg force-pushed the zbigg/fix-mapboxoverlay-unknown-layer-crash branch from 154523f to 9ad4550 Compare July 8, 2026 10:06
@zbigg zbigg marked this pull request as ready for review July 8, 2026 10:14
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 83.138% (+0.003%) from 83.135% — zbigg/fix-mapboxoverlay-unknown-layer-crash into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MapboxOverlay with beforeId crashes the map when the referenced layer is unloaded

2 participants