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
  • Loading branch information
littledivy committed Jun 13, 2024
1 parent abe9953 commit e4f3ed8
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 e4f3ed8

Please sign in to comment.