Skip to content

fix(google-maps): follow rendering type changes and remove containers - #10901

Merged
chrisgervang merged 11 commits into
masterfrom
chr/google-maps-remove-container
Nov 3, 2026
Merged

chrisgervang merged 11 commits into
masterfrom
chr/google-maps-remove-container

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10789

Background

When a vector map can't run, Google reports VECTOR and then falls back to RASTER. GoogleMapsOverlay only listened for renderingtype_changed while the type was UNINITIALIZED, so an overlay bound during that window kept its WebGLOverlayView and drew nothing.

The overlay also never removed #deck-gl-google-maps-container, and getContainer found that container by id. A later overlay on the same map therefore went into the stale container, offset by half the map.

This is separate from #10843, which fixes the offset under a CSS transform. The two merge cleanly.

Change List

  • setMap always listens for renderingtype_changed, and on a change it re-creates the overlays and the deck. The listener is removed on unbind.
  • The positioning overlay removes its container in onRemove.
  • createDeckInstance takes the element to place the deck in, and moves a reused deck there.
  • destroyDeckInstance removes the deck container. This includes a device prop's canvas, which Deck does not own.
  • Tests: finalize cleanup, binding again, and the vector-to-raster fallback.

Note

Low Risk
Changes are isolated to @deck.gl/google-maps overlay lifecycle and DOM container management, accompanied by comprehensive unit tests.

Overview
Dynamically handles Google Maps rendering type transitions, including runtime fallbacks from Vector to Raster rendering when WebGL is unsupported. When the rendering type changes, existing overlays and Deck instances are safely torn down and reinitialized, guarding against stale lifecycle callbacks and clearing finalized layers.

Improves DOM container lifecycle management by directly tracking and removing the positioning container when overlays are unbound. Stale DOM nodes are now explicitly cleaned up during deck destruction, preventing orphaned containers and alignment offsets when overlays are rebound to a map.

Reviewed by Cursor Bugbot for commit c9ea34c. Bugbot is set up for automated code reviews on this repo. Configure here.

GoogleMapsOverlay now re-creates its overlays when Google falls back
from a vector map to a raster map, and removes the positioning
container and the deck container when they are no longer used, so a
later overlay on the same map is not offset by half the map.
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

GoogleMapsOverlay now follows rendering-type changes and removes leftover containers.

  • Google Maps overlays replace decks when map rendering or context changes.
  • Google Maps overlays remove stale containers and reuse their deck when rebound.

The previous threads are unnumbered, so they have no entries in previousFindings. Their fixes remain covered by the current code and tests. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Rendering type changes] --> B[Remove old overlays and containers]
  B --> C[Destroy old Deck]
  D[Vector context lost] --> C
  C --> E[Drop finalized layers]
  E --> F[Create Deck for the current rendering path]
  F --> G[onLoad supplies fresh layers]
  G --> H[Draw layers]
Loading

Reviews (11) · Last reviewed commit: "fix(google-maps): supply layers in onLoa..." · Reviewed by Greptile

Comment thread modules/google-maps/src/utils.ts Resolved
@coveralls

coveralls commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.457% (+0.05%) from 84.408% — chr/google-maps-remove-container into master

chrisgervang and others added 2 commits October 23, 2026 15:55
Removing the overlay hides all layers with layerFilter, and a reused
deck kept that filter. The fallback test now supplies the vector map's
context, so it checks that the deck is replaced.
@chrisgervang
chrisgervang requested a review from ibgreen October 23, 2026 23:30

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at the author's request. Note: the latest Greptile review raised an unresolved P1 about reusing finalized layer instances after vector-to-raster fallback; please address and test the initialized-layer fallback path.

@chrisgervang chrisgervang mentioned this pull request Oct 26, 2026
53 of 66 tasks
… a fallback

Destroying the vector map's deck finalizes its layers, and a finalized
layer cannot be added to another deck. The overlay now copies its layers
before creating the raster deck. The fallback test initializes a layer
first and checks that the raster deck draws a copy with live buffers.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread modules/google-maps/src/utils.ts Resolved
@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
29 of 30 tasks
…fter a fallback

- Copy the layers before destroying the deck, with the values the app supplied for transformed
  async props: initialization replaced a direct image with a texture that the deck deletes
- Copy the layers when the vector map's context is lost too, which can come before the fallback
- Ignore callbacks from a WebGLOverlayView after it is replaced, e.g. a late onContextLost
Comment thread modules/google-maps/src/utils.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

- Copy the loaded data of a layer streamed from an async iterable, which can only be read once,
  without applying dataTransform again
- Replace the layers that a destroyed deck finalized with their copies when the app passes them again
Comment thread modules/google-maps/src/utils.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread modules/google-maps/src/utils.ts Resolved
… copying them

A deck that replaces the vector map's deck now drops the layers that the destroyed deck
finalized, rather than copying them. Reusing them would pass their finalized state to new
layers with the same id. The docs explain that the app supplies new layer instances, e.g.
from a renderingtype_changed listener.
…is lost

Only a rendering type change removes the finalized layers. When the context is lost and
restored without one, the app has no event to supply new layers from.
@chrisgervang

chrisgervang commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Change of approach: e061fa5 and c9ea34c replace the layer copying from 6ae3198 and 2c3f555.

Copying a finalized layer for the new deck meant rebuilding the prop values that initialization had replaced: an image that became a texture, or an async iterable that was already read. Each case needed its own handling, and an app could still pass the original instances again.

Now, whenever the overlay destroys its deck, it removes from its props the layers that deck drew. That happens when Google falls back from a vector map to a raster map, and when an interleaved vector map loses its WebGL context. A layer that was never drawn is kept, e.g. when Google falls back before the first frame. The app supplies new layer instances in onLoad, which runs for each deck the overlay creates. The overlay docs describe this.

The layers have to be removed, not just left in place. A finalized layer in the new deck would pass its finalized state to a new layer with the same id, so the app's new layers wouldn't draw either.

Known limitation: passing the old instances again doesn't draw them. The docs say to create new ones.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2504a39. Configure here.

A restored context also gets a new deck, which can't draw the layers that the lost deck
finalized. The overlay removes them on both paths, and the docs point to onLoad, which runs
for each deck that the overlay creates, instead of a renderingtype_changed listener.
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

@greptile-apps re-review

@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Nov 3, 2026
@chrisgervang
chrisgervang merged commit d655927 into master Nov 3, 2026
9 checks passed
@chrisgervang
chrisgervang deleted the chr/google-maps-remove-container branch November 3, 2026 07:20
chrisgervang added a commit that referenced this pull request Nov 6, 2026
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.4.2.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GoogleMapsOverlay does not follow Google's vector-to-raster fallback, and finalize() leaves its positioning container

3 participants