l1npengtul / nokhwa

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

threaded camera deadlock on stop stream #165

Open bsekura opened 4 months ago

bsekura commented 4 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 4 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.