Skip to content
Browse files

BUG: Restore functioning of CLI loadable module by fixing ITKv4 regre…


Problem is summarize by the discussion posted on the ITK developer list
reported below.

// --------------
Question from Jean-Christophe Fillion-Robin:

Following commit 4c47e7d [1] of February 19th and commit defb9c1 [2] of
March 1st, due to static initialization, the initialization of
ObjectFactory  now happens when ITK shared library are loaded [3][4].

This caused a regression in Slicer where the ObjectFactory were expected
to be loaded while attempting to load an image for the first time.

In Slicer case, the environment variable ITK_AUTOLOAD_PATH was set during
the initialization of the qSlicerCoreApplication, which is now too late.

By commenting line where a new ImageRegionSplitterSlowDimension is
instantiated [5][6] and updating the method "GetImageRegionSplitter /
GetGlobalDefaultSplitter" to return 0 [7][8], the initialization can
happen on demand instead of when ITK libraries are loaded.

An easy solution for us would be to ensure the "ITK_AUTOLOAD_PATH"
environment variable is set in the application launcher for Windows
and Linux application and set in Info.plist file associated with
the application bundle on MacOSX [9]

To provide more details, within Slicer we set the CMake variable
"include(${ITK_USE_FILE}) so that IOFactory are loaded only by
calling the method "itkFactoryRegistration" associated with a
shared library we named ITKFactoryRegistration. This approach allowed
us to disable the automatic registration of factory in selected part of
 the code. More details here [10]

It seems the new ITK commits 4c47e7d and defb9c1 prevent from completely
leveraging the use of ITK_NO_IO_FACTORY_REGISTER_MANAGER variable, the
code should probably be updated to consider this.

[1] Kitware/ITK@4c47e7d
[2] Kitware/ITK@defb9c1
[10] 03b8961
// --------------

// --------------
Answer from Brad Lowekamp:

This is quite an interesting side-effect of the changes I introduced.

I am glad that you were able to figure this out. For a variety of
reasons, it's likely a very bad thing for all that to occur during
static initialization in ITK. So it certainly needs to be fixed.

I agree that lazy initialization is the way to go. Unfortunately it
needs to be thread safe so its a little more completed.

ITKv4 performs the factory initialization when the user creates the
first ITK object.  And that changed with this patch, and need to be


Inside ITK, we can not use statically initialized ITK object.
// --------------


ITK discussion:

ITK patch:;a=commit;h=1679816baef6b95356d9afdd9bd4a481ca08556c

Fixes #3008
Fixes #3042

git-svn-id: 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
1 parent ed0437a commit ca86fc03dfad9ccf5ee068ab0fd50d4a70a312aa @jcfr jcfr committed Apr 3, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 SuperBuild/External_ITKv4.cmake
2 SuperBuild/External_ITKv4.cmake
@@ -75,7 +75,7 @@ if(NOT DEFINED ITK_DIR)
set(ITKv4_REPOSITORY ${git_protocol}://
- set(ITKv4_GIT_TAG c24dcc0b1db66dc6f2c749a40fd490381f2a96a4) #2013-04-03
+ set(ITKv4_GIT_TAG 1866ef42887df677a6197ad11ed0ef6e9b239567) #2013-04-03

0 comments on commit ca86fc0

Please sign in to comment.
Something went wrong with that request. Please try again.