Skip to content

Commit ffd5969

Browse files
authored
[webgpu] fix device loss callback to be immediately drop (#7992)
1 parent f8756a6 commit ffd5969

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

wgpu/src/backend/webgpu.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,9 @@ impl dispatch::DeviceInterface for WebDevice {
23912391
);
23922392
});
23932393
let _ = self.inner.lost().then(&closure);
2394+
// Release memory management of this closure from Rust to the JS GC.
2395+
// TODO: This will leak if weak references is not supported.
2396+
closure.forget();
23942397
}
23952398

23962399
fn on_uncaptured_error(&self, handler: Box<dyn crate::UncapturedErrorHandler>) {
@@ -2400,7 +2403,8 @@ impl dispatch::DeviceInterface for WebDevice {
24002403
}) as Box<dyn FnMut(_)>);
24012404
self.inner
24022405
.set_onuncapturederror(Some(f.as_ref().unchecked_ref()));
2403-
// TODO: This will leak the memory associated with the error handler by default.
2406+
// Release memory management of this closure from Rust to the JS GC.
2407+
// TODO: This will leak if weak references is not supported.
24042408
f.forget();
24052409
}
24062410

0 commit comments

Comments
 (0)