issue with vtkOpenGLRenderWindow on linux with vtk=9.1

I am trying to run a minimal example with python and vtk which was adapted from this link but with PySide2 instead of Qt4.

This works fine on my windows machine, with any vtk 9.x.x version.

However, on linux I can run this with vtk < 9.1, but with vtk 9.1.0 I get the following error:

Qt: Session management error: None of the authentication protocols specified are supported
2022-05-24 15:40:09.687 (   0.590s) [        CC1BB740]vtkOpenGLRenderWindow.c:493    ERR| vtkEGLRenderWindow (0x55732a7a9450): GLEW could not be initialized: Missing GL version
Segmentation fault (core dumped)

Any thoughts on why this is happening? Thank you.

Adapted example code:

import sys
import vtk
from PySide2 import QtWidgets
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
 
class MainWindow(QtWidgets.QMainWindow):
 
    def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self, parent)
 
        self.frame = QtWidgets.QFrame()
 
        self.vl = QtWidgets.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)
 
        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create source
        source = vtk.vtkSphereSource()
        source.SetCenter(0, 0, 0)
        source.SetRadius(5.0)
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
 
        self.ren.ResetCamera()
 
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
 
        self.show()
        self.iren.Initialize()
 
 
if __name__ == "__main__":
 
    app = QtWidgets.QApplication(sys.argv)
 
    window = MainWindow()
 
    sys.exit(app.exec_())
1 Like

I forgot to mention that I installed vtk from conda-forge.

The Qt error message is probably a red herring. So let’s work on the hypothesis that the error is with OpenGL.

What OpenGL drivers are you using? You can find them with this command:

glxinfo | grep OpenGL

Does glxinfo give the same answer when you run it with your conda environment activates, as when you conda environment is not activated?

Hi,

The command gives the same result when I run it with either of my conda environments activated or not.


OpenGL Version String: 4.6.0 NVIDIA 430.40

The version of vtk I’m having trouble with is vtk 9.1.0 osmesa_py37h29869c8_108
The version I have which works is: vtk 9.0.3 no_osmesa_py37hafc82d9_106

OpenGL 4.6 is definitely sufficient for VTK 9.1. To eliminate Qt as a possible source of the segfault, can you try a non-Qt VTK example like the cylinder example?

You can also call renderWindow.ReportCapabilities() after the first Render to get more information about the VTK<->OpenGL connection (assuming that the Render() doesn’t cause a segfault).

    # Render and interact
    renderWindow.Render()
    print(renderWindow.ReportCapabilities())
    # The Start() is only for non-Qt apps
    renderWindowInteractor.Start()