Repository navigation
fix(google-maps): follow rendering type changes and remove containers - #10901
Conversation
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.
[Medium impact] The PR appears safe to merge; no new blocking issues were found. Summary
The previous threads are unnumbered, so they have no entries in
|
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.
ibgreen
left a comment
There was a problem hiding this comment.
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.
… 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.
…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
- 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
… 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.
|
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 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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.
|
@greptile-apps re-review |
|
Released in deck.gl 9.4.2. |

Fixes #10789
Background
When a vector map can't run, Google reports
VECTORand then falls back toRASTER.GoogleMapsOverlayonly listened forrenderingtype_changedwhile the type wasUNINITIALIZED, so an overlay bound during that window kept itsWebGLOverlayViewand drew nothing.The overlay also never removed
#deck-gl-google-maps-container, andgetContainerfound 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
setMapalways listens forrenderingtype_changed, and on a change it re-creates the overlays and the deck. The listener is removed on unbind.onRemove.createDeckInstancetakes the element to place the deck in, and moves a reused deck there.destroyDeckInstanceremoves the deck container. This includes adeviceprop's canvas, which Deck does not own.finalizecleanup, binding again, and the vector-to-raster fallback.Note
Low Risk
Changes are isolated to
@deck.gl/google-mapsoverlay 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
Deckinstances 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.