Skip to content

[visualization] Qt 6.9 and VTK 9.5 do not work with PCL on macos #6317

@themightyoarfish

Description

@themightyoarfish

I am trying to render PCLVisualizer into a Qt widget, something that has worked with qt5 and vtk 9.0 before. Since upgrading everything to Qt6, this either no longer works properly (all mouse movements are interpreted as if the left button was clicked, even though it is not, making the widget unusable) or crashes inside VTK in different places.

In trying to narrow down the issue (so far unsuccessfully), I am working with latest VTK master, and latest PCL master, and qt 6.9.1 from homebrew.

I am trying to run the qt_visualizer tutorial, and launching the program first prints some VTK warnings

2025-08-11 15:54:09.570 (   0.541s) [          5701D9]     vtkOpenGLState.cxx:867   WARN| Error glBlendFuncSeparate1 OpenGL errors detected
  0 : (1280) Invalid enum

 with stack trace of
0x104b57170 : vtksys::SystemInformationImplementation::GetProgramStack(int, int) [(libvtksys-9.5.9.5.dylib) ???:-1]
0x104b570f0 : vtksys::SystemInformation::GetProgramStack(int, int) [(libvtksys-9.5.9.5.dylib) ???:-1]
0x106ae3384 : (anonymous namespace)::reportOpenGLErrors(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) [(libvtkRenderingOpenGL2-9.5.9.5.dylib) ???:-1]
0x106ae6424 : vtkOpenGLState::vtkglBlendFuncSeparate(unsigned int, unsigned int, unsigned int, unsigned int) [(libvtkRenderingOpenGL2-9.5.9.5.dylib) ???:-1]
0x106aaab58 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.5.9.5.dylib) ???:-1]
0x107a3f918 : vtkRenderWindow::Render() [(libvtkRenderingCore-9.5.9.5.dylib) ???:-1]
0x106aae54c : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.5.9.5.dylib) ???:-1]
0x106903cd0 : vtkGenericOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.5.9.5.dylib) ???:-1]
0x107a4bd48 : vtkRenderWindowInteractor::Render() [(libvtkRenderingCore-9.5.9.5.dylib) ???:-1]
0x10199aa5c : QVTKRenderWindowAdapter::QVTKInternals::paint() [(libvtkGUISupportQt-9.5.9.5.dylib) ???:-1]
0x10199a6f8 : QVTKRenderWindowAdapter::paint() [(libvtkGUISupportQt-9.5.9.5.dylib) ???:-1]
0x101995f28 : QVTKOpenGLNativeWidget::paintGL() [(libvtkGUISupportQt-9.5.9.5.dylib) ???:-1]
0x10052d62c : QOpenGLWidgetPrivate::render() [(QtOpenGLWidgets) ???:-1]
0x109591384 : QWidget::event(QEvent*) [(QtWidgets) ???:-1]
0x10052e608 : QOpenGLWidget::event(QEvent*) [(QtOpenGLWidgets) ???:-1]
0x101996270 : QVTKOpenGLNativeWidget::event(QEvent*) [(libvtkGUISupportQt-9.5.9.5.dylib) ???:-1]
…

And then crashes with SIGSEGV

error: memory read failed for 0x0

with such a backtrace

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x0000000106b16d40 libvtkRenderingOpenGL2-9.5.1.dylib`vtkOpenGLVertexArrayObject::Private::Initialize(this=0x0000600000f00750) at vtkOpenGLVertexArrayObject.cxx:90:7
    frame #2: 0x0000000106b16918 libvtkRenderingOpenGL2-9.5.1.dylib`vtkOpenGLVertexArrayObject::Bind(this=0x000060000228afd0) at vtkOpenGLVertexArrayObject.cxx:147:21
    frame #3: 0x0000000106a5a184 libvtkRenderingOpenGL2-9.5.1.dylib`vtkOpenGLPolyDataMapper::UpdateShaders(this=0x00000001448a2200, cellBO=0x00000001448a2438, ren=0x0000000144836000, actor=0x0000000143f36470) at vtkOpenGLPolyDataMapper.cxx:2623:15
    frame #4: 0x0000000106a61d10 libvtkRenderingOpenGL2-9.5.1.dylib`vtkOpenGLPolyDataMapper::RenderPieceDraw(this=0x00000001448a2200, ren=0x0000000144836000, actor=0x0000000143f36470) at vtkOpenGLPolyDataMapper.cxx:3517:13
    frame #5: 0x0000000106a62574 libvtkRenderingOpenGL2-9.5.1.dylib`vtkOpenGLPolyDataMapper::RenderPiece(this=0x00000001448a2200, ren=0x0000000144836000, actor=0x0000000143f36470) at vtkOpenGLPolyDataMapper.cxx:3656:9
    frame #6: 0x0000000107a12080 libvtkRenderingCore-9.5.1.dylib`vtkPolyDataMapper::Render(this=0x00000001448a2200, ren=0x0000000144836000, act=0x0000000143f36470) at vtkPolyDataMapper.cxx:69:11
…

The trace points to this VTK code

class vtkOpenGLVertexArrayObject::Private
{
public:
  Private()
  {
    this->HandleVAO = 0;
    this->HandleProgram = 0;
    this->Supported = true;
    this->ForceEmulation = false;
  }
  ~Private()
  {
    if (this->HandleVAO)
    {
      glDeleteVertexArrays(1, &this->HandleVAO);
    }
  }

  void Initialize()
  {
    if (!this->ForceEmulation)
    {
      this->Supported = true;
      glGenVertexArrays(1, &this->HandleVAO);     // <----- CRASH
    }
    else
    {
      this->Supported = false;
    }
  }

Context

Restore embedded pcl visualizer functionality with recent qt and vtk on macos. I'm fully at a loss how to debug this, it also may not be a PCL issue at all, but a VTK problem.

Expected behavior

Pcl visualizer window embedded in qvtkopenglnativewidget

Current Behavior

Crash

To Reproduce

Try to build qt_visualizer tutorial against qt 6.9, VTK d3dba86dd6d189df0dd4fcfa1311eb814cf2a461 (current master) and PCL 11ed9cc (current master)

Screenshots/Code snippets

n/a

Your Environment (please complete the following information):

  • OS: macOs 15.5 (24F74)
  • Compiler: apple Clang
  • PCL Version HEAD

Possible Solution

n/a

Additional context

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions