Skip to content

Return helpful error when WebGPU is disabled#9319

Open
emilk wants to merge 3 commits intogfx-rs:trunkfrom
rerun-io:emilk/improve-webgpu-error-msg
Open

Return helpful error when WebGPU is disabled#9319
emilk wants to merge 3 commits intogfx-rs:trunkfrom
rerun-io:emilk/improve-webgpu-error-msg

Conversation

@emilk
Copy link
Copy Markdown
Contributor

@emilk emilk commented Mar 27, 2026

Previously, if WebGPU was disabled in the browser, wgpu would crash with a very unhelpful error message:

panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wgpu-29.0.1/src/backend/webgpu.rs:1126:14:
canvas context is not a GPUCanvasContext: Object { obj: JsValue(GPUCanvasContext), generics: PhantomData<wasm_bindgen::JsValue> }

Tested in Firefox

Copy link
Copy Markdown
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

Curious that we get an non-null object back that simply isn't a GpuCanvasContext and not an error either. Nasty. But I believe it. Curious what that object is for you, would be nice if you could provide that information, but lgtm either way - can't be defensive enough I figure 🤷

@Wumpf Wumpf enabled auto-merge (squash) March 27, 2026 10:07
emilk added a commit to emilk/egui that referenced this pull request Mar 27, 2026
* Fix for emilk/eframe_template#223
* Related: gfx-rs/wgpu#9319

By default, we would only turn on the WebGPU backend on web, which means
browsers without WebGPU support would just crash.

You can still opt-out of all the default `wgpu` features by enabling
`eframe/wgpu_no_default_features` instead of `eframe/wgpu`
auto-merge was automatically disabled March 27, 2026 10:17

Head branch was pushed to by a user without write access

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.

2 participants