1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix(ext/webgpu): fix surface creation panic when adapter not initialized (#24201)

Fixes https://github.com/denoland/deno/issues/23433
This commit is contained in:
Divy Srivastava 2024-06-13 19:04:32 +05:30 committed by Bartek Iwańczuk
parent 4525facb02
commit 6f2ad6e1e2
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

View file

@ -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