gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.32k stars 904 forks source link

thread 'main' attempted to acquire a snatch lock recursively #6378

Open hakolao opened 6 hours ago

hakolao commented 6 hours ago

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 commented 6 hours ago

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

jimblandy commented 5 hours ago

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!