Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web: reimplement adapter|device_features #3428

Merged
merged 3 commits into from
Feb 9, 2023
Merged

Conversation

jinleili
Copy link
Contributor

@jinleili jinleili commented Jan 27, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
#3413

Description
This PR can fix the following panic issue:

•panicked at 'adapter.features () is not setlike: GuSupportedFeatures { obj: Object { obj: JsValue(GPUSupportedFeatures) } }', wgpu\src\backend\web.rs:935:14

Testing
Tested locally on Chrome Canary

@cwfitzgerald
Copy link
Member

I don't get why this would fail though

@jinleili
Copy link
Contributor Author

In web_sys,the GpuSupportedFeatures interface has not been marked as setlike:

 InterfaceMember::Setlike(_) => {
        log::warn!("Unsupported WebIDL Setlike interface member: {:?}", self);
        Ok(())
}

@gents83
Copy link
Contributor

gents83 commented Jan 29, 2023

Referring to: rustwasm/wasm-bindgen#3060
and
trying to fix it directly in wasm-bindgen with: rustwasm/wasm-bindgen#3268

@gents83
Copy link
Contributor

gents83 commented Jan 30, 2023

Referring to: rustwasm/wasm-bindgen#3060 and trying to fix it directly in wasm-bindgen with: rustwasm/wasm-bindgen#3268

Now it's integrated 👍

@gents83
Copy link
Contributor

gents83 commented Jan 30, 2023

@jinleili now that the setlike implementation has been integrated, may you double check if you get everything fine, please?

@jinleili
Copy link
Contributor Author

截屏2023-01-31 10 31 02

After patch web-sys, failed the same as before:

GpuSupportedFeatures { obj: Object { obj: JsValue(GPUSupportedFeatures) } }
imports.wbg.__wbg_error_ef9a0be47931175f | @ | cube.js:1367
-- | -- | --
  | $web_sys::features::gen_console::console::error_1::hab41c13b9e1ff93e | @ | cube_bg.wasm:0x12fe7f
  | $console_log::log::h813da3990aa4db8f | @ | cube_bg.wasm:0x7bfc6
  | $<console_log::WebConsoleLogger as log::Log>::log::h0258a3e12b38c489 | @ | cube_bg.wasm:0x10fcfd
  | $log::__private_api_log::hcee8c7881ef32096 | @ | cube_bg.wasm:0x6b0f0
  | $wgpu::backend::web::map_wgt_features::hdf4b99f933da17de | @ | cube_bg.wasm:0x4d35d
  | $<wgpu::backend::web::Context as wgpu::context::Context>::adapter_features::haf63d35a69cbe10f | @ | cube_bg.wasm:0x12590d
  | $<T as wgpu::context::DynContext>::adapter_features::h9b724d1ffd586611 | @ | cube_bg.wasm:0xf8d87
  | $wgpu::Adapter::features::h56ee026819aead12 | @ | cube_bg.wasm:0xf56af
  | $cube::framework::setup::{{closure}}::h86351027c529d8bd | @ | cube_bg.wasm:0x10563
  | $cube::framework::run::{{closure}}::hff184e9f0a9cc93a | @ | cube_bg.wasm:0x42a72
  | $wasm_bindgen_futures::task::singlethread::Task::run::h67f7f7c615bd3e34 | @ | cube_bg.wasm:0x72beb
  | $wasm_bindgen_futures::queue::QueueState::run_all::hb7d7ba3f311aadc4 | @ | cube_bg.wasm:0x64727
  | $wasm_bindgen_futures::queue::Queue::new::{{closure}}::h8a811b8c11c4a4cb | @ | cube_bg.wasm:0x106689
  | $<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::ha7acd9ebcdb7d741 | @ | cube_bg.wasm:0xe4259
  | __wbg_adapter_58 | @ | cube.js:256
  | real | @ | cube.js:201
  | Promise.then(异步) |   |  
  | imports.wbg.__wbg_then_11f7a54d67b4bfad | @ | cube.js:1645
  | $js_sys::Promise::then::h8072c51ae61f1405 | @ | cube_bg.wasm:0x1129c2
  | $wasm_bindgen_futures::queue::Queue::schedule_task::h265dd9bfd3d7e9d5 | @ | cube_bg.wasm:0x93d4c
  | $wasm_bindgen_futures::queue::Queue::push_task::h9b6c094b23d395c8 | @ | cube_bg.wasm:0x133b70
  | $wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::had8597d9acae93e0 | @ | cube_bg.wasm:0x1233c4
  | $std::thread::local::LocalKey<T>::try_with::he68d5139378c0c4f | @ | cube_bg.wasm:0x9b06f
  | $std::thread::local::LocalKey<T>::with::h6aa486951526bde6 | @ | cube_bg.wasm:0xed7b5
  | $wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::h5d646545d018e11d | @ | cube_bg.wasm:0xe5852
  | $wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::hfc75faf0cfc34382 | @ | cube_bg.wasm:0x111200
  | $core::task::wake::Waker::wake::h6172330a56c30e15 | @ | cube_bg.wasm:0x118ebe
  | $<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::hf60ebd054d90c901 | @ | cube_bg.wasm:0x5d66e
  | $<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::{{closure}}::h63963364b9753aa2 | @ | cube_bg.wasm:0x1016ee
  | $core::ops::function::FnOnce::call_once::h49d81799ab1ebd6c | @ | cube_bg.wasm:0x110177
  | $<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::hdcd28358bd91292a | @ | cube_bg.wasm:0x110269
  | $<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::ha7acd9ebcdb7d741 | @ | cube_bg.wasm:0xe4259
  | __wbg_adapter_58 | @ | cube.js:256
  | real | @ | cube.js:201
  | Promise.then(异步) |   |  
  | imports.wbg.__wbg_then_cedad20fbbd9418a | @ | cube.js:1649
  | $js_sys::Promise::then2::h88410f9ff93d3a87 | @ | cube_bg.wasm:0x106ab5
  | $<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::hb0baba003c9d4750 | @ | cube_bg.wasm:0x42f9c
  | $<wgpu::backend::web::Context as wgpu::context::Context>::instance_request_adapter::h0c118be3e1e784a1 | @ | cube_bg.wasm:0xd8b08
  | $<T as wgpu::context::DynContext>::instance_request_adapter::h0c413a53d343a419 | @ | cube_bg.wasm:0xaefe2
  | $wgpu::Instance::request_adapter::h2513afd43cfdbd2c | @ | cube_bg.wasm:0xd0bab
  | $wgpu::util::init::initialize_adapter_from_env_or_default::{{closure}}::ha3712bf4fbe04465 | @ | cube_bg.wasm:0x32a79
  | $cube::framework::setup::{{closure}}::h86351027c529d8bd | @ | cube_bg.wasm:0x10338
  | $cube::framework::run::{{closure}}::hff184e9f0a9cc93a | @ | cube_bg.wasm:0x42a72
  | $wasm_bindgen_futures::task::singlethread::Task::run::h67f7f7c615bd3e34 | @ | cube_bg.wasm:0x72beb
  | $wasm_bindgen_futures::queue::QueueState::run_all::hb7d7ba3f311aadc4 | @ | cube_bg.wasm:0x64727
  | $wasm_bindgen_futures::queue::Queue::new::{{closure}}::h8a811b8c11c4a4cb | @ | cube_bg.wasm:0x106689
  | $<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::ha7acd9ebcdb7d741 | @ | cube_bg.wasm:0xe4259
  | __wbg_adapter_58 | @ | cube.js:256
  | real | @ | cube.js:201
  | Promise.then(异步) |   |  
  | imports.wbg.__wbg_then_11f7a54d67b4bfad | @ | cube.js:1645
  | $js_sys::Promise::then::h8072c51ae61f1405 | @ | cube_bg.wasm:0x1129c2
  | $wasm_bindgen_futures::queue::Queue::schedule_task::h265dd9bfd3d7e9d5 | @ | cube_bg.wasm:0x93d4c
  | $wasm_bindgen_futures::task::singlethread::Task::spawn::{{closure}}::ha7b3f5003bcb3abf | @ | cube_bg.wasm:0x133beb
  | $std::thread::local::LocalKey<T>::try_with::he2acd96831b2966e | @ | cube_bg.wasm:0x950f2
  | $std::thread::local::LocalKey<T>::with::h481dad628be7a204 | @ | cube_bg.wasm:0xed6f9
  | $wasm_bindgen_futures::task::singlethread::Task::spawn::h7ec4fae297291184 | @ | cube_bg.wasm:0x62d43
  | $wasm_bindgen_futures::spawn_local::hac5adba45aa9d424 | @ | cube_bg.wasm:0x10fbc7
  | $cube::framework::run::h7c97ab6ce7553d3e | @ | cube_bg.wasm:0xcb371
  | $cube::main::h00b22ea9e098d8b6 | @ | cube_bg.wasm:0x1449bc
  | $core::ops::function::FnOnce::call_once::h25079f9570bc0eda | @ | cube_bg.wasm:0x13a514
  | $std::sys_common::backtrace::__rust_begin_short_backtrace::h6b8e80d8bfddd9f9 | @ | cube_bg.wasm:0x13a30c
  | $std::rt::lang_start::{{closure}}::h6cfb091a489116e3 | @ | cube_bg.wasm:0x10e182
  | $std::rt::lang_start_internal::hbecc6ff7763fb2f1 | @ | cube_bg.wasm:0x95422
  | $std::rt::lang_start::hb546b3a46ccb74c9 | @ | cube_bg.wasm:0x1038d0
  | $main | @ | cube_bg.wasm:0x143f10
  | $__wbindgen_start | @ | cube_bg.wasm:0x144db7
  | finalizeInit | @ | cube.js:1773
  | init | @ | cube.js:1805
  | await in init(异步) |   |  
  | (匿名) | @ | (索引):17
  | load(异步) |   |  
  | (匿名)


@jinleili
Copy link
Contributor Author

@gents83 I don't think there is a problem with your setlike fix, we can rewrite the relevant code in wgpu as soon as wasm-bindgen releases a new version.

@gents83
Copy link
Contributor

gents83 commented Feb 1, 2023

Version bumped today 👍
rustwasm/wasm-bindgen#3274

@cwfitzgerald
Copy link
Member

Best course of action would be adopting the new wasm-bindgen version, but I think the issue here is that our check (as written here) will never pass. GpuSupportedFeatures is not a Set, it just smells like one. So this case we should unchecked blast it to Set, as the typing here doesn't matter, we're just determining which functions to call.

@jinleili jinleili changed the title web: don't panic when calling GpuSupportedFeatures::dyn_into() web: reimplementation adapter|device_features Feb 2, 2023
@jinleili jinleili changed the title web: reimplementation adapter|device_features web: reimplement adapter|device_features Feb 2, 2023
@jinleili
Copy link
Contributor Author

jinleili commented Feb 2, 2023

Already adapted to new wasm-bindgen version

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cwfitzgerald cwfitzgerald merged commit 0d5b484 into gfx-rs:master Feb 9, 2023
@cwfitzgerald cwfitzgerald added the PR: needs back-porting PR with a fix that needs to land on crates label Feb 9, 2023
cwfitzgerald pushed a commit to cwfitzgerald/wgpu that referenced this pull request Feb 9, 2023
@jinleili jinleili deleted the web branch February 10, 2023 02:48
@cwfitzgerald cwfitzgerald removed the PR: needs back-porting PR with a fix that needs to land on crates label Feb 22, 2023
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.

3 participants