Camera stopped streaming when app window lose focus
-
Hi,
I'm using Qt 6.3.1 on Windows and Linux. This problem only happens on Windows. I'm usingQVideoSink
and itsvideoFrameChanged
signal to stream camera data. I just found out that two things happen when the app window just lose focus (when I click on other app)- Memory consumption of the app goes up quickly
- The app does not show new camera frames. It seems like the
videoFrameChanged
signal is not there.
After a while, the app resumes streaming. Then if I click on the app again to focus on it, the app freezes for about a second, then resumes streaming.
Why switching focus on and off causes the app to freeze? Is this a Windows problem? I'm using company laptop with quite a bit of security software installed, can it be an issue?
Thank you!
-
Looks like it is related to having too many
QLabel
s showing too manyQPixmap
s. I simplified my app to keep just a dozen or soQPixmap
s, and the problem was gone. -
I despise work-arounds but maybe consider adding an event trap to suspend the program when it loses focus and resync when it regains focus?
-
I despise work-arounds but maybe consider adding an event trap to suspend the program when it loses focus and resync when it regains focus?
@Kent-Dorfman Thank you for your reply!
Unfortunately suspending the program is not an option for my use case.
I think eventually I need to meet the constraint of my OS and my hardware. If my device cannot handle too many
QLabel
s, then maybe it is a sign that the structure of the program is not efficient.In this particular case, it is actually not necessary to have many
QLabel
s. So to reduce its number is the right thing to do, I think.