[webgpu] fix device loss callback to be immediately drop (#7992)

This commit is contained in:
Lucas Abel
2025-07-23 17:32:38 +02:00
committed by GitHub
parent f8756a6e1b
commit ffd59691e0

View File

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