I spent a day trying to break vgpu

The renderer held up. The quickstart, the error codes and the mock adapter didn't, and most of the fixes are small.

The test shader, running live

Starting WebGPU…

t = 0.00 s
waitingMean green at t = 0 must be above 10 out of 255, so the frame isn't black.
waitingMore than 5% of pixels must change by over 8 levels between t = 0 and t = 8, so the animation moves.

My Node run on an M4 got 50.4 and 51.0%. The check renders 480×270 frames offscreen in your browser, copies them to the CPU, and computes the same two numbers. Chromium on the same Mac returned exactly 50.4 and 51.0%.

vgpu is Vercel Labs' WebGPU library. You write WGSL, vgpu reflects the bindings out of it, and the same shader runs in the browser, headless in Node on Dawn, or against a mock adapter in tests. The pitch is that you (or a coding agent) can render something, read the pixels back, and check the result without ever opening a browser.

I spent a day with 0.6.0 on my M4. I copied the quickstarts exactly as written, made the mistakes everyone makes on day one, and kept notes on where I got stuck. All the output below is real.

The short version is that the renderer is great and getting to it is rough.

What held up

The shader above is the one from my pixel test. It renders headless in Node, reads back, and asserts that the frame isn't black and that it actually animates. The button runs the same check in your browser, and Chromium on my Mac lands on the same numbers Node did, 50.4 and 51.0%.

Speed was never the problem. Here's a draw plus a full readback to the CPU at four sizes, as the median of ten runs. The range is the best and worst of three separate processes.

Draw plus full readback

Median of ten runs at each size, worst of three separate processes. Hover a bar for the best process.

Show the data
SizeRead backBest process (ms)Worst process (ms)
256²0.3 MB0.530.99
1024²4.2 MB2.383.92
2048²16.8 MB7.4511.12
4096²67.1 MB30.132.58
A 4096² frame is 67 MB of RGBA and comes back in about 30 ms.

Every size gave one SHA-256 across 33 renders in three processes, so the output is deterministic. The first cold draw took 123 ms and later processes took about 5 ms, because Dawn's pipeline cache survives between runs. vgpu doctor came back healthy in 0.36 s after a real render and readback. vgpu check caught a type error at line 1, column 52 in about 0.2 s. The errors from set() are honestly some of the best I've seen in a graphics library:

VGPUError: Invalid WGSL value at '$.scale': expected f32, received string.
  code=VGPU-SET-VALUE-INVALID
  detail={"reason":"type","path":"$.scale","expected":"f32","actual":"string"}

That error has a path, the expected type, the actual value, and a stable code. That's the bar. Most of what follows is places where the rest of the library doesn't meet it yet.

Where it broke

1. The Node quickstart on the website crashes, then crashes again

The "Save a PNG" block on vgpu.sh's Node page is the first thing most people will copy. Run as written on 0.6.0, it fails on the shader:

The Save a PNG example, copied as is
VGPUError: The renderer requires a prepared ShaderSource v2, but received raw WGSL or a v1 artifact.
  code: 'VGPU-SHADER-SOURCE-UNPREPARED',
  fix: 'Use a compatible @vgpu/wgsl loader, rebuild shader assets, or call prepareShader() from @vgpu/wgsl/prepare.'

That one is a good error. It says what's wrong and how to fix it. So I wrapped the shader in prepareShader, ran it again, and got a plain JavaScript crash with no code and no hint:

TypeError: colorTarget.read is not a function

Target.read was removed in 0.5.0, and the migration guide says so. The page's own prose still says target.read() resolves to the bytes, the "Write a test" block on the same page has both bugs, and llms-full.txt, the copy meant for AI tools, has the same broken code. The getting-started doc that ships inside the npm package is correct and works the first time, so this one is easy. The website is just older than the package.

Today

vgpu.sh
effect(gpu, gradientSource).draw(colorTarget);
const pixels = await colorTarget.read();

What actually runs

what 0.6.0 accepts
effect(gpu, prepareShader(gradientSource)).draw(colorTarget);
const pixels = await colorTarget.color.read({ mipLevel: 0, region: "all" });

If I were on the team, I'd build the site's snippets from the docs in the package and run them in CI on every release. I'd also leave a stub read() on Target for a release or two that throws a VGPU- code pointing at color.read(). A removed method is exactly where people need a hint.

2. A shader type error renders a black frame and exits 0

This is the one that bothered me most. I took the getting-started loop (render, read back, check) and made the most common WGSL mistake I know, returning a float where a vec4f goes. prepareShader accepted it, draw() returned, settled() resolved, and read() handed back zeros. My check printed all zero: true and the process exited with code 0.

The error did go to stderr through the default console.error, but it says nothing about where the mistake is:

stderr
VGPUError: WebGPU pipeline compilation failed.
  cause: GPUValidationError {},
  code: 'VGPU-COMPILE-FAILED',
  fix: 'Check WGSL, pipeline bindings, device limits, and render target/vertex layouts when applicable.'

The annoying part is that the real diagnostic is right there. Node's inspector prints GPUValidationError {} because the message isn't an own property, but if you read e.cause.message yourself you get the whole thing:

e.cause.message = "Error while parsing WGSL: :1:52 error: cannot convert value of type 'abstract-float' to type 'vec4<f32>'"

You can try the same thing below. It's plain WebGPU in your browser with the same fullscreen triangle vgpu uses. Pick the broken shader, or break the working one yourself. The left box is what vgpu printed for me. The right box is what the GPU stack actually reported, with a line and column.

What vgpu 0.6.0 told me, in Node

…

What WebGPU knew, live in your browser

Starting WebGPU…

vgpu does have the right tools for this. await fx.compile(target) rejects properly, and gpu.onError sees the failure. The getting-started snippet just doesn't use either, so the path everyone copies is the one that fails silently. Three small changes on vgpu's side would fix it. Copy cause.message into the VGPUError message or detail. Put await fx.compile(target) in the quickstart. And have effect() reject a shader with no @fragment entry up front, the way compute() already does for @compute. Right now that case also ends as the same generic compile failure.

3. A typo in a binding name reports the same code as “no WebGPU”

I misspelled params as parms in set(). The message on the left is fine, but look at the code.

Today

Binding 'parms' does not exist in 'effect'.
  code=VGPU-RING1-UNSUPPORTED
  fix=undefined

What I'd want (my mockup, not real output)

Binding 'parms' does not exist in 'effect'.
  code=VGPU-BINDING-UNKNOWN
  fix=Did you mean 'params'? Reflected
      bindings: params, tex, samp

The init docs define VGPU-RING1-UNSUPPORTED as "WebGPU isn't available", and the shipping-to-production guide says to show a static poster when you see it. If you follow that guide, a typo in a uniform name shows your users the "your browser can't do WebGPU" fallback. I grepped dist/ and found about 25 places that throw this code, and most of them have no fix. Binding a Float32Array to a storage array gets the same code, with no mention of storage(gpu, bytes).

vgpu already reflects every binding name, so a did-you-mean list costs almost nothing. The set() value errors near the top show the team already knows how to write these.

4. The mock adapter isn't really the same code

The README says vgpu/mock "swaps in a deterministic software adapter for the same code, so tests never need a GPU," and it says that right under a pixel-readback example. So I ran the same three shaders against both:

Same shaders, real adapter vs. mock
vgpu/node: solid px0=[64,128,191,255]  uv px(3,3)=[223,223,0,255]  bad-shader compile(): rejected VGPU-COMPILE-FAILED
vgpu/mock: solid px0=[0,0,0,0]  uv px(3,3)=[0,0,0,0]  bad-shader compile(): resolved

The mock reads back zeros for everything, and a shader that doesn't compile compiles fine. To be fair, the @vgpu/adapter-mock README is accurate. It says to use vgpu/node for real rendering and readback. But the line people actually read is on the front page, and a pixel test written against the mock either always passes or always fails, depending on what it asserts. Either way, it isn't testing anything.

I'd reword the README to say the mock is for API wiring, not output. Better still, have read() on a mock target throw a VGPU-MOCK-NO-PIXELS error instead of returning zeros that look like a real black frame.

5. Getting a .wgsl file into plain Node takes three packages and a docs page

The README's Node quick start does import triangleShader from "./triangle.wgsl". In plain Node that's ERR_UNKNOWN_FILE_EXTENSION. @vgpu/wgsl ships loaders for webpack, Vite and Turbopack, but there's no Node register hook. What works is the no-bundler page's recipe:

quickstart.mjs
import { resolveShader } from "@vgpu/wgsl/runtime";
import { prepareShader } from "@vgpu/wgsl/prepare";

const resolved = await resolveShader({ entry: fileURLToPath(new URL("./triangle.wgsl", import.meta.url)) });
const triangleShader = prepareShader(resolved.wgsl);

That imports from @vgpu/wgsl, which the README never asks you to install. Its install line is pnpm add vgpu. With npm it works anyway because of hoisting. With pnpm, the getting-started example fails with ERR_MODULE_NOT_FOUND: Cannot find package '@vgpu/wgsl'. Only the 0.6.0 migration notes mention installing it directly.

What I'd want is one function. loadShader(path) from vgpu/node would resolve the imports, prepare the result, and need no second package. Headless Node is the main thing vgpu is selling, so it should be the shortest path, not the longest.

Smaller things

  • Typed WGSL imports aren't typed. The README calls them typed, and TypeScript does catch API-shape mistakes like colorTarget.read(). But set() takes Record<string, unknown> and every .wgsl import is the same plain ShaderSource, so set({ parms: … }) and scale: "2" compile cleanly and only fail at runtime. The loader already knows the bindings, so it could emit ShaderSource<{ params: … }>.
  • doctor and init() disagree about my GPU. doctor reports the M4's adapter type as "unknown", and init() on the same machine reports "gpu". They read it from different code paths.
  • A size of [8.5, 8] throws VGPU-TARGET-SIZE-REQUIRED: Target size required. It was given a size, just not an integer one.
  • The fix lives in two places. Some errors put it in .fix and others write "Fix: …" into the message and leave .fix undefined. Anything that reads errors in code has to check both.
  • NaN is accepted for an f32 uniform without a word.

What I'd change if I worked on vgpu

I'd fix issue 2, then issue 1. The black frame breaks the whole render-and-check idea, because a check that can't tell "the shader is wrong" from "the shader draws black" isn't much of a check. The quickstart is the one that costs every new user ten minutes. Both are small: one is a field copy plus two lines in a doc, the other is a CI job that runs the website's snippets.

The rest is cleaning up error codes. That sounds boring, but vgpu is built to be driven by code, including coding agents, and code can't squint at a stack trace. It branches on code and does whatever fix says, so those two fields need to be right.