fix(viz): Closing SightCalibrator while Calibration activity is open causes assertion failure
Description
When one closes SightCalibrator while the Calibration tab is open, it causes an assertion failure sightrun.bin: ./OgreMain/src/OgreLogManager.cpp:40: static Ogre::LogManager& Ogre::LogManager::getSingleton(): Assertion `msSingleton' failed.
. Note that there is no assertion failure if one closes this tab first.
Steps to reproduce
- Launch SightCalibrator
- Click on Calibration activity
- Close SightCalibrator window
- An assertion failure appears:
sightrun.bin: ./OgreMain/src/OgreLogManager.cpp:40: static Ogre::LogManager& Ogre::LogManager::getSingleton(): Assertion `msSingleton' failed.
- An assertion failure appears:
I only tested on Ubuntu 21.10.
Explanation
The new init sequence with only one initialisation stage may break the shutdown of applications with 3D activities.
Indeed, SightCalibrator itself does not depend on sight::module::viz::scene3d
. Thus at the start, it loads appXml first and registers the stopper of this module. When the calibration activity is loaded, sight::module::viz::scene3d
is loaded and its plugin is launched. It creates the Ogre log manager. Last it registers the stopper of sight::module::viz::scene3d
, but thus after appXml
without taking into account the priority.
So when exiting the application, sight::module::viz::scene3d
is stopped first, destroying the Ogre log manager. Then appXml is stopped, and so Ogre objects trying to log information when destroying fail to get it, causing the crash.
Resolution
Functional specifications
No change.
Technical specifications
The best option would be to take into account the PRIORITY
argument when stopping modules whatever the order in which they are loaded. So the stopper must be inserted in the list respecting this order.
This is not that straightforward because this priority doesn't exist in the C++ code. It is only present in CMake. We have three options:
pass this priority as a GCC definepass this priority in theplugin.xml
with aconfigure_file
CMake command.- move the priority from the
CMakeLists.txt
to theplugin.xml
. This implies we need to parse the plugin.xml to generate the profile.xml
We chose option 3. It would be also nice to move the START option and rename it into autostart.
Test plan
- Run applications with activities, they should exit properly.