
Description
Description
wgpu attempts to execute the createBuffer
method on an undefined
when running in a worker thread on the target wasm32-unknown-unknown
. The instance, adapter, surface, and device were created on the main thread.
Repro steps
A runnable example is here, the source code for which is here; see wasm.rs
and core/src/lib.rs
. More generic instructions are described below.
- Create a new Rust crate targeting
wasm32-unknown-unknown
. - Export a
main
function using#[wasm_bindgen]
. - In
main
, create a wgpu instance, adapter, device, and surface. - Create a new thread (e.g., using
wasm_thread
) in which a vertex buffer is created and initialized with the device returned by wgpu. - Observe the error.
Expected vs observed behavior
I expect the vertex buffer creation to be successful, after which render passes would occur, the command queue would be submitted, and the surface frame would ultimately be presented.
Instead, I observe that attempting to create the vertex buffer from a worker thread crashes the Wasm process.
Extra materials
On Microsoft Edge (Chromium-based), I receive the following error:
On Firefox, I receive the following error:
Platform
Windows 11. wgpu 0.13 (latest minor release). naga 0.9.