Closed Tobias-Fischer closed 2 years ago
There is a race condition somewhere. This fixes the problem, but is not a proper fix - it would be great if someone with more rviz / ogre knowledge could give me a hint how a proper fix could look like:
diff --git a/src/rviz/default_plugin/image_display.cpp b/src/rviz/default_plugin/image_display.cpp
index 3b5d50ce..90252890 100644
--- a/src/rviz/default_plugin/image_display.cpp
+++ b/src/rviz/default_plugin/image_display.cpp
@@ -117,9 +117,9 @@ void ImageDisplay::onInitialize()
}
render_panel_ = new RenderPanel();
+ render_panel_->getRenderWindow()->addListener(this);
render_panel_->getRenderWindow()->setAutoUpdated(false);
render_panel_->getRenderWindow()->setActive(false);
-
render_panel_->resize(640, 480);
render_panel_->initialize(img_scene_manager_, context_);
@@ -136,12 +136,29 @@ ImageDisplay::~ImageDisplay()
{
if (initialized())
{
+ render_panel_->getRenderWindow()->removeListener(this);
+
delete render_panel_;
delete screen_rect_;
removeAndDestroyChildNode(img_scene_node_->getParentSceneNode(), img_scene_node_);
}
}
+void ImageDisplay::preRenderTargetUpdate(const Ogre::RenderTargetEvent& /*evt*/)
+{
+ static int count = 0;
+ if(count++>1) {
+ img_scene_node_->setVisible(true);
+ } else{
+ img_scene_node_->setVisible(false);
+ }
+}
+
+void ImageDisplay::postRenderTargetUpdate(const Ogre::RenderTargetEvent& /*evt*/)
+{
+ img_scene_node_->setVisible(false);
+}
+
void ImageDisplay::onEnable()
{
ImageDisplayBase::subscribe();
diff --git a/src/rviz/default_plugin/image_display.h b/src/rviz/default_plugin/image_display.h
index 88492c19..17e4baa8 100644
--- a/src/rviz/default_plugin/image_display.h
+++ b/src/rviz/default_plugin/image_display.h
@@ -59,7 +59,7 @@ namespace rviz
* \class ImageDisplay
*
*/
-class ImageDisplay : public ImageDisplayBase
+class ImageDisplay : public ImageDisplayBase, public Ogre::RenderTargetListener
{
Q_OBJECT
public:
@@ -71,6 +71,10 @@ public:
void update(float wall_dt, float ros_dt) override;
void reset() override;
+ // Overrides from Ogre::RenderTargetListener
+ void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) override;
+ void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) override;
+
public Q_SLOTS:
virtual void updateNormalizeOptions();
If I make "count" a (non-static) class attribute, I can add multiple images; otherwise it crashes once adding a second image.
What I am confused about is the fact that the segfault occurs in a thread spawned by OpenGL. Maybe it's related to a broken OpenGL library? Did you try another version of it? @wolfv, what are your experiences?
My issues:
Environment OS Version: Mac Catalina ROS Distro: Noetic
Installation:
conda create -n ROS python==3.8
conda activate ROS
conda config --add channels conda-forge
conda config --add channels robostack
conda config --set channel_priority strict
conda install ros-noetic-desktop-full
conda install compilers cmake pkg-config make ninja catkin_tools
conda deactivate
conda activate ROS
rosdep init
rosdep update
rviz
RViz, Qt, OGRE, OpenGl version as printed by rviz:
[ INFO] [1655954814.977154000]: rviz version 1.14.6
[ INFO] [1655954814.977211000]: compiled against Qt version 5.12.9
[ INFO] [1655954814.977221000]: compiled against OGRE version 1.10.12 (Xalafu)
[ INFO] [1655954815.017990000]: Forcing OpenGl version 0.
[ INFO] [1655954816.113320000]: Stereo is NOT SUPPORTED
[ INFO] [1655954816.113386000]: OpenGL device: AMD Radeon Pro 560X OpenGL Engine
[ INFO] [1655954816.113403000]: OpenGl version: 2.1 (GLSL 1.2).
[ERROR] [1655954816.339471000]: PluginlibFactory: The plugin for class 'rviz/Orbit' failed to load. Error: Failed to load library /Users/d/opt/anaconda3/envs/ROS/lib/librviz_default_plugin.dylib. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = dlopen(/Users/d/opt/anaconda3/envs/ROS/lib/librviz_default_plugin.dylib, 9): Library not loaded: @rpath/liburdfdom_model.1.0.dylib
Referenced from: /Users/d/opt/anaconda3/envs/ROS/lib/liburdf.dylib
Reason: image not found)
Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame base_footprint at time 1655954817.627902 according to authority unknown_publisher
at line 278 in /Users/runner/miniforge3/conda-bld/ros-noetic-tf2_1615119151908/work/ros-noetic-tf2/src/work/src/buffer_core.cpp```
Please open an issue in https://github.com/RoboStack/ros-noetic @zzningxp
Closing here, as this is a RoboStack packaging issue.
Describe your issue here and explain how to reproduce it.
Your environment
Output of
rosrun rviz rviz -l
:Once I add an Image display:
Stacktrace:
Hi there, I built rviz using conda. It starts fine and seems to work fine, however if I try to add an Image it crashes with above error. It also happens with
export LIBGL_ALWAYS_SOFTWARE=1
.OSX additional output: