wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

thread 'main' attempted to acquire a snatch lock recursively

Open hakolao opened this issue 1 year ago • 3 comments

Description Device loss can cause lock contention due to lock guards being in scope while trying to write.

thread 'main' panicked at C:\Users\okko-\Programming\wgpu\wgpu-core\src\resource.rs:740:73:
thread 'main' attempted to acquire a snatch lock recursively.
- Currently trying to acquire a write lock at C:\Users\okko-\Programming\wgpu\wgpu-core\src\resource.rs:740:73
- Previously acquired a read lock at C:\Users\okko-\Programming\wgpu\wgpu-core\src\device\queue.rs:1043:55

Probably since #6229

Repro steps Cause a device is lost error on queue submit.

Device::release_gpu_resources will run into above error when trying to release buffers or others.

Expected vs observed behavior This lock contention should not occur.

Platform Trunk + Windows + RTX3080

noticed during investigations of another issue #6279

hakolao avatar Oct 07 '24 14:10 hakolao

I guess generally device loss is rare, so this maybe isn't that big of a deal...

I need to figure out why I'm getting it in the first place

hakolao avatar Oct 07 '24 14:10 hakolao

I guess generally device loss is rare, so this maybe isn't that big of a deal...

No, wgpu should handle device loss as gracefully as possible. Thanks for filing this!

jimblandy avatar Oct 07 '24 14:10 jimblandy

release_gpu_resources can be removed once we move the registries into the Firefox bindings (https://github.com/gfx-rs/wgpu/issues/5121) since we can instead clear the registry on device loss.

teoxoy avatar Oct 08 '24 11:10 teoxoy

c13fc3d14187bc07dc17d5b9c7f7bc8bb6daf007 resolved this.

teoxoy avatar Apr 22 '25 07:04 teoxoy