# Transition of nightly build from VTK 9.0.20201111 to 9.1.20220125

**URL:** <https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669>\
**Category:** Development\
**Created:** [January 28, 2022, 12:15am UTC](https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669 "2022-01-28T00:15:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 28, 2022, 12:15am UTC](https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669/1 "2022-01-28T00:15:12Z")

</div>

The pull request updating VTK is ready for review (see [PR-5978](https://github.com/Slicer/Slicer/pull/5978))

It fixes issue [#5956](https://github.com/Slicer/Slicer/issues/5956): `Update VTK9 to the latest master`

| | |
| --- | --- |
| 2022.01.27 | Experimental build for `PR-5978` have been started. See [dashboard](https://slicer.cdash.org/index.php?project=SlicerPreview&date=2022-01-27&filtercount=2&showfilters=1&filtercombine=and&field1=groupname&compare1=61&value1=Experimental&field2=site&compare2=63&value2=kitware) ✅ |
| 2022.01.28 | Upload packages in Google drive folder [3D Slicer Experimental Packages](https://drive.google.com/drive/u/0/folders/1Rt4SDZSIjqGmHEQI3wG4tpMhS63pH6l4) ✅ |

### Acknowledgments

This was made possible by the contributions and help of many 🙏

More specifically, I would like to acknowledge the specific help of @Sankhesh_Jhaveri , [dgobbi](https://gitlab.kitware.com/dgobbi), [ben.boeckel](https://gitlab.kitware.com/ben.boeckel), @lassoan, @Connor-Bowley, [will.schroeder](https://gitlab.kitware.com/will.schroeder) who helped track down & address issues, as well as @jadh4v who helped test & finalized the integration.

### Status of the transition

#### Slicer Application

After the pull requests list below are integrated, Slicer application will be expected to be successfully build and package on Linux, macOS and Windows.

| | description | merged? |
| --- | --- | --- |
| [PR-6059](https://github.com/Slicer/Slicer/pull/6059) | `COMP: Update SystemTools use anticipating update from VTK 9.0 to 9.1` | ✅ |
| [PR-5978](https://github.com/Slicer/Slicer/pull/5978) | `ENH: Update VTK9 from 9.0.20201111 to 9.1.20220125` | ⏳ |

#### Help needed to confirm there are no regressions

Check the following:

- Markups module
- Volume rendering
- Coincident topology
- …

Help create a check list ? Including reference to previous issue reports.

Issues to reevaluate once update is complete:

- [Multi-volume rendering much slower using VTK9 #5312](https://github.com/Slicer/Slicer/issues/5312)
- [VTK OpenGL2 Backend: Dashed line rendering broken with OpenGL2 rendering backend #4270](https://github.com/Slicer/Slicer/issues/4270)

#### Slicer Extension support

Remaining tasks will be the following:

- Support building VTK modules `Rendering/VR`, `Rendering/OpenVR` within the `SlicerVirtualReality` extension. See [PR KitwareMedical/SlicerVirtualReality#89](https://github.com/KitwareMedical/SlicerVirtualReality/pull/89)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 28, 2022, 6:48am UTC](https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669/2 "2022-01-28T06:48:41Z")

</div>

Experimental packages are available for download here: [3D Slicer Experimental Packages](https://drive.google.com/drive/u/0/folders/1Rt4SDZSIjqGmHEQI3wG4tpMhS63pH6l4)

### Additional failing tests building against VTK 9.1.20220125

| computron (macOS) |
| --- |
| [vtkMRMLThreeDReformatDisplayableManagerTest1](https://slicer.cdash.org/test/21153377) (segfault) |

| metroplex (Linux) |
| --- |
| [vtkMRMLThreeDReformatDisplayableManagerTest1](https://slicer.cdash.org/test/21154137) (segfault) |

| overload (Windows) |
| --- |
| [vtkMRMLThreeDReformatDisplayableManagerTest1](https://slicer.cdash.org/test/21156757) (invalid output) |
| [py\_nomainwindow\_SlicerOptionDisableSettingsTest](https://slicer.cdash.org/test/21156764) (AssertionError) |

### Output of `vtkMRMLThreeDReformatDisplayableManagerTest1`

#### overload (windows)

| Valid image | Test image |
| --- | --- |
| ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/e/ae2d3d8eca75059c941adad63cbe2363c9dc3d7e.png) | |

_Source: [https://slicer.cdash.org/test/21156757](https://slicer.cdash.org/test/21156757)_

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 4, 2022, 9:43pm UTC](https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669/3 "2022-02-04T21:43:27Z")

</div>

The regression has been fixed in Slicer/VTK in [e0d1851e2](https://github.com/Slicer/VTK/commit/e0d1851e22db9ae1d39096464964e7f1fe333436) and a merge request in being review in upstream VTK at [BUG: Rename vtkInteractionCallback class to avoid symbol clash (!8885) · Merge requests · VTK / VTK · GitLab](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8885)

### Impact of the regression on Slicer application

Enabling the “Lock Normal to Camera” associated with the reformat widget was leading to a crash.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/2/12881f3692079c245de3eff6c02ff6d2cd362719.png)

### Details

After hunting down the regression (performing a manual bisection of the history), I discovered that the following commits introduced the regression:

[kitware/vtk@7451dd2d1](https://github.com/Kitware/VTK/commit/7451dd2d1): `vtkDisplaySizedImplicitPlaneWidget/Representation: Implementation `

[kitware/vtk@cd42f785d](https://github.com/Kitware/VTK/commit/cd42f785d): `vtkCoordinateFrameWidget: Implementation`

At first, it didn’t make sense because we **do not instantiate these new widgets in Slicer**.

Looking at the issue more closely, I realized that the commit referenced above introduced the class `vtkDisplaySizedImplicitPlaneWidget` based of `vtkImplicitPlaneWidget2` that we effectively used in Slicer (see [here](https://github.com/Slicer/Slicer/blob/0094e9a35bd266cc8b0e677858dabce797c9928f/Libs/MRML/DisplayableManager/vtkMRMLThreeDReformatDisplayableManager.cxx#L240)).

It turns out that these classes all defined the class `vtkInteractionCallback` in their private implementation along with:

| | `vtkImplicitPlaneWidget2` | `vtkDisplaySizedImplicitPlaneWidget` | `vtkCoordinateFrameWidget` |
| --- | --- | --- | --- |
| static constructor | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkImplicitPlaneWidget2.cxx#L37-L51) | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkDisplaySizedImplicitPlaneWidget.cxx#L38-L52) | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkCoordinateFrameWidget.cxx#L35-L49) |
| `friend` statement in header | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkImplicitPlaneWidget2.h#L104) | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkDisplaySizedImplicitPlaneWidget.h#L108) | [link](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkCoordinateFrameWidget.h#L101) |

Since these classes were compiled within the same “program” (in that case the shared library `libvtkInteraction-9.1.(dll|dylib|so)`), the ODR ([One Definition Rule](https://en.cppreference.com/w/cpp/language/definition)) was violated and it now explains the following backtrace:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/2/c2c094af32f907446906a694aa6ea100452aa463.png)

_Backtrace obtained runing `ctest -R vtkMRMLThreeDReformatDisplayableManagerTest1 -V` and analyzing the core dump following the Slicer guide [C++ debugging on GNU/Linux systems: Analyze a segmentation fault](https://slicer.readthedocs.io/en/latest/developer_guide/debugging/linuxcpp.html#analyze-a-segmentation-fault)._

#### Symbol analysis

The following invocation of `nm` allows to confirm there the patch effectively ensure there are different instances of callback classes instead of a single `vtkInteractionCallback`:

Before integrating our fix:

```bash
$ nm lib/libvtkInteraction-9.1.so | c++filt | ack "typeinfo for vtk.+Callback$"
0000000000501f70 d typeinfo for vtkCWCallback
000000000050b938 d typeinfo for vtkPWCallback
000000000050b950 d typeinfo for vtkPW1Callback
000000000050b968 d typeinfo for vtkPW2Callback
00000000004fae80 d typeinfo for vtkAngleWidgetCallback
00000000004f7a28 d typeinfo for vtkImageViewerCallback
0000000000503d88 d typeinfo for vtkInteractionCallback
00000000004f7c10 d typeinfo for vtkImageViewer2Callback
0000000000500f70 d typeinfo for vtkCaptionAnchorCallback
0000000000505d58 d typeinfo for vtkDistanceWidgetCallback
00000000004fca38 d typeinfo for vtkBiDimensionalWidgetCallback
00000000004f7f28 d typeinfo for vtkResliceImageViewerScrollCallback

```

After integrating our fix:

```bash
$ nm lib/libvtkInteraction-9.1.so | c++filt | ack "typeinfo for vtk.+Callback$"
0000000000501df0 d typeinfo for vtkCWCallback
000000000050b948 d typeinfo for vtkPWCallback
000000000050b960 d typeinfo for vtkPW1Callback
000000000050b978 d typeinfo for vtkPW2Callback
00000000004fad00 d typeinfo for vtkAngleWidgetCallback
00000000004f78a8 d typeinfo for vtkImageViewerCallback
00000000004f7a90 d typeinfo for vtkImageViewer2Callback
0000000000500df0 d typeinfo for vtkCaptionAnchorCallback
0000000000505ca0 d typeinfo for vtkDistanceWidgetCallback
00000000004fc8b8 d typeinfo for vtkBiDimensionalWidgetCallback
00000000004f7da8 d typeinfo for vtkResliceImageViewerScrollCallback
000000000050aa80 d typeinfo for vtkImplicitPlaneWidget2InteractionCallback
0000000000503c08 d typeinfo for vtkCoordinateFrameWidgetInteractionCallback
0000000000504518 d typeinfo for vtkDisplaySizedImplicitPlaneInteractionCallback

```

#### Running test interactively disabling event replay

For future reference, it has also been useful to run the test interactively by disabling the replay of event, this was done by appending `-I --DisableReplay` to the command reported running the test with `-V`:

```bash
SLICER_SOURCE_DIR=/home/jcfr/Projects/Slicer
SLICER_BUILD_DIR=/home/jcfr/Projects/Slicer-rwdi

${SLICER_BUILD_DIR}/Slicer-build/Slicer --launch \
  ${SLICER_BUILD_DIR}/Slicer-build/bin/MRMLDisplayableManagerCxxTests \
  vtkMRMLThreeDReformatDisplayableManagerTest1\
    -D ${SLICER_SOURCE_DIR}/Libs/MRML/DisplayableManager/Testing/Cxx/../ \
    -T ${SLICER_BUILD_DIR}/Slicer-build/Testing/Temporary \
    -V Baseline/vtkMRMLThreeDReformatDisplayableManagerTest1.png \
    -I --DisableReplay

```

#### Further analysis of the VTK toolkit

Running the following commands allowed to discover other duplication and these ones will be discussed with the team as well:

- [#18456](https://gitlab.kitware.com/vtk/vtk/-/issues/18456) (Remove duplicated class vtkTextureArray)
- [#18455](https://gitlab.kitware.com/vtk/vtk/-/issues/18455) (Remove duplicated class vtkmOutputFilterPolicy)
- [#18457](https://gitlab.kitware.com/vtk/vtk/-/issues/18457) (Improve continuous integration to detect duplicated symbols)

```bash
$ cd VTK
$ ack -h --ignore-dir=Testing "^class.+vtk.+ \: " | ack "\:" | sort > /tmp/vtk-classes.txt
$ ack -h --ignore-dir=Testing "^class.+vtk.+ \: " | ack "\:" | sort | uniq > /tmp/vtk-uniq-classes.txt
$ diff /tmp/vtk-classes.txt /tmp/vtk-uniq-classes.txt

```

```diff
diff /tmp/vtk-classes.txt /tmp/vtk-uniq-classes.txt
1481,1482d1480
< class vtkInteractionCallback : public vtkCommand
< class vtkInteractionCallback : public vtkCommand
2047d2044
< class vtkmOutputFilterPolicy : public vtkm::filter::PolicyBase<vtkmOutputFilterPolicy>
2607d2603
< class vtkTextureArray : public std::map<int, vtkSmartPointer<vtkImageData>>

```

Occurrences of `vtkmOutputFilterPolicy`:

- [Accelerators/Vtkm/DataModel/vtkmFilterPolicy.h](https://github.com/Kitware/VTK/blob/164226edbe09ac420e1367c2c54c8e85a34a5939/Accelerators/Vtkm/Core/vtkmFilterPolicy.h)
- [Accelerators/Vtkm/DataModel/vtkmFilterPolicy.h](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Accelerators/Vtkm/DataModel/vtkmFilterPolicy.h)

Occurrences of `vtkTextureArray`:

- [Interaction/Widgets/vtkTexturedButtonRepresentation2D.cxx](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkTexturedButtonRepresentation2D.cxx#L36-L39)
- [Interaction/Widgets/vtkTexturedButtonRepresentation.cxx](https://github.com/Kitware/VTK/blob/67eaef6433e15644fd1b51d814b535dc66816464/Interaction/Widgets/vtkTexturedButtonRepresentation.cxx#L43-L46)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 4, 2022, 9:59pm UTC](https://discourse.slicer.org/t/transition-of-nightly-build-from-vtk-9-0-20201111-to-9-1-20220125/21669/4 "2022-02-04T21:59:12Z")

</div>

Impressive work Jc! Glad you were able to track this down 🙏
