mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
Return helpful error when WebGPU is disabled (#9319)
This commit is contained in:
1 parent
74827c4181
commit
fe725d6df0
1 file changed
+13
-5
@@ -1120,11 +1120,19 @@ impl ContextWebGpu {
|
||||
}
|
||||
};
|
||||
|
||||
// Not returning this error because it is a type error that shouldn't happen unless
|
||||
// the browser, JS builtin objects, or wasm bindings are misbehaving somehow.
|
||||
let context: webgpu_sys::GpuCanvasContext = context
|
||||
.dyn_into()
|
||||
.expect("canvas context is not a GPUCanvasContext");
|
||||
// An error here indicated that WebGPU is disabled in the browser.
|
||||
let context: webgpu_sys::GpuCanvasContext =
|
||||
context
|
||||
.dyn_into()
|
||||
.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: `{}`",
|
||||
actual.to_string()
|
||||
)),
|
||||
})?;
|
||||
|
||||
Ok(WebSurface {
|
||||
gpu: self.gpu.clone(),
|
||||
|
||||
Reference in new issue
Block a user