fix(mapbox,google-maps): use css-dpr pixel sizing in overlaid mode to prevent basemap misalignment#10370
Open
chrisgervang wants to merge 6 commits into
Open
fix(mapbox,google-maps): use css-dpr pixel sizing in overlaid mode to prevent basemap misalignment#10370chrisgervang wants to merge 6 commits into
chrisgervang wants to merge 6 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>
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
Touches canvas sizing for all overlaid Mapbox and non-interleaved Google Maps integrations; standalone deck and interleaved modes are scoped out but wrong DPR behavior would show as misalignment or blur.
Overview
Fixes deck.gl overlay drift vs Mapbox/MapLibre/Google Maps basemaps at fractional browser zoom by sizing the deck canvas like the basemap (CSS × DPR) instead of luma’s default exact
device-pixel-content-boxsizing.MapboxOverlay(overlaid mode) andGoogleMapsOverlay(when no sharedgl/ non-interleaved) now passdeviceProps.createCanvasContext.pixelSizeSource: 'css-dpr', merging with any existingdeviceProps. Interleaved / external-GL paths are unchanged.Monorepo
@luma.gl/*dependencies are bumped 9.3.3 → 9.3.4 (lockfile resolves to 9.3.5). A manualtest/apps/fractional-zoom-alignmentMapbox +ScatterplotLayerapp compares map vs deck canvas dimensions for #10173.Reviewed by Cursor Bugbot for commit 0f2789a. Bugbot is set up for automated code reviews on this repo. Configure here.