-
Notifications
You must be signed in to change notification settings - Fork 186
Panic when no adapters are available #117
Comments
Actually, the unwrap lies in rust code here: It would be a good idea to call |
In general we should avoid skipping the C API for functional changes like this, since we also want to allow other languages using the C API to fail gracefully too.
We can't return We haven't implemented full WebGPU error handling yet, so for now the C API could use the special Line 1358 in cbdd74f
|
Duplicate of gfx-rs/wgpu#368 |
375: Use callback for `request_adapter` r=kvark a=grovesNL For now this is mostly a signature change which allows us to start using a callback for `request_adapter`. Once we have an event loop, the callback could be scheduled to make this asynchronous. At that point the examples and server would have to be updated, because they currently rely on the callback running immediately (inline). The reason for this change is that `request_adapter` is supposed to return a `Promise` in JS, so we can represent it with callbacks at the C API, and `Future` in Rust (though we'll probably keep using callbacks initially). I also changed `request_adapter` to provide an adapter with `AdapterId::ERROR` when no adapters are available, so we can add basic error handling to wgpu-rs (gfx-rs/wgpu-rs#117). Co-authored-by: Joshua Groves <josh@joshgroves.com>
Similar to #105
Originally reported in parasyte/pixels#36
We try to catch any errors from
wgpu::Adapter::request
to provide a "helpful" error message, but our error handler never gets called: https://github.com/parasyte/pixels/blob/98983d201db0639f51c264ade5cf876f8df65d1e/src/lib.rs#L412-L413The backtrace points to the panic occurring here in
wgpu-native
: https://github.com/gfx-rs/wgpu/blob/951641dcc50b355eda894c9a5cd6da057d48765b/wgpu-native/src/instance.rs#L473-L475The
wgpu::Adapter::request
method itself is suspicious. The docs claim it returnsNone
when an adapter cannot be found, but it is clearly hardcoded to returnSome<T>
:wgpu-rs/src/lib.rs
Lines 538 to 547 in cbdd74f
Given these two issues, we're unable to capture the error (transform the
None
intoResult<_, E>
) because this method never returnsNone
. I would work on this, but unfortunately I don't know the best way to approach theextern "C"
interface. Should it just returnOption<AdapterId>
?The text was updated successfully, but these errors were encountered: