Skip to content

fix: a view with no size draws nothing and logs nothing - #22

Merged
KaNaDaAT merged 1 commit into
mainfrom
skip-zero-size-frames
Nov 5, 2026
Merged

KaNaDaAT merged 1 commit into
mainfrom
skip-zero-size-frames

Conversation

@KaNaDaAT

@KaNaDaAT KaNaDaAT commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Symptom. A 0x0 view logs WebGPU validation errors in Chrome on every frame. The Vega editor starts on an empty spec, which compiles to a 0x0 scene, so anyone who picks WebGPU there sees them: "The texture size ... is empty", "Could not create a swapchain texture of size 0", then the invalid "MSAA Color Texture", texture view, render pass and command buffer on Queue.Submit. The canvas renderer draws nothing there and logs nothing.

Cause. The renderer ran a full frame whatever the canvas size. Every target a frame draws into is the size of the canvas (MSAA, offscreen, swapchain, mask and blend targets), and a texture cannot be empty. Configuring the context on a 0x0 canvas fails the same check, so it is not only the frame's textures.

Fix. _frame ends straight away when the canvas width or height is 0, before the device is made or the context is configured: no textures, no encoding, no submit. It goes through _finishFrame, so the render lock is released and a queued render still runs. A pending captureFrame() resolves with the empty frame instead of timing out. Drawing resumes once the view has a size again.

Test. test/render/zerosize.spec.ts takes canvas and webgpu through the same steps: 0x0, 200x100, back to 0x0, then 0x0 onto the canvas (offscreen: false, the editor's path) with two renders back to back. It checks the frame size at each step, that the 200x100 frame is filled, and that neither renderer logs anything. Every device is wrapped before the page loads, so uncaptured GPU errors from the very first frame are reported too. A pixel comparison cannot hold this case, since both renders are empty and the suite's ink floor rejects a blank case, so it is a spec of its own rather than a corpus entry. It fails before the fix with all three of the editor's messages.

npm run typecheck, npm run lint and npm run build pass. npm test: 257 passed, 9 skipped, 1 failed. The failure is the path-commands fixture at 72.0 on the worst-block measure against 70, which reads the same 72.0 on unchanged main with the local Chrome this machine runs the suite in, so it is not from this change.

A 0x0 view, which the vega editor's empty spec gives, still ran a whole
frame. The context was configured and the MSAA, offscreen and swapchain
textures were made at 0x0, and Chrome logged each failed texture and the
invalid pass and submit after it, every frame. Canvas draws nothing there
and logs nothing.

- a frame on a canvas with no area ends before the device is made
- a capture waiting on it resolves with the empty frame
- zerosize.spec.ts takes canvas and webgpu from 0x0 to 200x100 and back,
  offscreen and onto the canvas, and holds both to no console output
@KaNaDaAT
KaNaDaAT merged commit 984b4f5 into main Nov 5, 2026
4 checks passed
@KaNaDaAT
KaNaDaAT deleted the skip-zero-size-frames branch November 5, 2026 21:23

This branch was previously deployed

1 inactive deployment
github-pages — 984b4f5f Deployed Nov 5, 2026 by KaNaDaAT via Deploy #5
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.

1 participant