Vtk, Qt and long VTK operations

We are currently writing a Qt6 based application that uses VTK as the back end 3D rendering. As our data sets get larger and larger the VTK operations are getting longer and longer. This leads to the main UI thread being taken over by the VTK processing which manifests itself as a “spinning beach ball” or Windows stating that the application is not responding. Eventually the VTK algorithms finish up and the everything goes back to “normal” but this is a very sub-par user experience.

I have considered trying to run some of the VTK processing on a separate thread but those who I have talked to on the side state this is a “bad idea”.

We have tried hooking into the VTK progress monitoring in order to essentially manually run the Qt::eventLoop() each time we get a progress message but this lead to some other issues (not saying that our implementation was correct on this one)

We are currently trying to fork another ‘helper’ Qt application that pops up a modal progress dialog. The main application sends progress messages to the ‘helper’ application to display progress messages.

Has anyone else tackled this problem and is willing to share how they accomplished their solution?

Thank You

Hello,

This is true when it comes to the classes involved with rendering and interacting with Qt. But you can safely run VTK algorithms in another thread, get the resulting object and then return it to the rendering pipeline’s thread for rendering. You can resort to C++'s move semantics to transfer ownership of large objects between different scopes without copying them.

best,

PC

1 Like

Some parts of vtkGarbageCollector are not thread safe. I wonder if this will affect the functionality of VTK algorithms.

For example deferred collection wouldn’t work. I don’t want to sound as if I know what’s going on here but I’ve encountered it while running a unit test from CommonCore module “TestGarbageCollector.cxx” in a different thread. The delete call was not deferred.

https://gitlab.kitware.com/vtk/vtk/-/blob/90ef0a2a28c7647adccb5e4687c62e6846a238b7/Common/Core/Testing/Cxx/TestGarbageCollector.cxx