l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
531 stars 137 forks source link

threaded camera deadlock on stop stream #165

Open bsekura opened 8 months ago

bsekura commented 8 months ago

Threaded camera CameraCallback creates a loop camera_frame_thread_loop that continuously acquires the lock. When stop_stream is called, it tries to lock the camera first, but it never succeeds. As a result, one cannot stop the threaded camera - it continues on indefinitely.

bsekura commented 8 months ago

This is happening on Windows using media foundation backend. frame internally calls source reader ReadSample, which is a blocking call. So this results in this thread being blocked on ReadSample for most of its time, practically holding the lock all the time.

l1npengtul commented 1 month ago

Ill change the MSMF backend to use the callback reader in 0.11