Skip to content

fix(mapbox): ignore useDevicePixels in interleaved mode - #10510

Merged
chrisgervang merged 4 commits into
masterfrom
chrisgervang/basemap-browser-use-device-pixels-v1
Jul 31, 2026
Merged

chrisgervang merged 4 commits into
masterfrom
chrisgervang/basemap-browser-use-device-pixels-v1

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #10509

Change List

  • Drop useDevicePixels in interleaved mode instead of forwarding it to Deck. The base map owns the WebGL context and the canvas drawing buffer size, so the prop has never had any effect there. The reason is recorded in a code comment rather than a runtime warning, to avoid bundling a string for a development-only case.
  • Fix filterProps reading interleaved off the incoming props (defaulting to false) instead of this._interleaved. Since setProps receives partial props, setProps({useDevicePixels}) on an interleaved overlay was forwarding the value.
  • Document useDevicePixels as ignored in interleaved mode in the MapboxOverlay API reference, pointing to MapLibre's pixelRatio map option (Mapbox GL JS has no equivalent).
  • Add a test covering the constructor path, the setProps path, and that overlaid mode still passes the prop through.

Not a breaking change: useDevicePixels had no effect in interleaved mode in any tested version (9.1, 9.2, 9.3), so nothing that worked before stops working.


Note

Low Risk
Localized prop filtering and documentation for MapboxOverlay; no auth, security, or broad rendering pipeline changes beyond avoiding a mistaken useDevicePixels forward in interleaved mode.

Overview
MapboxOverlay now strips useDevicePixels when interleaved: true, because the basemap owns the WebGL context and canvas buffer size. filterProps uses this._interleaved instead of the incoming interleaved prop (which defaulted to false), so setProps({ useDevicePixels }) no longer incorrectly forwards that value in interleaved mode. Overlaid mode still passes useDevicePixels through to Deck.

The MapboxOverlay API docs document that useDevicePixels is ignored in interleaved mode and point users to MapLibre’s pixelRatio map option (no Mapbox GL JS equivalent). Tests cover constructor and setProps behavior for interleaved vs overlaid.

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

@chrisgervang chrisgervang added this to the v9.4 milestone Jul 29, 2026
@coveralls

coveralls commented Jul 29, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.127% (+0.01%) from 83.117% — chrisgervang/basemap-browser-use-device-pixels-v1 into master

Comment thread modules/mapbox/src/mapbox-overlay.ts Outdated
if (this._interleaved) {
if (useDevicePixels !== undefined && useDevicePixels !== true) {
log.warn(
'useDevicePixels has no effect in interleaved mode. The basemap controls the drawing buffer resolution. Use MapLibre pixelRatio option instead.'

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.

While warnings are nice, this is a big string to bundle for every app for what is likely to be a rare case that would only hit during development.

Options:

  • shorter string.
  • assert(), then add the explanation in a comment here so that stopping in the debugger gives the developer the reason. That is what is usually done in luma/deck.

@chrisgervang chrisgervang Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Moved the explanation into a code comment, so nothing extra gets bundled.

chrisgervang and others added 2 commits July 30, 2026 17:23
Replace the runtime warning with a code comment to avoid bundling an
error string for a development-only case.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@chrisgervang chrisgervang changed the title fix(mapbox): warn when useDevicePixels is set in interleaved mode fix(mapbox): ignore useDevicePixels in interleaved mode Jul 31, 2026
@chrisgervang
chrisgervang merged commit 0ee8cd4 into master Jul 31, 2026
6 checks passed
@chrisgervang
chrisgervang deleted the chrisgervang/basemap-browser-use-device-pixels-v1 branch July 31, 2026 01:17
Pessimistress pushed a commit that referenced this pull request Aug 7, 2026
* fix(mapbox): warn when useDevicePixels is set in interleaved mode

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(mapbox): suppress unused variable lint warning

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(mapbox): silently drop useDevicePixels in interleaved mode

Replace the runtime warning with a code comment to avoid bundling an
error string for a development-only case.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
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.

useDevicePixels is silently ignored in interleaved MapboxOverlay mode

3 participants