Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vizkit3DWidget tries to swapBuffers on non-exposed windows, resulting in message on stderr #48

Open
pierrewillenbrockdfki opened this issue Jun 4, 2020 · 3 comments

Comments

@pierrewillenbrockdfki
Copy link
Contributor

This happens when running rock-display_bin, using my qt5 branches. Vizkit3DWidget is only changed in minor ways, so the underlying problem imo also exists using qt4.

rock-display does not show() the Vizkit3DWidget by default, but Vizkit3DWidget still does setup its _timer to start calling osgviz::update(), which goes on to osgviz::WindowManager::frame() and then to osgViewer::CompositeViewer::frame(), and finally calling QOpenGLContext::swapBuffers().

Vizkit3DWidget uses an osgviz::Window that extends osgViewer::CompositeViewer with additional data and functionality. The osgviz::Window is created in a way that automatically registers it with the osgviz::WindowManager and cannot be unregistered and registered again without changing its state.

The actual message is

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

Backtrace from osgviz::WindowManager::frame()

#0  osgviz::WindowManager::frame() (this=0x555555c116d0) at rock/gui/osgviz/src/windows/WindowManager.cpp:68
#1  0x00007ffff55a631e in osgviz::OsgViz::update() (this=0x555555c11640) at rock/gui/osgviz/src/OsgViz.cpp:92
#2  0x00007ffff7067eac in void doActivate<false>(QObject*, int, void**) () at /usr/lib64/libQt5Core.so.5
#3  0x00007ffff706b52a in QTimer::timeout(QTimer::QPrivateSignal) () at /usr/lib64/libQt5Core.so.5
#4  0x00007ffff70605a5 in QObject::event(QEvent*) () at /usr/lib64/libQt5Core.so.5
#5  0x00007ffff62f1c9f in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#6  0x00007ffff62fad90 in QApplication::notify(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#7  0x00007ffff70351ee in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib64/libQt5Core.so.5
#8  0x00007ffff7088598 in QTimerInfoList::activateTimers() () at /usr/lib64/libQt5Core.so.5
#9  0x00007ffff7088e5c in idleTimerSourceDispatch(_GSource*, int (*)(void*), void*) () at /usr/lib64/libQt5Core.so.5
#10 0x00007ffff0527e4b in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0
#11 0x00007ffff05280f8 in g_main_context_iterate.constprop () at /usr/lib64/libglib-2.0.so.0
#12 0x00007ffff05281af in g_main_context_iteration () at /usr/lib64/libglib-2.0.so.0
#13 0x00007ffff70892a0 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib64/libQt5Core.so.5
#14 0x00007ffff703409b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib64/libQt5Core.so.5
#15 0x00007ffff703be42 in QCoreApplication::exec() () at /usr/lib64/libQt5Core.so.5
#16 0x000055555555ac64 in main(int, char**) (argc=<optimized out>, argv=0x7fffffffb268) at rock/gui/rock-display/src/Main.cpp:54

A simple solution would be to check for isVisible() before the call to osgviz::update(), but that only works for applications that have no other calls to osgviz::update() and a single Vizkit3DWidget(or all Vizkit3DWidget being shown/hidden at the same time). A more involved solution could stop using osgviz::Window and osgviz::WindowManager and include the necessary bits directly(with -20+23 lines changes; i can try to rebase that patch off of my qt5 work on request).

@planthaber
Copy link
Member

That would be nice, i already tried to check isVisible(), but it seems like the main window is unable to complete show(), when frame() is not called (the Graphicscontext coming from QT)

@pierrewillenbrockdfki
Copy link
Contributor Author

Find the two changes here: https://github.com/pierrewillenbrockdfki/gui-vizkit3d/tree/fix-calling-frame-on-hidden-window

(That was a lot easier than expected, but not even compile tested, lacking qt4)

@planthaber
Copy link
Member

planthaber commented Jun 10, 2020

I tested it in my envire_visualizer setup (that used vizkit3d directly) and it works.

Still needs to be tested in a plain rock gui/vizkit (rock-display, debug drawings) context though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants