QVTKWidget regression, crash after "reparenting" a widget on OSX
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
VTK 6.3 / OGL2 / Qt 5.3.2, OSX
A program will crash after reparenting a QVTKWidget on OSX with the new OpenGL backend. The crash is in the method vtkShaderProgram::FindUniform() but we suspect it is about the OpenGL context not being ready on time for the next paintEvent with the new parent.
Attached is a program that reproduce the problem, and here is a full backtrace :
ERROR: In /Users/gloups/VTK/src/Rendering/OpenGL2/vtkShaderProgram.cxx, line 354 vtkShaderProgram (0x6000001809c0): 1: #version 120 2: #define highp 3: #define mediump 4: #define lowp 5: 6: /========================================================================= 7: 8: Program: Visualization Toolkit 9: Module: vtkPolyDataVS.glsl 10: 11: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 12: All rights reserved. 13: See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 14: 15: This software is distributed WITHOUT ANY WARRANTY; without even 16: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 17: PURPOSE. See the above copyright notice for more information. 18: 19: =========================================================================/ 20: 21: attribute vec4 vertexMC; 22: 23: // frag position in VC 24: varying vec4 vertexVCVSOutput; 25: 26: // optional normal declaration 27: attribute vec3 normalMC; 28: uniform mat3 normalMatrix; 29: varying vec3 normalVCVSOutput; 30: 31: // extra lighting parameters 32: //VTK::Light::Dec 33: 34: // Texture coordinates 35: //VTK::TCoord::Dec 36: 37: // material property values 38: //VTK::Color::Dec 39: 40: // clipping plane vars 41: //VTK::Clip::Dec 42: 43: // camera and actor matrix values 44: uniform mat4 MCDCMatrix; 45: uniform mat4 MCVCMatrix; 46: 47: // Apple Bug 48: //VTK::PrimID::Dec 49: 50: void main() 51: { 52: //VTK::Color::Impl 53: 54: normalVCVSOutput = normalMatrix * normalMC; 55: 56: //VTK::TCoord::Impl 57: 58: //VTK::Clip::Impl 59: 60: //VTK::PrimID::Impl 61: 62: vertexVCVSOutput = MCVCMatrix * vertexMC; 63: gl_Position = MCDCMatrix * vertexMC; 64: 65: 66: //VTK::Light::Impl 67: } 68:
ERROR: In /Users/gloups/VTK/src/Rendering/OpenGL2/vtkShaderProgram.cxx, line 355 vtkShaderProgram (0x6000001809c0): ERROR: 0:1: '' : version '120' is not supported ERROR: 0:2: '' : #version required and missing. ERROR: 0:21: 'attribute' : syntax error: syntax error
(lldb) bt
- thread #1: tid = 0x600e30, 0x0000000100609f1f VtkReparentingProblem`vtkShaderProgram::FindUniform(char const*) + 31, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x60)
- frame #0: 0x0000000100609f1f VtkReparentingProblem
vtkShaderProgram::FindUniform(char const*) + 31 frame #1: 0x00000001006074ab VtkReparentingProblem
vtkShaderProgram::SetUniformi(char const*, int) + 27 frame #2: 0x00000001005b8c28 VtkReparentingProblemvtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkOpenGLHelper&, vtkRenderer*, vtkActor*) + 72 frame #3: 0x00000001005b8b1b VtkReparentingProblem
vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&, vtkRenderer*, vtkActor*) + 1211 frame #4: 0x00000001005bb782 VtkReparentingProblemvtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer*, vtkActor*) + 818 frame #5: 0x00000001005bbbe3 VtkReparentingProblem
vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer*, vtkActor*) + 195 frame #6: 0x00000001004ba1fe VtkReparentingProblemvtkPolyDataMapper::Render(vtkRenderer*, vtkActor*) + 174 frame #7: 0x0000000100561be0 VtkReparentingProblem
vtkOpenGLActor::Render(vtkRenderer*, vtkMapper*) + 144 frame #8: 0x00000001004667c3 VtkReparentingProblemvtkActor::RenderOpaqueGeometry(vtkViewport*) + 435 frame #9: 0x00000001005caa87 VtkReparentingProblem
vtkOpenGLRenderer::UpdateGeometry() + 263 frame #10: 0x00000001005ca945 VtkReparentingProblemvtkOpenGLRenderer::DeviceRender() + 181 frame #11: 0x00000001004cb96c VtkReparentingProblem
vtkRenderer::Render() + 604 frame #12: 0x00000001004d08cc VtkReparentingProblemvtkRendererCollection::Render() + 92 frame #13: 0x00000001004c5d1a VtkReparentingProblem
vtkRenderWindow::DoStereoRender() + 138 frame #14: 0x00000001004c5098 VtkReparentingProblemvtkRenderWindow::Render() + 328 frame #15: 0x00000001005c7816 VtkReparentingProblem
vtkOpenGLRenderWindow::Render() + 22 frame #16: 0x00000001004c8f17 VtkReparentingProblemvtkRenderWindowInteractor::Render() + 39 frame #17: 0x00000001006831dd VtkReparentingProblem
QVTKWidget::paintEvent(QPaintEvent*) + 109 frame #18: 0x0000000100bb73d6 QtWidgetsQWidget::event(QEvent*) + 1958 frame #19: 0x0000000100683079 VtkReparentingProblem
QVTKWidget::event(QEvent*) + 281 frame #20: 0x0000000100b7effc QtWidgetsQApplicationPrivate::notify_helper(QObject*, QEvent*) + 300 frame #21: 0x0000000100b81abb QtWidgets
QApplication::notify(QObject*, QEvent*) + 6187 frame #22: 0x0000000101902932 QtCoreQCoreApplication::notifyInternal(QObject*, QEvent*) + 114 frame #23: 0x0000000100bb2035 QtWidgets
QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 2997 frame #24: 0x0000000100b8aed0 QtWidgetsQWidgetPrivate::repaint_sys(QRegion const&) + 400 frame #25: 0x0000000100bd4987 QtWidgets
QWidgetWindow::event(QEvent*) + 423 frame #26: 0x0000000100b7effc QtWidgetsQApplicationPrivate::notify_helper(QObject*, QEvent*) + 300 frame #27: 0x0000000100b81abb QtWidgets
QApplication::notify(QObject*, QEvent*) + 6187 frame #28: 0x0000000101902932 QtCoreQCoreApplication::notifyInternal(QObject*, QEvent*) + 114 frame #29: 0x00000001011c4d7a QtGui
QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) + 314 frame #30: 0x00000001011c08a7 QtGuiQGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 951 frame #31: 0x00000001011af1cb QtGui
QWindowSystemInterface::sendWindowSystemEvents(QFlagsQEventLoop::ProcessEventsFlag) + 315 frame #32: 0x0000000104a39f0d libqcocoa.dylibQCocoaEventDispatcherPrivate::processPostedEvents() + 317 frame #33: 0x0000000104a3a8a8 libqcocoa.dylib
QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 40 frame #34: 0x00007fff8f9e3a01 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 frame #35: 0x00007fff8f9d5b8d CoreFoundation
__CFRunLoopDoSources0 + 269 frame #36: 0x00007fff8f9d51bf CoreFoundation__CFRunLoopRun + 927 frame #37: 0x00007fff8f9d4bd8 CoreFoundation
CFRunLoopRunSpecific + 296 frame #38: 0x00007fff8b65f56f HIToolboxRunCurrentEventLoopInMode + 235 frame #39: 0x00007fff8b65f2ea HIToolbox
ReceiveNextEventCommon + 431 frame #40: 0x00007fff8b65f12b HIToolbox_BlockUntilNextEventMatchingListInModeWithFilter + 71 frame #41: 0x00007fff894cf8ab AppKit
_DPSNextEvent + 978 frame #42: 0x00007fff894cee58 AppKit-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346 frame #43: 0x00007fff894c4af3 AppKit
-[NSApplication run] + 594 frame #44: 0x0000000104a395e4 libqcocoa.dylibQCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2420 frame #45: 0x00000001018ff9ad QtCore
QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) + 381 frame #46: 0x0000000101902ee7 QtCoreQCoreApplication::exec() + 359 frame #47: 0x0000000100005dab VtkReparentingProblem
main + 59 frame #48: 0x0000000100005d64 VtkReparentingProblem`start + 52
- frame #0: 0x0000000100609f1f VtkReparentingProblem
Hope this test case helps
Thanks Simon