I have been developing with Qt for some time now on my project, and we are starting to move to a more thread-oriented design. Upon moving some GL rendering widgets to other threads I have discovered some very weird behavior. It appears that if a GL Widget begins updating from another thread (boost thread or QThread) before a widget that accepts user input (such as a QTextEdit) grabs focus, I get XCB crashes that look like:
[xcb] Too much data requested from _XRead
[xcb] This is most likely caused by a broken X extension library
[xcb] Aborting, sorry about that.
hypnotizer: ../../src/xcb_io.c:735: _XRead: Assertion ‘!xcb_xlib_too_much_data_requested’ failed.
To test this out, I actually can make a simple modification to the GLHypnotizer demo to reproduce the crash. That demo can be found here: http://qt-project.org/doc/qt-4.8/demos-glhypnotizer.html [qt-project.org]
If I add the line ‘mdiArea.addSubWindow(new QTextEdit(this));’ at around line 313 (before the call to newThread()), then when the demo starts there will be a QTextEdit and a GL Hypnotizer Widget. If I then click on the QTextEdit to grab focus I will get the above crash every time.
Can anyone reproduce the error on there Linux install using the above instructions? Has anyone encountered these types of issues on Linux using Qt and threading before?
Note: I am using Ubuntu 12 and this crash happens in VirtualBox and non VirtualBox Ubuntu installations
OpenGL, Qt rendering and multithreading don't mix well. In particular a OpenGL context can be active in only one thread at a time. Now if the context is shared among multiple widgets (note that this different from sharing objects between contexts, I'm talking about a single context that's used for multiple windows/widgets which is legitimate) and those widgets render from different threads you're going to get into a lot of issues.
Usually the best course of action when it comes to OpenGL and multithreading is, not doing it. Use multiple threads, yes, but use them for everything that's not related to OpenGL or any kind of graphics output. Keep all graphics operations to a single thread to avoid major issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With