[PyQt] Errors while rendering to multiple QGLWidgets in a multi-threaded app
Michael Broxton
broxton at stanford.edu
Sun Nov 6 00:57:04 GMT 2011
Hi again,
I wanted to send another quick request for help in case any PyQt devs or users can help me with the QGLWidget multi-threaded rendering bug I posted about below... I've done a little more testing this week and found that this issue occurs on Linux as well, so the problem does appear to be truly cross-platform (confirmed on Mac/Win/Linux). Once again, I have a C++ implementation of the test program in pure Qt that does not crash when rendering multiple QGLWidgets from multiple threads, so I don't think that my approach is fundamentally flawed. However, the PyQt test program (https://gist.github.com/1318290) does crash shortly after multiple render threads are up and running. Any clues as to why this is happening in PyQt but not pure Qt would be greatly appreciated.
Thanks in advance,
-Michael
On Oct 27, 2011, at 7:04 PM, Michael Broxton wrote:
> Hi there,
>
> I'm attempting to write a PyQt application that renders to different QGLWidgets from different threads (there is one QGLWidget accessed in each thread, and each thread only renders to its one widget -- therefore the opengl contexts should be strictly kept to their separate threads). However my application crashes soon after two or more QGLWidgets are open and rendering. It looks very much like the two threads are rendering into the same OpenGL context, with a typical error message looking like this:
>
> GLError(
> err = 1282,
> description = 'invalid operation',
> baseOperation = glEnd,
> cArguments = ()
> )
>
> as if glEnd() had been called twice in a row in the same context without a glBegin() in between. This shouldn't happen if the threads are rendering into different contexts, though, and I have very carefully checked using Apple's OpenGL Profiling tool and each thread definitely has its own gl context. After a lot of debugging, I'm stumped as to why this is happening! I have created a very simple test program that illustrates the problem here:
>
> https://gist.github.com/1318290
>
> For more background: I'm running OSX 10.7.2 on a macbook pro with Qt version 4.7.4 and PyQt 4.8.6. I have also tested this program on a similarly configured Windows 7 machine, and experienced the same problem.
> My test code is based on this old(ish) article about multi-threaded GL rendering in Qt, available here:
>
> http://doc.qt.nokia.com/qq/qq06-glimpsing.html#writingmultithreadedglapplications
>
> A straight C++ implementation (snagged from the github repo of Anders Wallin) of this method can be downloaded here:
>
> http://graphics.stanford.edu/~broxton/qt_opengl_threads.tgz
>
> My python test harness is essentially identical to this C++ code, but the C++ code compiles and runs fine on my computer without any issue. Everything on the 'net leads me to believe that I'm doing this multi-threaded rendering correctly, so I think that this is a Python/OpenGL or PyQt related issue, and not a Qt issue. Thus, it feels like it is time to escalate the issue and seek out some help!
>
> Any assistance in figuring this out would be greatly appreciated. Thanks!
>
> -Michael
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20111105/8957b964/attachment-0001.html>
More information about the PyQt
mailing list