fix(mapbox,google-maps): use css-dpr pixel sizing in overlaid mode to prevent basemap misalignment#10370
Open
chrisgervang wants to merge 8 commits into
Open
fix(mapbox,google-maps): use css-dpr pixel sizing in overlaid mode to prevent basemap misalignment#10370chrisgervang wants to merge 8 commits into
chrisgervang wants to merge 8 commits into
Conversation
… prevent basemap misalignment At fractional browser zoom levels, luma.gl's exact device-pixel-content-box sizing diverges from the Math.round(css * dpr) approach used by Mapbox GL, MapLibre, and Google Maps, causing visible drift between the deck.gl overlay canvas and the basemap. Pass pixelSizeSource: 'css-dpr' when creating the canvas context in overlaid (non-interleaved) mode so luma.gl derives pixel sizes using the same rounding as the underlying basemap. Depends on visgl/luma.gl#2588 (pixelSizeSource prop, merged to master, pending release). Closes #10173 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…release The pixelSizeSource prop is available in luma.gl >9.3.3 (visgl/luma.gl#2588) but not yet in the currently pinned @luma.gl/core@9.3.3 types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
luma.gl 9.3.4 ships the pixelSizeSource prop (visgl/luma.gl#2588), so the ts-expect-error suppression is no longer needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update yarn.lock to pull in @luma.gl/core 9.3.5 which includes the css-dpr observer box fix (visgl/luma.gl#2676) - Add test/apps/fractional-zoom-alignment for manual verification of issue #10173 (basemap misalignment at fractional browser zoom) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…uation Resolved conflicts: took @loaders.gl ^4.4.3 (from master) and @luma.gl ^9.3.4 (from this branch). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mode Add unit tests confirming that MapboxOverlay and GoogleMapsOverlay pass pixelSizeSource: 'css-dpr' through deviceProps.createCanvasContext when creating their own Deck instance, ensuring the luma.gl canvas context uses content-box sizing to stay aligned with the basemap. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pixelSizeSource: 'css-dpr'to the luma.gl canvas context in overlaid (non-interleaved) mode for bothMapboxOverlayandGoogleMapsOverlaydevicePixelContentBoxSize, matching how Mapbox GL, MapLibre, and Google Maps compute their canvas drawing buffer dimensions@luma.gl/*to 9.3.4 which ships thepixelSizeSourceprop (visgl/luma.gl#2588)Remaining luma.gl fix needed
visgl/luma.gl#2675: The
css-dprmode in luma.gl 9.3.4 has two bugs:ResizeObserverstill watchesdevice-pixel-content-boxeven incss-dprmode — this causes major canvas misalignment during real browser zoom (Cmd+/-) due to race conditions in the observer callbackMath.roundinstead ofMath.floor— causes 1px mismatch at certain DPR values since Mapbox truncates via implicitcanvas.widthassignmentBoth issues are confirmed fixed by patching luma.gl locally. Once luma.gl ships the fix, this PR will fully resolve #10173.
Impact by environment
pixelSizeSourceremains'exact'width: null, height: null, map owns canvasglprop present,devicePropsnot injectedRoot cause
At fractional browser zoom,
window.devicePixelRatiobecomes non-integer. Mapbox/MapLibre compute canvas pixel size asMath.floor(cssWidth * dpr)(via implicit truncation), while luma.gl'sResizeObserverwithdevice-pixel-content-boxreports the true physical pixel count. These can differ significantly, causing the two canvases to have different drawing buffer dimensions and visible misalignment.The larger issue is that
device-pixel-content-boxobservation fires during DPR changes with potentially stale/racey values, causing the deck.gl canvas to resize out of sync with Mapbox's canvas.Test plan
Math.floormatches Mapbox)Closes #10173 (pending luma.gl#2675)
🤖 Generated with Claude Code
Note
Medium Risk
Changes how overlay canvases compute drawing-buffer size for Mapbox/Google Maps integrations; behavior is scoped to non-shared-GL paths but can affect alignment and rendering at non-100% zoom until the paired luma.gl fixes land.
Overview
Aligns deck.gl overlay canvas sizing with Mapbox/MapLibre and Google Maps at fractional browser zoom by opting into luma.gl’s
pixelSizeSource: 'css-dpr'when Deck owns its own WebGL canvas.MapboxOverlayalways mergesdeviceProps.createCanvasContext.pixelSizeSource: 'css-dpr'into theDeckit creates in overlaid mode, preserving any existingdeviceProps/createCanvasContextfields.GoogleMapsOverlayapplies the same merge only when no externalglis passed (non-interleaved / separate overlay canvas); interleaved shared-context paths are unchanged.Monorepo
@luma.gl/*dependencies and peers are bumped from 9.3.3 to 9.3.4 (lockfile resolves 9.3.5). Unit tests assert thecss-dprwiring for Mapbox overlaid mode and Google Maps without externalgl, and afractional-zoom-alignmentVite test app was added to manually verify Mapbox overlay vs basemap dimensions at browser zoom.Reviewed by Cursor Bugbot for commit c983cfd. Bugbot is set up for automated code reviews on this repo. Configure here.