Skip to content

fix(core): do not draw before the canvas is sized - #10842

Open
xecanto wants to merge 3 commits into
visgl:masterfrom
xecanto:fix/10599-first-frame-canvas-size
Open

xecanto wants to merge 3 commits into
visgl:masterfrom
xecanto:fix/10599-first-frame-canvas-size

Conversation

@xecanto

@xecanto xecanto commented Oct 10, 2026 •

Copy link
Copy Markdown

Closes #10599

Background

A Deck that creates its own canvas draws its first frames into the default 300x150 drawing buffer, stretched over the real canvas size, until luma reports the size. The issue describes this for MapboxOverlay, but a standalone Deck with a parent does the same. Deck now sizes the canvas when it creates it and skips frames until luma has measured it.

Change List

  • Deck: apply the CSS size when the canvas is created
  • Deck: skip frames until the owned canvas is measured
    • Not applied when width and height are numbers
    • A canvas with no layout size is not drawn until it has one
  • Unit tests
  • Ran vitest --project headless, --project render and yarn lint

Note

Medium Risk
Touches core redraw() and canvas lifecycle in deck.ts, but behavior is gated to auto-created canvases without explicit numeric dimensions; mis-detection could delay or skip an initial draw.

Overview
Fixes first-frame rendering when Deck auto-creates its own canvas (e.g. MapboxOverlay): layers were briefly drawn into the default 300×150 drawing buffer and stretched until luma measured the real size.

Deck now applies CSS width/height as soon as the owned canvas is created, tracks _ownedCanvasNeedsSize when numeric width/height props are not set, and skips redraw() until the canvas has non-zero layout and luma reports a resize (or the context was already initialized on device setup). Redraw flags are preserved so the next resize still paints.

Mapbox overlay tests assert the first completed frame uses the map’s 400×300 drawing buffer, including when the overlay DOM is inserted late.

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

A Deck that creates its own canvas drew its first frames into the
default 300x150 drawing buffer, stretched over the real canvas size,
until luma reported the size. Apply the CSS size when the canvas is
created and skip frames until it has been measured.
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issue remains.

Summary

Deck applies CSS sizing when it creates a canvas and holds redraws until that canvas has a measured layout size.

  • Deck waits for an owned canvas to have a real size before drawing.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Deck creates canvas] --> B[Apply CSS size]
  B --> C{Both size props are numbers?}
  C -->|Yes| F[Allow redraw]
  C -->|No| D[Hold redraws]
  D --> E[Luma initialization or resize]
  E --> G{Canvas has layout size?}
  G -->|No| D
  G -->|Yes| F
Loading

Reviews (3) · Last reviewed commit: "fix(core): keep waiting while the canvas..." · Reviewed by Greptile

Comment thread modules/core/src/lib/deck.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit d14b304. Configure here.

Comment thread modules/core/src/lib/deck.ts Outdated
Comment thread modules/core/src/lib/deck.ts Outdated
Comment thread modules/core/src/lib/deck.ts Outdated
MapboxOverlay redraws from the map render event, which bypassed the
check in the render loop. Move the check to redraw(), and stop waiting
when luma measured the canvas before the resize handler was installed.
luma reports the default canvas size for a canvas that is detached or
hidden. Only stop holding redraws once a size is reported for a canvas
that has a layout, so an overlay inserted late is not drawn at 300x150.

This branch has not been deployed

No deployments
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.

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

1 participant