-
Notifications
You must be signed in to change notification settings - Fork 920
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
Properly handle the case where Navigator.gpu is undefined and WebGPU is the only compiled backend #6197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch! Not convinced of the Option
wrapper on gpu, but looking good otherwise.
Unfortunate that this needs the OptionFuture
wrapper, but don't see a better solution either
…U is the only compiled backend. Previously, `Instance::request_adapter` would invoke a wasm binding with an undefined arg0, thus crashing the program. Now it will cleanly return `None` instead. Fixes gfx-rs#6196.
e4001a5
to
3ab65b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Connections
Fixes #6196.
Description
This PR fixes a bug where
wgpu
would "crash" in the browser (JavaScriptTypeError
exception) when compiled withoutwebgl
support and the browser doesn't support WebGPU.Implementation
This PR changes
ContextWebGPU
to avoid callingwgpu_sys
with anundefined
Gpu
object. InContextWebGpu::request_adapter
, this involves immediately returningNone
ifself.gpu
is undefined in the browser.Testing
Please advise. I have no idea how to write an automated regression test for this kind of change. I could not find any
CONTRIBUTING.md
or likewise providing any guidelines.Additionally, I have not yet manually tested that this works. I will work on that.
EDIT: Okay I applied the patch to
wgpu
0.20.1 locally and patchedeframe
to use it, and it does successfully get past the problem.Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.--target wasm32-unknown-unknown
as well ??CHANGELOG.md
. See simple instructions inside file.