Skip to content

Fix race condition in vtkXOpenGLRenderWindow::SetSize

Alex Dewar requested to merge alexdewar/vtk:fix_xresize_freeze into master

Currently, VTK attempts to resize the window using XResizeWindow, then verifies that the resize has actually happened by calling XGetWindowAttributes afterwards. If the size returned by XGetWindowAttributes doesn't match what was requested with XResizeWindow, it is assumed that the resize has not yet happened and XIfEvent is used to wait until the event has actually been processed by the X server.

The problem is that the size of the window can seemingly be changed between when it is set and when it is queried afterwards. When using the Python wrapper on Linux (specifically the Qt wrapper), sometimes VTK hangs indefinitely when waiting on XIfEvent and sometimes not (see issue #18701 (closed)). Further analysis showed that the size had been changed again between setting and getting the window size.

I'm not sure where the window size is being set from, though presumably it is being called from another thread.

I have verified that this commit fixes the issue by repeatedly running my example program successfully -- the hang doesn't happen anymore. Tested on both XWayland and regular X11.

Fixes #18701 (closed).

Merge request reports