Skip to content

fix(ext/webgpu): allow empty writeBuffer data - #37264

Open
caiotheodoro wants to merge 1 commit into
denoland:mainfrom
caiotheodoro:fix/webgpu-writebuffer-empty
Open

caiotheodoro wants to merge 1 commit into
denoland:mainfrom
caiotheodoro:fix/webgpu-writebuffer-empty

Conversation

@caiotheodoro

Copy link
Copy Markdown

Fixes #37182.

GPUQueue.writeBuffer() panicked for empty ArrayBuffers, typed arrays, and views because V8 uses a null data pointer for zero-length backing stores. Deno unwrapped that missing pointer while converting the input to a slice, before wgpu could treat the empty write as a no-op.

This change returns an empty slice when the input byte length is zero. Non-empty inputs use the existing slice construction.

Added a regression test covering:

  • new ArrayBuffer(0)
  • new Uint8Array(0)
  • new DataView(new ArrayBuffer(0))

Validation performed on macOS aarch64:

  • the new test panics on released Deno 2.9.8 at ext/webgpu/queue.rs:160
  • cargo build --bin deno passes
  • the new test passes on the fixed build: 1 passed | 0 failed
  • a manual repro covering all three input forms exits successfully
  • tools/format.js passes
  • tools/lint.js --js passes

AI assistance was used to prepare this patch; the validation results above are from local runs.

GPUQueue.writeBuffer() panicked for empty ArrayBuffers, typed arrays,
and views because V8 uses a null data pointer for zero-length backing
stores. Return an empty slice when the input byte length is zero so
wgpu can treat the write as a no-op.

Fixes denoland#37182

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.

WebGPU: GPUQueue.writeBuffer() with empty data panics (ext/webgpu/queue.rs:153)

1 participant