Skip to content

Commit

Permalink
fix(ext/webgpu): fix surface creation panic when adapter not initiali…
Browse files Browse the repository at this point in the history
…zed (#24201)

Fixes #23433
  • Loading branch information
littledivy authored and bartlomieju committed Jun 18, 2024
1 parent 4525fac commit 6f2ad6e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/webgpu/byow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub fn op_webgpu_surface_create(
p1: *const c_void,
p2: *const c_void,
) -> Result<ResourceId, AnyError> {
let instance = state.borrow::<super::Instance>();
let instance = state.try_borrow::<super::Instance>().ok_or_else(|| {
type_error("Cannot create surface outside of WebGPU context. Did you forget to call `navigator.gpu.requestAdapter()`?")
})?;
// Security note:
//
// The `p1` and `p2` parameters are pointers to platform-specific window
Expand Down

0 comments on commit 6f2ad6e

Please sign in to comment.