This page documents the update of Slicer to use VTK 8.0.
- 1 Overview
- 2 Status
- 3 Migration guide
- 4 Future work
It is planned to update the version of VTK that Slicer uses from 7.1 to 8.0.
- Builds on Linux and Windows; Mac is untested. Additional test runs are in progress.
- Windows (VS2013) may have a dependency issue related to Python wrapping. At first, wrapping seems to not use the hierarchy files or runs before they are available. Building again generates the wrapped classes correctly.
- Windows shows OpenGL errors at exit with the OpenGL backend. Likely a regression from https://github.com/Kitware/VTK/commit/49802a3d15fac9dd64feb6e86fb8d0dfc2d31a05.
Generic Warning: In C:\path\to\S\VTKv7\Rendering\OpenGL\vtkOpenGLDisplayListPainter.cxx, line 52 failed after ReleaseAllLists 16 OpenGL errors detected 0 : (1282) Invalid operation 1 : (1282) Invalid operation ... 15 : (1282) Invalid operation
Update "VTKv7" project name to "VTKv8". Add Slicer_VTK_VERSION_MAJOR option to support building with VTK7 and VTK8, as was done for VTK5/6 in https://github.com/Slicer/Slicer/commit/50281153c57c683106498295ea82472eaa20eee4. VTK7 wrapping should not build the hierarchy files. EMSegment remote module will require updates to fix vtkDebugLeaks output.(updated in r17131)
Outstanding VTK issues
Respect access specifier of using statements in wrapping: https://gitlab.kitware.com/vtk/vtk/merge_requests/2988
- WIP: Fix OpenGL errors when destroying vtkWin32OpenGLRenderWindow: https://gitlab.kitware.com/vtk/vtk/merge_requests/2986
- Would be great to get a proper fix from the VTK team for this regression.
- Update Slicer/VTK branch to include upstreamed fixes
Slicer-specific VTK commits
Slicer's VTK 8.0 branch includes fixes/changes that aren't in upstream:
- Respect access specifier of using statements in wrapping
- ENH: Allow selection of seed points using vtkSeedWidget
- Ensure vtkVariant stream associated with << operator is set back to "dec".
- BUG: WIP: fix vtkPickingManager interaction with widgets
This section lists test failures on each platform for Release builds.
- http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1055401 (Release configuration, OpenGL backend, bypassing wrapping dependency issue)
- http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1053469 (Release configuration, OpenGL backend, Ubuntu 16.04)
- py_StandaloneEditorWidgetTest is vtkDebugLeaks; also occurs when built with VTK7.
- http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1053471 (Release configuration, OpenGL2 backend, Ubuntu 16.04)
Although VTK 7 changed the default setting of VTK_RENDERING_BACKEND to OpenGL2, Slicer still explicitly sets it to OpenGL. The rendering backend in Slicer is set using Slicer_VTK_RENDERING_BACKEND.
OpenGL2 backend known issues
- Need to move OS X nightly build to new factory machine to be able to set CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7. This will ensure that the required OpenGL version is found. See https://github.com/Slicer/Slicer/pull/595.
- 4252: Slicer crashes on start when started through Windows Remote Desktop
The transition plan was announced on the Slicer forum: https://discourse.slicer.org/t/transition-to-vtk-8-0/379.
This section lists categories of code changes necessary to build and run Slicer with VTK 8.0. Each category has a short description, a suggested upgrade path, and references to relevant commits (TBD once merged).
Use hierarchy files for VTK Python wrapping
In VTK8 it's necessary to generate hierarchy files for proper wrapping VTK classes in Python. Without the information provided by the hierarchy files, the Python wrapping tool lacks complete information about classes and types. In this case, the generated classes contain methods that shouldn't be wrapped and fail to compile, and include references to types such as vtkTypeBool. Once the hierarchy files are generated and provided to the Python wrapping tool, the generated classes compile and typedefs like vtkTypeBool are correctly resolved.
Once the VTK8 changes are merged, generating hierarchy files is handled by https://github.com/Slicer/Slicer/blob/master/CMake/vtkMacroKitPythonWrap.cmake.
Call InitializeObjectBase() in vtkObject New() methods
In VTK8 it's necessary for vtkObject New() methods to call InitializeObjectBase() on the new object for proper tracking with vtkDebugLeaks. The standard macros (vtkStandardNewMacro, vtkObjectFactoryNewMacro) handle this. For those classes that don't use the macros, add a call to InitializeObjectBase() immediately after constructing the object by new vtkXXX().
Additionally, vtkObjectFactory::CreateInstance() now doesn't register the class name with vtkDebugLeaks if the factory fails to create the object. Therefore, it's no longer necessary to unregister the class name with vtkDebugLeaks. Remove calls to vtkDebugLeaks::DestructClass(className) following vtkObjectFactory::CreateInstance().
To support both VTK8 and earlier versions of VTK, wrap these changes in preprocessor checks for whether VTK_HAS_INITIALIZE_OBJECT_BASE is defined.
Future work in Slicer related to VTK 8 could include:
- Remove BTX/ETX markers.
- Check for and resolve build warnings in Slicer VTK classes.
- Check that settings in External_VTKv8.cmake are all still necessary, specifically VTK_USE_PARALLEL, and anything related to Qt.