genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
502 stars 86 forks source link

Mutex not released with run_in_background #289

Closed blaine141 closed 2 years ago

blaine141 commented 2 years ago

Describe the Bug Mutex is not nicely released when getting a buffer from the background thread and there is not one queued. This is expressed as a random pause in the camera stream followed by a large number of frames coming through at once. The specific line of issue is this one. It blocks while trying to grab a buffer from the queue, but since it is holding the mutex, the queue can never be filled. The loop also never yields control to the background thread which is what causes the long pause.

To Reproduce Steps to reproduce the behavior:

  1. Make some tool to display frames from the camera and enable run_in_background
  2. Force it to grab a frame when there is not one available. Can be done by grabbing faster than frame rate.
  3. Observe the large pause as the thread cannot gain possession of the mutex to add to the buffer queue.

Expected Behavior No pause, the mutex is released back to the background thread and it provides the next buffer.

Configuration

Actions You Have Taken

Additional context In my application, I have to always have the background thread on

kazunarikudo commented 2 years ago

@blaine141 Hi, please feel free to close this ticket if you can confirm the issue has been fixed. Regards, Kazunari.