Skip to content

wgpu(web): assertion failed: wasm.is_instance_of::<T>() #4108

@petalas

Description

@petalas

Description
Possibly related to #3430?

I'm getting the same assertion failed: wasm.is_instance_of::<T>() error.

Apologies if I am missing something obvious, I am just trying to get the examples to run with no changes.

Repro steps

I've done my best to chain together the steps to reproduce it, you should be able to copy and paste the whole thing.

cargo install -f --version 0.2.87 wasm-bindgen-cli && \
cargo install simple-http-server && \
BRANCH_NAME="trunk" && \
TEST_FOLDER_NAME="wgpu-4108" && \
EXAMPLE="hello-triangle" && \
rm -rf ${TEST_FOLDER_NAME} && \
git clone [email protected]:gfx-rs/wgpu.git --depth 1 --branch ${BRANCH_NAME} ${TEST_FOLDER_NAME} && \
cd ${TEST_FOLDER_NAME} && \
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build --bin ${EXAMPLE} --target wasm32-unknown-unknown && \
wasm-bindgen --out-dir target/generated --web target/wasm32-unknown-unknown/debug/${EXAMPLE}.wasm && \
echo -e '<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<meta charset="UTF-8" />\n\t\t<meta name="viewport" content="width=device-width, initial-scale=1.0" />\n\t</head>\n\t<body>\n\t\t<script type="module">\n\t\t\timport init from "./'$EXAMPLE'.js"; // Change this file to the name of the example you are using\n\t\t\tinit();\n\t\t</script>\n\t</body>\n</html>' >> target/generated/index.html && \
simple-http-server target/generated

Then → http://localhost:8000/index.html

capture.js:278 panicked at 'assertion failed: wasm.is_instance_of::<T>()', wgpu/src/backend/web.rs:53:9

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:8000/capture.js:284:21)
    at console_error_panic_hook::Error::new::h396265745b367172 (http://localhost:8000/capture_bg.wasm:wasm-function[3685]:0x102ca4)
    at console_error_panic_hook::hook_impl::h1f62bddb2913838c (http://localhost:8000/capture_bg.wasm:wasm-function[676]:0x88c3a)
    at console_error_panic_hook::hook::h9a07278a04a6aae8 (http://localhost:8000/capture_bg.wasm:wasm-function[4090]:0x1087a5)
    at core::ops::function::Fn::call::h4f15a388443f4583 (http://localhost:8000/capture_bg.wasm:wasm-function[3403]:0xfe66f)
    at std::panicking::rust_panic_with_hook::h6df5db7ad9f65dc8 (http://localhost:8000/capture_bg.wasm:wasm-function[1564]:0xc9e11)
    at std::panicking::begin_panic_handler::{{closure}}::h0d169fa297411d6d (http://localhost:8000/capture_bg.wasm:wasm-function[1927]:0xda4ed)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h7fe51fb4d3ba6060 (http://localhost:8000/capture_bg.wasm:wasm-function[4870]:0x10ffb2)
    at rust_begin_unwind (http://localhost:8000/capture_bg.wasm:wasm-function[2902]:0xf529e)
    at core::panicking::panic_fmt::h2d3c5586175098d9 (http://localhost:8000/capture_bg.wasm:wasm-function[4060]:0x108180)

Platform
wgpu trunk (332cd03 at the time of writing this)
Ubuntu 22.04.3 LTS (WSL2) - host is Windows 11 Pro 22H2 (22621.2215)
rustc 1.65.0
wasm-bindgen 0.2.87
Chrome: Version 116.0.5845.141 (Official Build) (64-bit)
GeForce RTX 4090, driver version 537.13

Update

I was able to also reproduce it on the host (Windows) machine but NOT on my MacBook Pro (M1 Max)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend: webgpuIssues with direct interface with WebGPUtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions