Skip to content

[Bug] MapboxOverlay creates its Deck canvas at the browser default size (300×150), causing an oversized/blurry render flash on load #10599

Description

@kahole

Description

When @deck.gl/mapbox's MapboxOverlay is added to a mapbox-gl map (non-interleaved mode), MapboxOverlay._onAddOverlaid() constructs the Deck instance before the control's own wrapper container has been given a real CSS size (_updateContainerSize() runs after new Deck(...)). The container also isn't attached to the document yet at that point (mapbox only inserts the control's returned element after onAdd() returns), so any size read via getBoundingClientRect() at that time is zero anyway.

Deck's _createCanvas() only sets canvas.width/canvas.height when props.width/props.height are typeof === 'number'. In this flow they're the default CSS string "100%", so that check never applies and the canvas keeps the browser's default drawing-buffer size (300×150). That buffer gets stretched via CSS to fill the real container size until luma.gl's internal ResizeObserver (its start is deferred until WebGL device initialization finishes) fires and corrects canvas.width/canvas.height — one or more frames later.

Net effect: everything rendered by deck.gl (points, icons, any pixel- or meter-sized layer) appears oversized and blurry for the first frame(s), then snaps to the correct size.

Flavors

No response

Expected Behavior

The canvas should be created at the correct drawing-buffer resolution (matching its real container size × devicePixelRatio) from the first rendered frame, with no visible size flash.

Steps to Reproduce

  1. Add a MapboxOverlay (default, non-interleaved) to a mapbox-gl map via map.addControl(overlay), with at least one layer using pixel- or meter-based sizing (e.g. ScatterplotLayer).
  2. Load/reload the page.
  3. Log canvas.width/canvas.height on each animation frame right after mount.
  4. Observe the first 1-2 frames report 300x150 (or whatever the browser's canvas default is) while displayed at full container size, before jumping to the correct value.

Environment

  • @deck.gl/core: 9.3.9
  • @deck.gl/mapbox: 9.3.9
  • @deck.gl/react: 9.3.9
  • mapbox-gl: 3.28.1
  • @vis.gl/react-mapbox: 8.1.2
  • Rendering mode: MapboxOverlay, non-interleaved
  • Browser: Chrome (desktop), macOS

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions