Return helpful error when WebGPU is disabled#9319
Return helpful error when WebGPU is disabled#9319emilk wants to merge 4 commits intogfx-rs:trunkfrom
Conversation
Wumpf
left a comment
There was a problem hiding this comment.
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 🤷
* 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`
Head branch was pushed to by a user without write access
* 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`
| .map_err(|actual| crate::CreateSurfaceError { | ||
| inner: crate::CreateSurfaceErrorKind::Web( | ||
| format!( | ||
| "canvas.getContext() returned a value that did not coerce to GPUCanvasContext. This is likely because WebGPU is disabled in this browser. Expected: GPUCanvasContext, Actual: {}", |
There was a problem hiding this comment.
style: Let's put code-like things in backticks. Not all wgpu code perfectly does this yet, but we're trying to meet the standard the rest of the Rust ecosystem sets for this.
I'm less certain if it makes sense for the to_string call; I think it's the Web platform's toString, but I'm not positive. So, I'll leave off the comparison printing, but suspect it would also be helpful there.
/me gets off his backtick soap box
| "canvas.getContext() returned a value that did not coerce to GPUCanvasContext. This is likely because WebGPU is disabled in this browser. Expected: GPUCanvasContext, Actual: {}", | |
| "`canvas.getContext()` returned a value that did not coerce to `GPUCanvasContext`. This is likely because WebGPU is disabled in this browser. Expected: GPUCanvasContext, Actual: {}", |
style: Let's break up this string with concat!(…), so we don't hamstring rustfmt. Case in point: rustfmt would have indented the multiple lines of arguments here, but it didn't because of this.
|
Ahhh, but I can't push anything, because org-based forks don't allow maintainer edits. 🤔 Well, here: you can apply the fixups I suggested and applied at cf44334 with |
wgpubackend: Enable WebGL fallback emilk/egui#8038Previously, if WebGPU was disabled in the browser,
wgpuwould crash with a very unhelpful error message:Tested in Firefox