[vtkusers] VTK 6.3/OGL2/Qt5.3.2 : QVTKWidget regression, crash after "reparenting" a widget on OSX
Simon ESNEAULT
simon.esneault at gmail.com
Thu Nov 19 04:12:53 EST 2015
Hello Ken,
I've created a merge request here :
https://gitlab.kitware.com/vtk/vtk/merge_requests/925
Can you review it and eventually allow it to master if it is the correct
fix ?
I've also added Sean McBride as a reviewer.
Thanks
Simon
2015-11-18 17:42 GMT+01:00 Ken Martin <ken.martin at kitware.com>:
> Yes, if some process is causing the opengl context to be destroyed then we
> need to release the graphics resources tied to the old context. Sounds like
> that is the case here and the cocoa window was missing it.
>
> On Wed, Nov 18, 2015 at 11:36 AM, Simon ESNEAULT <simon.esneault at gmail.com
> > wrote:
>
>> Hello Ken,
>>
>> A colleague has just found a solution that prevent the crash. Here is the
>> patch:
>>
>>
>> //----------------------------------------------------------------------------
>>
>> --- VTK/Rendering/OpenGL2/vtkCocoaRenderWindow.mm Wed Nov 18 17:25:01
>> 2015
>> +++ VTK/Rendering/OpenGL2/vtkCocoaRenderWindow.mm Wed Nov 18 17:29:12
>> 2015
>> @@ -309,6 +309,7 @@
>> this->SetRootWindow(NULL);
>> this->WindowCreated = 0;
>> this->ViewCreated = 0;
>> + this->ReleaseGraphicsResources();
>> }
>>
>>
>> //----------------------------------------------------------------------------
>>
>> It just add a call to this->ReleaseGraphicsResources() at the end of the
>> DestroyWindow() method in vtkCocoaRenderWindow implementation, which is
>> called by the Finalize() method.
>>
>> He found out this solution because this method is called in the
>> Finalize() method on the WIN32 implementation, and there is no crash in
>> Windows...
>>
>> Do you think it is the correct fix? Or can this cause some unwanted side
>> effects ?
>>
>> Regards
>> Simon
>>
>>
>> 2015-11-18 15:21 GMT+01:00 Ken Martin <ken.martin at kitware.com>:
>>
>>> (sorry for the half written email, switching to the gmail web interface
>>> has me messing up)
>>>
>>> I know zippo about Qt, but the version 120 error means that VTK thinks
>>> it has an old OpenGL 2.1 context as opposed to a 3.2 context. There is a
>>> setting in vtkOpenGLRenderWindow to indicate that it has a 3.2 context
>>>
>>>
>>> // Description::
>>> // Get if the context includes opengl core profile 3.2 support
>>> static bool GetContextSupportsOpenGL32();
>>> void SetContextSupportsOpenGL32(bool val);
>>>
>>> it could be that the vtk Qt class is creating a 3.2 context but not
>>> setting the above methods to true? Or maybe somehow not calling void
>>> vtkOpenGLRenderWindow::OpenGLInitContext()
>>>
>>> Just a guess.
>>>
>>> Thanks
>>> Ken
>>>
>>>
>>>
>>> On Wed, Nov 18, 2015 at 9:15 AM, Ken Martin <ken.martin at kitware.com>
>>> wrote:
>>>
>>>> I know zippo about Qt, but the version 120 error means that VTK thinks
>>>> it has an old OpenGL 2.1 context as opposed to a 3.2 context. There is a
>>>> setting in vtkOpenGLRenderWindow to indicate that it has a 3.2 context
>>>>
>>>>
>>>> On Wed, Nov 18, 2015 at 8:55 AM, Simon ESNEAULT <
>>>> simon.esneault at gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I've created a bug in Mantis for this
>>>>> http://www.vtk.org/Bug/view.php?id=15840
>>>>>
>>>>> Looking at the code in QVTKWidget.cxx, here is the part that may be
>>>>> causing the problem, because it handles the reparenting part...
>>>>>
>>>>>
>>>>>
>>>>> */*******************************************************************************/*
>>>>> *if(e->type() == QEvent::ParentAboutToChange)*
>>>>> * {*
>>>>> * this->markCachedImageAsDirty();*
>>>>> * if (this->mRenWin)*
>>>>> * {*
>>>>> * // Finalize the window to remove graphics resources associated
>>>>> with*
>>>>> * // this window*
>>>>> * if(this->mRenWin->GetMapped())*
>>>>> * {*
>>>>> * this->mRenWin->Finalize();*
>>>>> * }*
>>>>> * }*
>>>>> * }*
>>>>> * else if(e->type() == QEvent::ParentChange)*
>>>>> * {*
>>>>> * if(this->mRenWin)*
>>>>> * {*
>>>>> * x11_setup_window();*
>>>>> * // connect to new window*
>>>>> * this->mRenWin->SetWindowId(
>>>>> reinterpret_cast<void*>(this->winId()));*
>>>>>
>>>>> * // start up the window to create graphics resources for this
>>>>> window*
>>>>> * if(isVisible())*
>>>>> * {*
>>>>> * this->mRenWin->Start();*
>>>>> * }*
>>>>> * }*
>>>>> * }*
>>>>>
>>>>> */*******************************************************************************/*
>>>>>
>>>>> Were there any significant changes in the methods GetMapped() /
>>>>> Finalize() / Start() of vtkRenderWindow (or children implementation) during
>>>>> the development of the new rendering backend that may lead to such a crash
>>>>> :
>>>>>
>>>>>
>>>>>
>>>>> */*******************************************************************************/*
>>>>> *ERROR: In
>>>>> /Users/th-dev/EndoSize_OGL2/cmake-externals/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
>>>>> <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/th-dev/EndoSize_OGL2/cmake-externals/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
>>>>> VtkReparentingProblem`vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkOpenGLHelper&,
>>>>> vtkRenderer*, vtkActor*) + 72*
>>>>> * frame #3: 0x00000001005b8b1b
>>>>> VtkReparentingProblem`vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&,
>>>>> vtkRenderer*, vtkActor*) + 1211*
>>>>> * frame #4: 0x00000001005bb782
>>>>> VtkReparentingProblem`vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer*,
>>>>> vtkActor*) + 818*
>>>>> * frame #5: 0x00000001005bbbe3
>>>>> VtkReparentingProblem`vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer*,
>>>>> vtkActor*) + 195*
>>>>> * frame #6: 0x00000001004ba1fe
>>>>> VtkReparentingProblem`vtkPolyDataMapper::Render(vtkRenderer*, vtkActor*) +
>>>>> 174*
>>>>> * frame #7: 0x0000000100561be0
>>>>> VtkReparentingProblem`vtkOpenGLActor::Render(vtkRenderer*, vtkMapper*) +
>>>>> 144*
>>>>> * frame #8: 0x00000001004667c3
>>>>> VtkReparentingProblem`vtkActor::RenderOpaqueGeometry(vtkViewport*) + 435*
>>>>> * frame #9: 0x00000001005caa87
>>>>> VtkReparentingProblem`vtkOpenGLRenderer::UpdateGeometry() + 263*
>>>>> * frame #10: 0x00000001005ca945
>>>>> VtkReparentingProblem`vtkOpenGLRenderer::DeviceRender() + 181*
>>>>> * frame #11: 0x00000001004cb96c
>>>>> VtkReparentingProblem`vtkRenderer::Render() + 604*
>>>>> * frame #12: 0x00000001004d08cc
>>>>> VtkReparentingProblem`vtkRendererCollection::Render() + 92*
>>>>> * frame #13: 0x00000001004c5d1a
>>>>> VtkReparentingProblem`vtkRenderWindow::DoStereoRender() + 138*
>>>>> * frame #14: 0x00000001004c5098
>>>>> VtkReparentingProblem`vtkRenderWindow::Render() + 328*
>>>>> * frame #15: 0x00000001005c7816
>>>>> VtkReparentingProblem`vtkOpenGLRenderWindow::Render() + 22*
>>>>> * frame #16: 0x00000001004c8f17
>>>>> VtkReparentingProblem`vtkRenderWindowInteractor::Render() + 39*
>>>>> * frame #17: 0x00000001006831dd
>>>>> VtkReparentingProblem`QVTKWidget::paintEvent(QPaintEvent*) + 109*
>>>>> * frame #18: 0x0000000100bb73d6 QtWidgets`QWidget::event(QEvent*) +
>>>>> 1958*
>>>>> * frame #19: 0x0000000100683079
>>>>> VtkReparentingProblem`QVTKWidget::event(QEvent*) + 281*
>>>>> * frame #20: 0x0000000100b7effc
>>>>> QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300*
>>>>> * frame #21: 0x0000000100b81abb
>>>>> QtWidgets`QApplication::notify(QObject*, QEvent*) + 6187*
>>>>> * frame #22: 0x0000000101902932
>>>>> QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 114*
>>>>> * frame #23: 0x0000000100bb2035
>>>>> QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint
>>>>> const&, int, QPainter*, QWidgetBackingStore*) + 2997*
>>>>> * frame #24: 0x0000000100b8aed0
>>>>> QtWidgets`QWidgetPrivate::repaint_sys(QRegion const&) + 400*
>>>>> * frame #25: 0x0000000100bd4987
>>>>> QtWidgets`QWidgetWindow::event(QEvent*) + 423*
>>>>> * frame #26: 0x0000000100b7effc
>>>>> QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300*
>>>>> * frame #27: 0x0000000100b81abb
>>>>> QtWidgets`QApplication::notify(QObject*, QEvent*) + 6187*
>>>>> * frame #28: 0x0000000101902932
>>>>> QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 114*
>>>>> * frame #29: 0x00000001011c4d7a
>>>>> QtGui`QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*)
>>>>> + 314*
>>>>> * frame #30: 0x00000001011c08a7
>>>>> QtGui`QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)
>>>>> + 951*
>>>>> * frame #31: 0x00000001011af1cb
>>>>> QtGui`QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
>>>>> + 315*
>>>>> * frame #32: 0x0000000104a39f0d
>>>>> libqcocoa.dylib`QCocoaEventDispatcherPrivate::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 HIToolbox`RunCurrentEventLoopInMode
>>>>> + 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.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
>>>>> + 2420*
>>>>> * frame #45: 0x00000001018ff9ad
>>>>> QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381*
>>>>> * frame #46: 0x0000000101902ee7 QtCore`QCoreApplication::exec() +
>>>>> 359*
>>>>> * frame #47: 0x0000000100005dab VtkReparentingProblem`main + 59*
>>>>> * frame #48: 0x0000000100005d64 VtkReparentingProblem`start + 52*
>>>>>
>>>>>
>>>>> */*******************************************************************************/*
>>>>>
>>>>> Any hints ?
>>>>>
>>>>> Regards,
>>>>> Simon
>>>>>
>>>>> 2015-11-17 9:27 GMT+01:00 Simon ESNEAULT <simon.esneault at gmail.com>:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> After the switch to the new rendering backend, we have a crash on our
>>>>>> program after reparenting a QVTKWidget on OSX. 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, as well as a
>>>>>> complete backtrace for this crash. This used to work fine with the previous
>>>>>> backend.
>>>>>>
>>>>>> Hope this little test case helps
>>>>>>
>>>>>> Thanks
>>>>>> Simon
>>>>>>
>>>>>> --
>>>>>> ------------------------------------------------------------------
>>>>>> Simon Esneault
>>>>>> Rennes, France
>>>>>> ------------------------------------------------------------------
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> ------------------------------------------------------------------
>>>>> Simon Esneault
>>>>> Rennes, France
>>>>> ------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Ken Martin PhD
>>>> Chairman & CFO
>>>> Kitware Inc.
>>>> 28 Corporate Drive
>>>> Clifton Park NY 12065
>>>> 518 371 3971
>>>>
>>>> This communication, including all attachments, contains confidential
>>>> and legally privileged information, and it is intended only for the use of
>>>> the addressee. Access to this email by anyone else is unauthorized. If you
>>>> are not the intended recipient, any disclosure, copying, distribution or
>>>> any action taken in reliance on it is prohibited and may be unlawful. If
>>>> you received this communication in error please notify us immediately and
>>>> destroy the original message. Thank you.
>>>>
>>>
>>>
>>>
>>> --
>>> Ken Martin PhD
>>> Chairman & CFO
>>> Kitware Inc.
>>> 28 Corporate Drive
>>> Clifton Park NY 12065
>>> 518 371 3971
>>>
>>> This communication, including all attachments, contains confidential and
>>> legally privileged information, and it is intended only for the use of the
>>> addressee. Access to this email by anyone else is unauthorized. If you are
>>> not the intended recipient, any disclosure, copying, distribution or any
>>> action taken in reliance on it is prohibited and may be unlawful. If you
>>> received this communication in error please notify us immediately and
>>> destroy the original message. Thank you.
>>>
>>
>>
>>
>> --
>> ------------------------------------------------------------------
>> Simon Esneault
>> Rennes, France
>> ------------------------------------------------------------------
>>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee. Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message. Thank you.
>
--
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151119/20629db0/attachment.html>
More information about the vtkusers
mailing list