From c13fc3d14187bc07dc17d5b9c7f7bc8bb6daf007 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 2 Apr 2025 15:35:36 +0200 Subject: [PATCH] don't call `release_gpu_resources` when losing the device This removes the possibility of deadlocks happening since `release_gpu_resources` tries to lock resources (trackers, snatchable_lock, pending_writes, life_tracker) while they might be already locked; `handle_hal_error` is called in lots of places. Removing the call only delays destruction since `release_gpu_resources` is still called in `maintain`. --- wgpu-core/src/device/resource.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 4f3c5ab797..75deda2d9b 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -3916,12 +3916,9 @@ impl Device { // since that will prevent any new work from being added to the queues. // Future calls to poll_devices will continue to check the work queues // until they are cleared, and then drop the device. - - // Eagerly release GPU resources. - self.release_gpu_resources(); } - pub(crate) fn release_gpu_resources(&self) { + fn release_gpu_resources(&self) { // This is called when the device is lost, which makes every associated // resource invalid and unusable. This is an opportunity to release all of // the underlying gpu resources, even though the objects remain visible to