App hangs in QPixmap::fromImage
-
Is your QImage good? Does saving the QImage to a file work? What is the QImage::Format of the image?
-
It works most of the time and hangs randomly. It can take somewhere between a few seconds and a 1-2 hours to hang. Images are fetched from camera at around 60fps and each frame should be the same size. I suspect data gets corrupted somewhere but I was expecting a crash instead of an app freeze. It's a bit strange that it always hang at the same point.
-
Again: it hangs on a mutex lock - nothing to do with the data. Take a look if this mutex is locked in another thread...
-
@Christian-Ehrlicher the mutex is owned by Qt code inside
QPixmap::fromImage
I don't use this function from other threads so I don't see what I did that caused it to stay locked. -
@mpouchol said in App hangs in QPixmap::fromImage:
I don't use this function from other threads so I don't see what I did that caused it to stay locked.
I'm giving up... looks like it's too hard to look into the other threads while it is hanging to see if another thread is also using this mutex. So try to figure it out by your own.
-
@Christian-Ehrlicher said in App hangs in QPixmap::fromImage:
I'm giving up... looks like it's too hard to look into the other threads
I did that and that's not the case. Thanks for your help anyway.
-
Ok, taking a deeper look into convert_generic() the qimage is converted with more than one thread. One of these subthreads hangs maybe due to a broken QImage. Look into your other threads to see which one is somewhere hanging inside convertSegment()
-
I also had a look at the code inside
convert_generic()
. When the main thread is frozen I don't see other threads hanging inconvertSegment
which make me think that maybe one of the convertSegment threads has died silently and is not releasing the semaphore inconvert_generic
because I don't see visual studio raising exceptions in other threads. -
If you compile Qt by your own build a big try/catch block around convert_segment and simply catch all exceptions to see if there is one.
You can also create a helper thread which writes out the current qimage after a certain period of time when it was not canceled in between so you can inspect the qimage. -
Ah, see https://bugreports.qt.io/browse/QTBUG-90629 and https://bugreports.qt.io/browse/QTBUG-92188 even I don't see how this should affect windows.
-
@Christian-Ehrlicher said in App hangs in QPixmap::fromImage:
Indeed when looking at the stack trace it looks very similar to my case, almost the same function calls except for the low level semaphore things on linux.
I think I may have to rebuild Qt and try your suggestion to wrap convert_segment around a try/catch block to have more detail.
-
@mpouchol
I updated my (working) software from 5.12.11 to 5.15.8 and have exactly the same problem, now the QPixmap::fromImage hangs. I did not debugged into qt but its defenitely in main thread and its my only and first call of it. It happens every time in my case, the image is a Format_Grayscale8 toois there a solution for it?
-
it really seems to have something to do with Format_Grayscale8, Format_RGB888 and QImage::Format_Mono works...