<div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 11:36 AM, Simon ESNEAULT <span dir="ltr"><<a href="mailto:simon.esneault@gmail.com" target="_blank">simon.esneault@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Ken,<br><br>A colleague has just found a solution that prevent the crash. Here is the patch:<br><div><br> //----------------------------------------------------------------------------<div><br><div><div>--- VTK/Rendering/OpenGL2/vtkCocoaRenderWindow.mm<span style="white-space:pre-wrap"> </span>Wed Nov 18 17:25:01 2015</div><div>+++ VTK/Rendering/OpenGL2/vtkCocoaRenderWindow.mm<span style="white-space:pre-wrap"> </span>Wed Nov 18 17:29:12 2015</div><div>@@ -309,6 +309,7 @@</div><div> this->SetRootWindow(NULL);</div><div> this->WindowCreated = 0;</div><div> this->ViewCreated = 0;</div><div>+ this->ReleaseGraphicsResources();</div><div> }</div></div><div><br></div><div> //----------------------------------------------------------------------------</div><div><br></div><div>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.<br><br>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...<br><br>Do you think it is the correct fix? Or can this cause some unwanted side effects ? <br><br>Regards<br>Simon</div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-18 15:21 GMT+01:00 Ken Martin <span dir="ltr"><<a href="mailto:ken.martin@kitware.com" target="_blank">ken.martin@kitware.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">(sorry for the half written email, switching to the gmail web interface has me messing up) </span><span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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</span><br><div><span style="font-size:12.8px"><br></span></div></div><div><span style="font-size:12.8px"><br></span></div></span><div><div><span style="font-size:12.8px">// Description::</span></div><div><span style="font-size:12.8px"> // Get if the context includes opengl core profile 3.2 support</span></div><div><span style="font-size:12.8px"> static bool GetContextSupportsOpenGL32();</span></div><div><span style="font-size:12.8px"> void SetContextSupportsOpenGL32(bool val);</span></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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()</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Just a guess.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div><span><font color="#888888"><div><span style="font-size:12.8px">Ken</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 9:15 AM, Ken Martin <span dir="ltr"><<a href="mailto:ken.martin@kitware.com" target="_blank">ken.martin@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 8:55 AM, Simon ESNEAULT <span dir="ltr"><<a href="mailto:simon.esneault@gmail.com" target="_blank">simon.esneault@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<br><br>I've created a bug in Mantis for this<br><a href="http://www.vtk.org/Bug/view.php?id=15840" target="_blank">http://www.vtk.org/Bug/view.php?id=15840</a><br><br>Looking at the code in QVTKWidget.cxx, here is the part that may be causing the problem, because it handles the reparenting part...<br><br><i>/*******************************************************************************/<br></i><div><i>if(e->type() == QEvent::ParentAboutToChange)</i></div><div><i> {</i></div><div><i> this->markCachedImageAsDirty();</i></div><div><i> if (this->mRenWin)</i></div><div><i> {</i></div><div><i> // Finalize the window to remove graphics resources associated with</i></div><div><i> // this window</i></div><div><i> if(this->mRenWin->GetMapped())</i></div><div><i> {</i></div><div><i> this->mRenWin->Finalize();</i></div><div><i> }</i></div><div><i> }</i></div><div><i> }</i></div><div><i> else if(e->type() == QEvent::ParentChange)</i></div><div><i> {</i></div><div><i> if(this->mRenWin)</i></div><div><i> {</i></div><div><i> x11_setup_window();</i></div><div><i> // connect to new window</i></div><div><i> this->mRenWin->SetWindowId( reinterpret_cast<void*>(this->winId()));</i></div><div><i><br></i></div><div><i> // start up the window to create graphics resources for this window</i></div><div><i> if(isVisible())</i></div><div><i> {</i></div><div><i> this->mRenWin->Start();</i></div><div><i> }</i></div><div><i> }</i></div><div><i> }</i></div><i>/*******************************************************************************/</i><br><br><div>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 : </div><div><br></div><div><i>/*******************************************************************************/<br></i><div><i>ERROR: In /Users/th-dev/EndoSize_OGL2/cmake-externals/VTK/src/Rendering/OpenGL2/vtkShaderProgram.cxx, line 354</i></div><div><i>vtkShaderProgram (0x6000001809c0): 1: #version 120</i></div><div><i>2: #define highp</i></div><div><i>3: #define mediump</i></div><div><i>4: #define lowp</i></div><div><i>5: </i></div><div><i>6: /*=========================================================================</i></div><div><i>7: </i></div><div><i>8: Program: Visualization Toolkit</i></div><div><i>9: Module: vtkPolyDataVS.glsl</i></div><div><i>10: </i></div><div><i>11: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen</i></div><div><i>12: All rights reserved.</i></div><div><i>13: See Copyright.txt or <a href="http://www.kitware.com/Copyright.htm" target="_blank">http://www.kitware.com/Copyright.htm</a> for details.</i></div><div><i>14: </i></div><div><i>15: This software is distributed WITHOUT ANY WARRANTY; without even</i></div><div><i>16: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</i></div><div><i>17: PURPOSE. See the above copyright notice for more information.</i></div><div><i>18: </i></div><div><i>19: =========================================================================*/</i></div><div><i>20: </i></div><div><i>21: attribute vec4 vertexMC;</i></div><div><i>22: </i></div><div><i>23: // frag position in VC</i></div><div><i>24: varying vec4 vertexVCVSOutput;</i></div><div><i>25: </i></div><div><i>26: // optional normal declaration</i></div><div><i>27: attribute vec3 normalMC;</i></div><div><i>28: uniform mat3 normalMatrix;</i></div><div><i>29: varying vec3 normalVCVSOutput;</i></div><div><i>30: </i></div><div><i>31: // extra lighting parameters</i></div><div><i>32: //VTK::Light::Dec</i></div><div><i>33: </i></div><div><i>34: // Texture coordinates</i></div><div><i>35: //VTK::TCoord::Dec</i></div><div><i>36: </i></div><div><i>37: // material property values</i></div><div><i>38: //VTK::Color::Dec</i></div><div><i>39: </i></div><div><i>40: // clipping plane vars</i></div><div><i>41: //VTK::Clip::Dec</i></div><div><i>42: </i></div><div><i>43: // camera and actor matrix values</i></div><div><i>44: uniform mat4 MCDCMatrix;</i></div><div><i>45: uniform mat4 MCVCMatrix;</i></div><div><i>46: </i></div><div><i>47: // Apple Bug</i></div><div><i>48: //VTK::PrimID::Dec</i></div><div><i>49: </i></div><div><i>50: void main()</i></div><div><i>51: {</i></div><div><i>52: //VTK::Color::Impl</i></div><div><i>53: </i></div><div><i>54: normalVCVSOutput = normalMatrix * normalMC;</i></div><div><i>55: </i></div><div><i>56: //VTK::TCoord::Impl</i></div><div><i>57: </i></div><div><i>58: //VTK::Clip::Impl</i></div><div><i>59: </i></div><div><i>60: //VTK::PrimID::Impl</i></div><div><i>61: </i></div><div><i>62: vertexVCVSOutput = MCVCMatrix * vertexMC;</i></div><div><i>63: gl_Position = MCDCMatrix * vertexMC;</i></div><div><i>64: </i></div><div><i>65: </i></div><div><i>66: //VTK::Light::Impl</i></div><div><i>67: }</i></div><div><i>68: </i></div><div><i><br></i></div><div><i><br></i></div><div><i>ERROR: In /Users/th-dev/EndoSize_OGL2/cmake-externals/VTK/src/Rendering/OpenGL2/vtkShaderProgram.cxx, line 355</i></div><div><i>vtkShaderProgram (0x6000001809c0): ERROR: 0:1: '' : version '120' is not supported</i></div><div><i>ERROR: 0:2: '' : #version required and missing.</i></div><div><i>ERROR: 0:21: 'attribute' : syntax error: syntax error</i></div><div><i><br></i></div><div><i><br></i></div><div><i>(lldb) bt</i></div><div><i>* 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)</i></div><div><i> * frame #0: 0x0000000100609f1f VtkReparentingProblem`vtkShaderProgram::FindUniform(char const*) + 31</i></div><div><i> frame #1: 0x00000001006074ab VtkReparentingProblem`vtkShaderProgram::SetUniformi(char const*, int) + 27</i></div><div><i> frame #2: 0x00000001005b8c28 VtkReparentingProblem`vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkOpenGLHelper&, vtkRenderer*, vtkActor*) + 72</i></div><div><i> frame #3: 0x00000001005b8b1b VtkReparentingProblem`vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&, vtkRenderer*, vtkActor*) + 1211</i></div><div><i> frame #4: 0x00000001005bb782 VtkReparentingProblem`vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer*, vtkActor*) + 818</i></div><div><i> frame #5: 0x00000001005bbbe3 VtkReparentingProblem`vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer*, vtkActor*) + 195</i></div><div><i> frame #6: 0x00000001004ba1fe VtkReparentingProblem`vtkPolyDataMapper::Render(vtkRenderer*, vtkActor*) + 174</i></div><div><i> frame #7: 0x0000000100561be0 VtkReparentingProblem`vtkOpenGLActor::Render(vtkRenderer*, vtkMapper*) + 144</i></div><div><i> frame #8: 0x00000001004667c3 VtkReparentingProblem`vtkActor::RenderOpaqueGeometry(vtkViewport*) + 435</i></div><div><i> frame #9: 0x00000001005caa87 VtkReparentingProblem`vtkOpenGLRenderer::UpdateGeometry() + 263</i></div><div><i> frame #10: 0x00000001005ca945 VtkReparentingProblem`vtkOpenGLRenderer::DeviceRender() + 181</i></div><div><i> frame #11: 0x00000001004cb96c VtkReparentingProblem`vtkRenderer::Render() + 604</i></div><div><i> frame #12: 0x00000001004d08cc VtkReparentingProblem`vtkRendererCollection::Render() + 92</i></div><div><i> frame #13: 0x00000001004c5d1a VtkReparentingProblem`vtkRenderWindow::DoStereoRender() + 138</i></div><div><i> frame #14: 0x00000001004c5098 VtkReparentingProblem`vtkRenderWindow::Render() + 328</i></div><div><i> frame #15: 0x00000001005c7816 VtkReparentingProblem`vtkOpenGLRenderWindow::Render() + 22</i></div><div><i> frame #16: 0x00000001004c8f17 VtkReparentingProblem`vtkRenderWindowInteractor::Render() + 39</i></div><div><i> frame #17: 0x00000001006831dd VtkReparentingProblem`QVTKWidget::paintEvent(QPaintEvent*) + 109</i></div><div><i> frame #18: 0x0000000100bb73d6 QtWidgets`QWidget::event(QEvent*) + 1958</i></div><div><i> frame #19: 0x0000000100683079 VtkReparentingProblem`QVTKWidget::event(QEvent*) + 281</i></div><div><i> frame #20: 0x0000000100b7effc QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300</i></div><div><i> frame #21: 0x0000000100b81abb QtWidgets`QApplication::notify(QObject*, QEvent*) + 6187</i></div><div><i> frame #22: 0x0000000101902932 QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 114</i></div><div><i> frame #23: 0x0000000100bb2035 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 2997</i></div><div><i> frame #24: 0x0000000100b8aed0 QtWidgets`QWidgetPrivate::repaint_sys(QRegion const&) + 400</i></div><div><i> frame #25: 0x0000000100bd4987 QtWidgets`QWidgetWindow::event(QEvent*) + 423</i></div><div><i> frame #26: 0x0000000100b7effc QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300</i></div><div><i> frame #27: 0x0000000100b81abb QtWidgets`QApplication::notify(QObject*, QEvent*) + 6187</i></div><div><i> frame #28: 0x0000000101902932 QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 114</i></div><div><i> frame #29: 0x00000001011c4d7a QtGui`QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) + 314</i></div><div><i> frame #30: 0x00000001011c08a7 QtGui`QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 951</i></div><div><i> frame #31: 0x00000001011af1cb QtGui`QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 315</i></div><div><i> frame #32: 0x0000000104a39f0d libqcocoa.dylib`QCocoaEventDispatcherPrivate::processPostedEvents() + 317</i></div><div><i> frame #33: 0x0000000104a3a8a8 libqcocoa.dylib`QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 40</i></div><div><i> frame #34: 0x00007fff8f9e3a01 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17</i></div><div><i> frame #35: 0x00007fff8f9d5b8d CoreFoundation`__CFRunLoopDoSources0 + 269</i></div><div><i> frame #36: 0x00007fff8f9d51bf CoreFoundation`__CFRunLoopRun + 927</i></div><div><i> frame #37: 0x00007fff8f9d4bd8 CoreFoundation`CFRunLoopRunSpecific + 296</i></div><div><i> frame #38: 0x00007fff8b65f56f HIToolbox`RunCurrentEventLoopInMode + 235</i></div><div><i> frame #39: 0x00007fff8b65f2ea HIToolbox`ReceiveNextEventCommon + 431</i></div><div><i> frame #40: 0x00007fff8b65f12b HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71</i></div><div><i> frame #41: 0x00007fff894cf8ab AppKit`_DPSNextEvent + 978</i></div><div><i> frame #42: 0x00007fff894cee58 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346</i></div><div><i> frame #43: 0x00007fff894c4af3 AppKit`-[NSApplication run] + 594</i></div><div><i> frame #44: 0x0000000104a395e4 libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2420</i></div><div><i> frame #45: 0x00000001018ff9ad QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381</i></div><div><i> frame #46: 0x0000000101902ee7 QtCore`QCoreApplication::exec() + 359</i></div><div><i> frame #47: 0x0000000100005dab VtkReparentingProblem`main + 59</i></div><div><i> frame #48: 0x0000000100005d64 VtkReparentingProblem`start + 52</i></div></div><div><i><br></i></div><div><i>/*******************************************************************************/</i><br><br>Any hints ?<br><br>Regards,<br>Simon</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-17 9:27 GMT+01:00 Simon ESNEAULT <span dir="ltr"><<a href="mailto:simon.esneault@gmail.com" target="_blank">simon.esneault@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<br><br>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.<br><br>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.<br><br>Hope this little test case helps<br><br>Thanks<span><font color="#888888"><br>Simon<span><font color="#888888"><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div>------------------------------------------------------------------<br>Simon Esneault<div>Rennes, France<br>------------------------------------------------------------------</div></div></div></div>
</font></span></font></span></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div>------------------------------------------------------------------<br>Simon Esneault<div>Rennes, France<br>------------------------------------------------------------------</div></div></div></div>
</font></span></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br><a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><div><br></div><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">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.</span></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div>Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br><a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><div><br></div><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">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.</span></div></div></div>
</font></span></div><span class="HOEnZb"><font color="#888888">
</font></span></div></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div>------------------------------------------------------------------<br>Simon Esneault<div>Rennes, France<br>------------------------------------------------------------------</div></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br>518 371 3971<div><br></div><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">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.</span></div></div></div>
</div>