1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -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 GitHub
parent abe9953829
commit e4f3ed82ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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