You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual behavior: When starting Gazebo GUI compiled against Qt 5.15.2 it will complain with:
[GUI] [Err] [Application.cc:885] [QT] ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 0x0x55555622e390. Receiver '' (of type 'gz::gui::MainWindow') was created in thread 0x0x555555a1ebe0", file /mnt/ZLinuxDatos/qt-everywhere-src-5.15.2/qtbase/src/corelib/kernel/qcoreapplication.cpp, line 552
Steps to reproduce
Install Qt 5.15.2
Compile against it, using colcon build --cmake-args -DBUILD_TESTING=OFF -DBUILD_DOCS=OFF -DCMAKE_PREFIX_PATH=/opt/Qt/5.15.2/gcc_64 -DQT_QMAKE_EXECUTABLE=/opt/Qt/5.15.2/gcc_64/bin/qmake --merge-install
Note: I'm running a custom-compiled (Debug version) of Qt 5.15.2; so it's possible additional debug checks are being ran that aren't made in the Release version. UPDATE: Confirmed that this assert only triggers in Debug builds from Qt. Release versions don't exhibit this crash.
It is possible that this bug repros out of the box on Ubuntu 22.04 since it comes with Qt 5.15 by default.
Output
The error happens in GzRenderer::Render:
if (gz::gui::App())
{
gz::gui::App()->sendEvent(
gz::gui::App()->findChild<gz::gui::MainWindow *>(),
newgui::events::PreRender());
}
Qt's intended way would be to call postEvent and wait for the results
However the documentation of PreRender explicitly states: /// It's safe to make rendering calls in this event's callback.
Due to how OpenGL works (context sticks per thread) any rendering call must happen in the rendering thread
Any code (Qt, OS, or Gazebo's) that relies on TLS (Thread Local Storage) could break if they are in the wrong thread
Hence we've run into a contradiction: Qt debug checks want the event to happen in the Main thread; Gazebo wants the event to happen in the rendering thread.
The simplest (and best) solution would be to move the whole rendering to the Main thread, which is something I've been wanting to do since gazebosim/gz-sim#774
From the looks of it, this bug will not be fixable for Garden. The assert itself should be harmless as far as I can see; but if left unfixed it may become a problem in Ubuntu 22.04
Environment
main
Description
Steps to reproduce
colcon build --cmake-args -DBUILD_TESTING=OFF -DBUILD_DOCS=OFF -DCMAKE_PREFIX_PATH=/opt/Qt/5.15.2/gcc_64 -DQT_QMAKE_EXECUTABLE=/opt/Qt/5.15.2/gcc_64/bin/qmake --merge-install
It is possible that this bug repros out of the box on Ubuntu 22.04 since it comes with Qt 5.15 by default.
Output
The error happens in
GzRenderer::Render
:Qt does not like that sendEvent() call.
Full callstack:
I'll keep researching
The text was updated successfully, but these errors were encountered: