gfx-rs/wgpu-rs

Trouble running wasm version of examples/hello-triangle

bes opened this issue · 5 comments

bes commented

I am having trouble running the examples/hello-triangle sample using the instructions at:

I have tried running under Firefox & Safari for webgpu. I have tried running under Chrome & Firefox for webgl.

WebGPU errors

In Firefox 85.0.2 I get:

panicked at 'Failed to find an appropriate adapter', examples/hello-triangle/main.rs:19:10
panicked at 'Failed to find an appropriate adapter', examples/hello-triangle/main.rs:19:10

Stack:

init/imports.wbg.__wbg_new_59cb74e423758ede@http://localhost:8000/hello-triangle.js:328:19
console_error_panic_hook::Error::new::h701f816778cbde16@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6335]:0x1cb39e
console_error_panic_hook::hook_impl::h968bbfa5649201e2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[852]:0x10cf8e
console_error_panic_hook::hook::h3505a89344ad6000@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7088]:0x1d5a98
core::ops::function::Fn::call::h43e482af6b7e72bf@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5862]:0x1c3e44
std::panicking::rust_panic_with_hook::h123718ba3bf480af@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1685]:0x14c21b
std::panicking::begin_panic_handler::{{closure}}::hf393a82e58397bd2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2742]:0x17b06a
std::sys_common::backtrace::__rust_end_short_backtrace::h2ff2cfc953878925@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7585]:0x1dbeb0
rust_begin_unwind@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6850]:0x1d28bb
core::panicking::panic_fmt::h285dc015a87be5a4@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7587]:0x1dbf14
core::option::expect_failed::hb64df147f43458bd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4469]:0x1a9e04
core::option::Option<T>::expect::h284e6b3aac34525a@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2691]:0x179357
hello_triangle::run::{{closure}}::haeeff40a886b810f@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[163]:0x7cd3f
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9ce74b4e96678e40@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2119]:0x161e45
wasm_bindgen_futures::task::singlethread::Task::run::he04978d9c8df62fd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[545]:0xe91e2
wasm_bindgen_futures::queue::QueueState::run_all::ha21102f27cadc4c0@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[782]:0x1060e9
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h52992c67fc2efdc2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3877]:0x19c10e
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hec483c5849c35283@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1782]:0x1515a9
__wbg_adapter_49@http://localhost:8000/hello-triangle.js:250:10
real@http://localhost:8000/hello-triangle.js:199:20
promise callback*init/imports.wbg.__wbg_then_dd3785597974798a@http://localhost:8000/hello-triangle.js:725:35
js_sys::Promise::then::h14860cee1803c036@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3784]:0x199c07
wasm_bindgen_futures::queue::Queue::push_task::hb4f03822e5c9c982@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1087]:0x122a47
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h34396df0d36604f3@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5287]:0x1b9f4b
std::thread::local::LocalKey<T>::try_with::h0c4e9795ef3cb3b7@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1790]:0x151c2f
std::thread::local::LocalKey<T>::with::h27cc13b30d142573@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3643]:0x196125
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::h70324a6b213208ef@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1956]:0x15a48c
wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::hbb35faffd008867d@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3733]:0x19870d
core::task::wake::Waker::wake::h5ef9dcc5051e6749@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4503]:0x1aa975
<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::h31ac3ecc9f166ae2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[320]:0xc1c33
<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::{{closure}}::hda59ce31fa6bffd3@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3091]:0x18676d
core::ops::function::FnOnce::call_once::h7e32eb05cc8a4b7b@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3692]:0x1975ff
<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::ha9caaaefba16d188@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3551]:0x193977
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hec483c5849c35283@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1782]:0x1515a9
__wbg_adapter_49@http://localhost:8000/hello-triangle.js:250:10
real@http://localhost:8000/hello-triangle.js:199:20
promise callback*init/imports.wbg.__wbg_then_0f957e0f4c3e537a@http://localhost:8000/hello-triangle.js:729:35
js_sys::Promise::then2::h3d51551e33640a24@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3114]:0x187293
<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::hbd378b542760c7a0@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[270]:0xb4b3a
<wgpu::backend::web::Context as wgpu::Context>::instance_request_adapter::h10bfdf6210cb9b24@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1608]:0x147b8e
wgpu::Instance::request_adapter::h7922468c557b5723@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2229]:0x166d6c
hello_triangle::run::{{closure}}::haeeff40a886b810f@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[163]:0x7cbbe
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9ce74b4e96678e40@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2119]:0x161e45
wasm_bindgen_futures::task::singlethread::Task::run::he04978d9c8df62fd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[545]:0xe91e2
wasm_bindgen_futures::queue::QueueState::run_all::ha21102f27cadc4c0@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[782]:0x1060e9
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h52992c67fc2efdc2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3877]:0x19c10e
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hec483c5849c35283@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1782]:0x1515a9
__wbg_adapter_49@http://localhost:8000/hello-triangle.js:250:10
real@http://localhost:8000/hello-triangle.js:199:20
promise callback*init/imports.wbg.__wbg_then_dd3785597974798a@http://localhost:8000/hello-triangle.js:725:35
js_sys::Promise::then::h14860cee1803c036@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3784]:0x199c07
wasm_bindgen_futures::queue::Queue::push_task::hb4f03822e5c9c982@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1087]:0x122a47
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h34396df0d36604f3@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5287]:0x1b9f4b
std::thread::local::LocalKey<T>::try_with::h0c4e9795ef3cb3b7@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1790]:0x151bd2
std::thread::local::LocalKey<T>::with::h27cc13b30d142573@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3643]:0x196125
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::h70324a6b213208ef@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1956]:0x15a48c
wasm_bindgen_futures::task::singlethread::Task::spawn::h72084486f59176ae@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[398]:0xd227a
wasm_bindgen_futures::spawn_local::h869c1c3fadfe7980@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3347]:0x18de8f
hello_triangle::main::hce9f8cda87517ea5@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[404]:0xd316b
core::ops::function::FnOnce::call_once::h9e99301fd53a7fa8@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6962]:0x1d4100
std::sys_common::backtrace::__rust_begin_short_backtrace::h09d2d935680f95cd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6852]:0x1d2924
std::rt::lang_start::{{closure}}::h3ff753582f7c0e2b@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5906]:0x1c493d
std::rt::lang_start_internal::h1ad6338b95de9507@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1567]:0x14542e
std::rt::lang_start::h4abee94ee085336f@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4046]:0x1a045e
main@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[8472]:0x1e38c0
@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[8539]:0x1e3d9e
init@http://localhost:8000/hello-triangle.js:841:10
async*@http://localhost:8000/:9:7

Uncaught (in promise) RuntimeError: unreachable executed
    __wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
    real http://localhost:8000/hello-triangle.js:199
    promise callback*init/imports.wbg.__wbg_then_dd3785597974798a http://localhost:8000/hello-triangle.js:725
    __wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
    real http://localhost:8000/hello-triangle.js:199
    promise callback*init/imports.wbg.__wbg_then_0f957e0f4c3e537a http://localhost:8000/hello-triangle.js:729
    __wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
    real http://localhost:8000/hello-triangle.js:199
    promise callback*init/imports.wbg.__wbg_then_dd3785597974798a http://localhost:8000/hello-triangle.js:725
    init http://localhost:8000/hello-triangle.js:841
    async* http://localhost:8000/:9

In Safari 14.0.3 I get:

panicked at 'expected to get context from canvas', /Users/bes/repos/github/wgpu-rs/src/backend/web.rs:921:18

Stack:

http://localhost:8000/hello-triangle.js:328:28
wasm-stub@[wasm code]
<?>.wasm-function[console_error_panic_hook::Error::new::h701f816778cbde16]@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook_impl::h968bbfa5649201e2]@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook::h3505a89344ad6000]@[wasm code]
<?>.wasm-function[core::ops::function::Fn::call::h43e482af6b7e72bf]@[wasm code]
<?>.wasm-function[std::panicking::rust_panic_with_hook::h123718ba3bf480af]@[wasm code]
<?>.wasm-function[std::panicking::begin_panic::{{closure}}::h21c362a0abf19a1c]@[wasm code]
<?>.wasm-function[std::sys_common::backtrace::__rust_end_short_backtrace::h007f37ff3327b8c1]@[wasm code]
<?>.wasm-function[std::panicking::begin_panic::h2cc188958d331369]@[wasm code]
<?>.wasm-function[<wgpu::backend::web::Context as wgpu::Context>::instance_create_surface::he0a68e0cfc3f9a3c]@[wasm code]
<?>.wasm-function[wgpu::Instance::create_surface::hdda6ca2fca929085]@[wasm code]
<?>.wasm-function[hello_triangle::run::{{closure}}::haeeff40a886b810f]@[wasm code]
<?>.wasm-function[<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9ce74b4e96678e40]@[wasm code]
<?>.wasm-function[wasm_bindgen_futures::task::singlethread::Task::run::he04978d9c8df62fd]@[wasm code]
<?>.wasm-function[wasm_bindgen_futures::queue::QueueState::run_all::ha21102f27cadc4c0]@[wasm code]
<?>.wasm-function[wasm_bindgen_futures::queue::Queue::new::{{closure}}::h52992c67fc2efdc2]@[wasm code]
<?>.wasm-function[<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hec483c5849c35283]@[wasm code]
wasm-stub@[wasm code]
_dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec483c5849c35283@[native code]
__wbg_adapter_49@http://localhost:8000/hello-triangle.js:250:134
real@http://localhost:8000/hello-triangle.js:199:21
promiseReactionJob@[native code]

WebGL errors

In Chrome 88.0.4324.146 I get:

panicked at 'expected to get context from canvas', /Users/bes/repos/github/wgpu-rs/src/backend/web.rs:921:18
panicked at 'expected to get context from canvas', /Users/bes/repos/github/wgpu-rs/src/backend/web.rs:921:18

Stack:

Error
    at imports.wbg.__wbg_new_59cb74e423758ede (http://localhost:8000/hello-triangle.js:328:19)
    at console_error_panic_hook::Error::new::h701f816778cbde16 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6335]:0x1cb39e)
    at console_error_panic_hook::hook_impl::h968bbfa5649201e2 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[852]:0x10cf8e)
    at console_error_panic_hook::hook::h3505a89344ad6000 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7088]:0x1d5a98)
    at core::ops::function::Fn::call::h43e482af6b7e72bf (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5862]:0x1c3e44)
    at std::panicking::rust_panic_with_hook::h123718ba3bf480af (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1685]:0x14c21b)
    at std::panicking::begin_panic::{{closure}}::h21c362a0abf19a1c (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2703]:0x179a5d)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h007f37ff3327b8c1 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4084]:0x1a12e2)
    at std::panicking::begin_panic::h2cc188958d331369 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5042]:0x1b5707)
    at <wgpu::backend::web::Context as wgpu::Context>::instance_create_surface::he0a68e0cfc3f9a3c (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[448]:0xdaa52)

Uncaught (in promise) RuntimeError: unreachable
    at __rust_start_panic (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[8599]:0x1e3fe3)
    at rust_panic (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7850]:0x1deb69)
    at std::panicking::rust_panic_with_hook::h123718ba3bf480af (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1685]:0x14c242)
    at std::panicking::begin_panic::{{closure}}::h21c362a0abf19a1c (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2703]:0x179a5d)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h007f37ff3327b8c1 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4084]:0x1a12e2)
    at std::panicking::begin_panic::h2cc188958d331369 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5042]:0x1b5707)
    at <wgpu::backend::web::Context as wgpu::Context>::instance_create_surface::he0a68e0cfc3f9a3c (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[448]:0xdaa52)
    at wgpu::Instance::create_surface::hdda6ca2fca929085 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3329]:0x18d62a)
    at hello_triangle::run::{{closure}}::haeeff40a886b810f (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[163]:0x7cb36)
    at <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9ce74b4e96678e40 (http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2119]:0x161e45)

In Firefox I get:

panicked at 'Failed to find an appropriate adapter', examples/hello-triangle/main.rs:19:10 ``` panicked at 'Failed to find an appropriate adapter', examples/hello-triangle/main.rs:19:10

Stack:

init/imports.wbg.__wbg_new_59cb74e423758ede@http://localhost:8000/hello-triangle.js:328:19
console_error_panic_hook::Error:🆕:h701f816778cbde16@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6335]:0x1cb39e
console_error_panic_hook::hook_impl::h968bbfa5649201e2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[852]:0x10cf8e
console_error_panic_hook:🪝:h3505a89344ad6000@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7088]:0x1d5a98
core::ops::function::Fn::call::h43e482af6b7e72bf@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[5862]:0x1c3e44
std::panicking::rust_panic_with_hook::h123718ba3bf480af@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1685]:0x14c21b
std::panicking::begin_panic_handler::{{closure}}::hf393a82e58397bd2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2742]:0x17b06a
std::sys_common::backtrace::__rust_end_short_backtrace::h2ff2cfc953878925@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7585]:0x1dbeb0
rust_begin_unwind@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[6850]:0x1d28bb
core::panicking::panic_fmt::h285dc015a87be5a4@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[7587]:0x1dbf14
core::option::expect_failed::hb64df147f43458bd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[4469]:0x1a9e04
core::option::Option::expect::h284e6b3aac34525a@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2691]:0x179357
hello_triangle::run::{{closure}}::haeeff40a886b810f@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[163]:0x7cd3f
<core::future::from_generator::GenFuture as core::future::future::Future>::poll::h9ce74b4e96678e40@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[2119]:0x161e45
wasm_bindgen_futures::task::singlethread::Task::run::he04978d9c8df62fd@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[545]:0xe91e2
wasm_bindgen_futures::queue::QueueState::run_all::ha21102f27cadc4c0@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[782]:0x1060e9
wasm_bindgen_futures::queue::Queue:🆕:{{closure}}::h52992c67fc2efdc2@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[3877]:0x19c10e
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hec483c5849c35283@http://localhost:8000/hello-triangle_bg.wasm:wasm-function[1782]:0x1515a9
__wbg_adapter_49@http://localhost:8000/hello-triangle.js:250:10
real@http://localhost:8000/hello-triangle.js:199:20

Uncaught (in promise) RuntimeError: unreachable executed
__wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
real http://localhost:8000/hello-triangle.js:199

</details>

In summary, I haven't got the triangles example to run in any web browser.

Any help would be appreciated. Thank you!
kvark commented

You don't get WebGPU in FF stable, it's too early. See https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#firefox for how to get it enabled.

bes commented

Firefox Nightly 87.0a1 (2021-02-11) macOS Big Sur

  • dom.webgpu.enabled = true
  • gfx.webrender.all = true
  • Restart browser
  • WebGPU version of index.html

Result: Completely black canvas + console message:

Uncaught (in promise) Error: Using exceptions for control flow, don't mind me. This isn't actually an error!
    __wbindgen_throw http://localhost:8000/hello-triangle.js:786
    __wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
    real http://localhost:8000/hello-triangle.js:199
    promise callback*init/imports.wbg.__wbg_then_dd3785597974798a http://localhost:8000/hello-triangle.js:725
    __wbg_adapter_49 http://localhost:8000/hello-triangle.js:250
    real http://localhost:8000/hello-triangle.js:199
kvark commented

I can confirm this. Something got broken, will investigate.

bes commented

Thank you! ❤️

kvark commented

@bes I believe this should work now. The issue was in Gecko, unrelated to WebGPU.