Skip to content

fix(maplibre): sync camera changes made during Deck initialization - #10702

Merged
chrisgervang merged 3 commits into
visgl:masterfrom
birkskyum:fix/maplibre-initial-camera-sync
Sep 20, 2026
Merged

chrisgervang merged 3 commits into
visgl:masterfrom
birkskyum:fix/maplibre-initial-camera-sync

Conversation

@birkskyum

@birkskyum birkskyum commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Interleaved overlays retain their initial camera state if the map moves after map.addControl(overlay) but before Deck finishes initializing. For example, an immediate map.jumpTo(...) leaves Deck's view state and projected coordinates stale until another camera move.

Refresh the view state and register movement listeners before calling the app's onLoad callback. Regression tests cover MapLibre 4.5.1, 5.0.0, and 6.0.0, including camera reads and moves inside onLoad. All three fail on master and pass with this fix.

Split from #10697 following review feedback.


Note

Medium Risk
Touches interleaved overlay startup ordering and view-state sync; behavior change is narrow but affects all MapLibre interleaved integrations at first paint.

Overview
Fixes interleaved MapLibreOverlay keeping a stale Deck camera when the map moves after addControl but before Deck finishes loading.

In deck-utils, the wrapped Deck onLoad now starts move listeners, runs onMapLibreMove to pull the current MapLibre view into Deck, and only then invokes the app onLoad. That way jumpTo / camera updates during the init window are reflected in view state and projection before consumer code runs.

Adds WebGL regression tests (overlay-startup.spec.ts) for MapLibre 4.5.1, 5.0.0, and 6.0.0 that move the camera before load and assert view state and screen projection inside onLoad.

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

@birkskyum
birkskyum marked this pull request as ready for review September 11, 2026 19:47
@greptile-apps

greptile-apps Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the startup synchronization order is intentional and exercised by focused multi-version regression coverage.

Summary

This PR synchronizes an interleaved Deck instance with MapLibre’s current camera before invoking the application’s onLoad callback.

  • Registers the map movement listener before application startup code runs
  • Refreshes Deck’s view state after asynchronous initialization
  • Tests startup and callback-time camera changes across MapLibre 4, 5, and 6
Diagram
sequenceDiagram
    participant Map as MapLibre
    participant Deck
    participant App as Application onLoad

    Map->>Deck: Add interleaved overlay
    Map->>Map: Camera changes while Deck initializes
    Deck->>Deck: Initialization completes
    Deck->>Map: Register move listener
    Map->>Deck: Supply current camera state
    Deck->>App: Invoke onLoad
    App->>Map: Optional camera change
    Map->>Deck: Synchronous move event
    Deck->>Deck: Refresh view state
Loading

Reviews (3) · Last reviewed commit: "Merge branch 'master' into fix/maplibre-..."

@chrisgervang
chrisgervang merged commit 8d7b20a into visgl:master Sep 20, 2026
6 checks passed
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 82.484% (-0.002%) from 82.486% — birkskyum:fix/maplibre-initial-camera-sync into visgl:master

@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.1. Thanks @birkskyum!

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.

3 participants