VTK crashes when no OpenGL context can be created; should fail gracefully.
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
In vtkCocoaRenderWindow::CreateGLContext() the attribute NSOpenGLPFAAccelerated is used when creating the pixel format. However, when this code is used on a headless Mac (one with no monitor connected, like a server), the pixel format will be nil, which will in turn creates a nil OpenGL context. Indeed, on a headless Mac the hardware renderer isn't available.
We're not looking for VTK to work in this situation, we'd just like that it does not crash.
The problem seems that the code assumes the context will never be nil. If the context is nil, VTK will crash later on. With no context, it is not valid to call OpenGL APIs like glGetString(), yet VTK does exactly this.
#0 0x91752150 in strlen #1 0x9178dde5 in sscanf #2 0x00dac160 in vtkOpenGLExtensionManager::ReadOpenGLExtensions at vtkOpenGLExtensionManager.cxx:479 #3 0x00dad463 in vtkOpenGLExtensionManager::Update at vtkOpenGLExtensionManager.cxx:140 #4 0x00dad13d in vtkOpenGLExtensionManager::ExtensionSupported at vtkOpenGLExtensionManager.cxx:147 #5 0x00dc6bc0 in vtkOpenGLRenderWindow::OpenGLInit at vtkOpenGLRenderWindow.cxx:230 #6 0x00df1ba5 in vtkCocoaRenderWindow::CreateAWindow at vtkCocoaRenderWindow.mm:577 #7 0x00df005c in vtkCocoaRenderWindow::Initialize at vtkCocoaRenderWindow.mm:645 #8 0x00dee51c in vtkCocoaRenderWindow::Start at vtkCocoaRenderWindow.mm:168 #9 (closed) 0x00ded91c in vtkCocoaRenderWindowInteractor::Initialize at vtkCocoaRenderWindowInteractor.mm:331