Avoid a deadlock in Device::lose (#5197)

This commit is contained in:
Nicolas Silva authored and GitHub committed 2024-02-05 10:01:05 -05:00
1 parent 563d9202c3
commit 4da46f35ef
1 file changed
+4 -2
+4 -2
View File
@@ -3362,9 +3362,11 @@ impl<A: HalApi> Device<A> {
// 1) Resolve the GPUDevice device.lost promise.
let mut life_lock = self.lock_life();
let closure = life_lock.device_lost_closure.take();
// It's important to not hold the lock while calling the closure and while calling
// release_gpu_resources which may take the lock again.
drop(life_lock);
if let Some(device_lost_closure) = closure {
// It's important to not hold the lock while calling the closure.
drop(life_lock);
device_lost_closure.call(DeviceLostReason::Unknown, message.to_string());
}