PDA

View Full Version : Application freezes after sleep or being blocked by an anti-virus



pixaeiro
27th April 2015, 14:36
Hello,

I am developing an image editor with Qt, and I have noticed that sometimes the application freezes after the Windows 7 wakes up from Sleep model, or after it is blocked by an antivirus.

Unfortunately it doesn't block immediately, and I haven't been able to reproduce this issue in my development desktop. Also, I am not 100% sure this is the case... this is just my hunch based on the reports I got.

Does anybody has any tips about what should I investigate?

Besides the most common user interface widgets, I am using QThread for constant image update.

Thank you!

d_stranz
27th April 2015, 18:53
I am using QThread for constant image update.

Then I would strongly suspect that you have a race / deadlock condition in your threading. Why do you need threading in the first place?

pixaeiro
29th April 2015, 15:23
Thanks d_stranz,

Yes, a race condition is my first suspect too...

The software is a non-destructive image editor that is powered by a node graph engine. When the user edits a node in the user interface, in the background the engine starts evaluating the new image. For example, if there is a blur node, and the user drags the slider, the ui sends events to the engine with different blur values (1.0, 2.0, 7.0, 12.0, 8.0)... As these events arrive, the engine requests the working thread to stop the current task and start a new one... And the application is responsive the whole time.

I have extensively tested the software for hours with no issues... but I have seen it blocking after a sleep, or after an antivirus blocks it.

Does anybody know how an antivirus stops an application from running? I'd like to reproduce this issue.. I know that as soon as I can reproduce it in debug mode, catching and killing the bug is fast.

Thanks for your help!

wysota
29th April 2015, 15:31
I don't think what you do requires a constant thread execution. I would suggest eliminating the thread to see if the problem persists.The application shouldn't care about anti-virus or sleep mode, the system should stop and restart it in a transparent way.

pixaeiro
29th April 2015, 19:00
Hello wysota,

It is extremely important that the image operations are exectued in a thread different to the UI thread. For example, when moving a slider, the operation has to be always smooth! Most of the time the worker thread is in an idle state, and I wake it up with a signal when the user changes an attribute in an image operator in the UI. The thread updates the nodes in the graph with the new images, and sends a signal to the UI thread informing that the node graph is up to date. For this I use QThread, and signals and slots.

What other Qt classes would you suggest me to investigate for executing the image operations in a worker thread?

Thank you!

d_stranz
29th April 2015, 19:26
Your use of threads for this purpose seems reasonable, if your goal is to keep the UI as responsive as possible.

Back to the possible race condition: are you using locks, semaphores, mutexes, or some other blocking mechanism to control shared access to your data structure?

Where does the freeze occur? In the GUI or in the processing thread? (That is, can you do things on the GUI side, but no image updates occur as a result?)

pixaeiro
29th April 2015, 19:45
Yes, I use a locking system and semaphores to protect data that can be used by multiple threads.

Unfortunately I have never been able to reproduce this bug in my PC... but I have seen it in other PCs. When the application freezes, everything is unresponsive, and the windows title change to + (Not Responding) or something like that.

I found this a few minutes ago to pause a windows program using the Resource Monitor. I'll give it a try tom
http://superuser.com/questions/493896/is-there-a-program-that-can-pause-another-program
I'll give it a try tomorrow!

Thanks!

d_stranz
29th April 2015, 22:19
Well, that may or may not trigger the problem. I have no idea if sleep mode on Windows uses this. I would be very, very surprised if an anti-virus program could arbitrarily suspend a running process if the process was behaving and minding its own business.