Sample Java code crashes fatally on Macs
When trying to run the JOGLConeRendering sample code from VTK9, with the latest code from MR 6629, the following crash occurs:
2020-04-02 16:28:47.783 ( 21.002s) [Java: AWT-EventQ]vtkOpenGLRenderWindow.c:578 ERR| vtkGenericOpenGLRenderWindow (0x7f9dde0506e0): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr. If you are on windows and using Microsoft remote desktop note that it only supports OpenGL 3.2 with nvidia quadro cards. You can use other remoting software such as nomachine to avoid this issue.
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:79 WARN| Error in cache state for GL_BLEND
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:86 WARN| Error in cache state for GL_DEPTH_TEST
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:101 WARN| Error in cache state for GL_MULTISAMPLE
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:109 WARN| Error in cache state for GL_SCISSOR_TEST
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:140 WARN| Error in cache state for GL_SCISSOR_BOX
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:161 WARN| Error in cache state for GL_DEPTH_FUNC
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:168 WARN| Error in cache state for GL_BLEND_SRC_RGB
2020-04-02 16:28:47.785 ( 21.004s) [Java: AWT-EventQ] vtkOpenGLState.cxx:196 WARN| Error in cache state for GL_DRAW_FRAMEBUFFER_BINDING
2020-04-02 16:28:47.788 ( 21.007s) [Java: AWT-EventQ] vtkOpenGLState.cxx:265 WARN| at stack loc
0x1438fc272 : vtksys::SystemInformationImplementation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x1438fc1d0 : vtksys::SystemInformation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x14919b91c : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14919db96 : vtkOpenGLState::vtkBindFramebuffer(unsigned int, vtkOpenGLFramebufferObject*) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1490777a3 : vtkOpenGLFramebufferObject::Bind(unsigned int) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1490750fa : vtkOpenGLFramebufferObject::Bind() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14907bce2 : vtkOpenGLFramebufferObject::PopulateFramebuffer(int, int, bool, int, int, bool, int, int, bool) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14915fc22 : vtkOpenGLRenderWindow::CreateOffScreenFramebuffer(int, int) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14915fa14 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x13ecc5f7e : vtkRenderWindow::Render() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x149163aff : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14903773c : vtkGenericOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x148ed7ba1 : Java_vtk_vtkGenericOpenGLRenderWindow_Render_132 [(libvtkRenderingOpenGL2Java.jnilib) ???:-1]
0x107b3d954 : ??? [(???) ???:-1]
0x107b2fc4d : ??? [(???) ???:-1]
2020-04-02 16:28:47.788 ( 21.007s) [Java: AWT-EventQ] vtkOpenGLState.cxx:1380 WARN| Hardware does not support the number of textures defined.
2020-04-02 16:28:47.789 ( 21.008s) [Java: AWT-EventQ] vtkTextureObject.cxx:1658 ERR| vtkTextureObject (0x7f9d1d431000): failed at glTexImage2D 1 OpenGL errors detected
0 : (1280) Invalid enum
2020-04-02 16:28:47.789 ( 21.008s) [Java: AWT-EventQ] vtkOpenGLState.cxx:1380 WARN| Hardware does not support the number of textures defined.
2020-04-02 16:28:47.789 ( 21.008s) [Java: AWT-EventQ] vtkOpenGLState.cxx:222 WARN| Error in cache state for GL_DRAW_BUFFER got 0 expected1026
2020-04-02 16:28:47.790 ( 21.009s) [Java: AWT-EventQ] vtkOpenGLState.cxx:265 WARN| at stack loc
0x1438fc272 : vtksys::SystemInformationImplementation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x1438fc1d0 : vtksys::SystemInformation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x14919b91c : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14919db96 : vtkOpenGLState::vtkBindFramebuffer(unsigned int, vtkOpenGLFramebufferObject*) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1490777a3 : vtkOpenGLFramebufferObject::Bind(unsigned int) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1490750fa : vtkOpenGLFramebufferObject::Bind() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14915fa48 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x13ecc5f7e : vtkRenderWindow::Render() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x149163aff : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14903773c : vtkGenericOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x148ed7ba1 : Java_vtk_vtkGenericOpenGLRenderWindow_Render_132 [(libvtkRenderingOpenGL2Java.jnilib) ???:-1]
0x107b3d954 : ??? [(???) ???:-1]
0x107b2fc4d : ??? [(???) ???:-1]
2020-04-02 16:28:47.793 ( 21.012s) [Java: AWT-EventQ] vtkOpenGLState.cxx:961 WARN| Error glEnable/Disable1 OpenGL errors detected
0 : (1286) Invalid framebuffer operation
with stack trace of
0x1438fc272 : vtksys::SystemInformationImplementation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x1438fc1d0 : vtksys::SystemInformation::GetProgramStack(int, int) [(libvtksys-9.0.9.0.0.dylib) ???:-1]
0x14919d512 : (anonymous namespace)::reportOpenGLErrors(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1491a0795 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x1491a0920 : vtkOpenGLState::vtkglEnable(unsigned int) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14916d021 : vtkOpenGLRenderer::Clear() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14904adbe : vtkOpenGLCamera::Render(vtkRenderer*) [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x13eceb872 : vtkRenderer::UpdateCamera() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x149168db7 : vtkOpenGLRenderer::DeviceRender() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x13eceacce : vtkRenderer::Render() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x13ed05cce : vtkRendererCollection::Render() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x13ecc630c : vtkRenderWindow::DoStereoRender() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x13ecc60a5 : vtkRenderWindow::Render() [(libvtkRenderingCore-9.0.9.0.0.dylib) ???:-1]
0x149163aff : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x14903773c : vtkGenericOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.0.9.0.0.dylib) ???:-1]
0x148ed7ba1 : Java_vtk_vtkGenericOpenGLRenderWindow_Render_132 [(libvtkRenderingOpenGL2Java.jnilib) ???:-1]
0x107b3d954 : ??? [(???) ???:-1]
0x107b2fc4d : ??? [(???) ???:-1]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=5720, tid=57863
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/steelrj1/vtk9.0rc1/vtkjavatest/hs_err_pid5720.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Abort trap: 6
I have been able to fix this in the past by asking for GLProfile.getMaximum(true) instead of GLProfile.getDefault() in the vtkJoglCanvasComponent.java and vtkJoglPanelComponent.java classes. I'm not sure if this is purely a mac issue or not, but it definitely has caused this problem to go away in the past, and force the system to see the full GL capabilities of the Mac (which is brand new, by the way). I'll submit an MR for this assuming this previous fix works.