ros-visualization / rviz

ROS 3D Robot Visualizer
BSD 3-Clause "New" or "Revised" License
831 stars 463 forks source link

Librviz crashes when initialized after previous instance has been destroyed #816

Open mdedonato opened 10 years ago

mdedonato commented 10 years ago

When using lib rviz and following the hydro tutorial, I get the following error:

[ WARN] [1411074212.640251017]: OGRE EXCEPTION(3:RenderingAPIException): Zero sized texture surface on texture SelectionTexture2 face 0 mipmap 0. Probably, the GL driver refused to create the texture. in GLTexture::_createSurfaceList at /build/buildd/ogre-1.7.4/RenderSystems/GL/src/OgreGLTexture.cpp (line 406)
std::exception was caught

This error only occurs when trying to create an instance after another instance has been created and destroyed.

You can take a look at my test code here:

https://github.com/mdedonato/librviz_test

It is a modified version of the tutorial code that recreates the issue.

To recreate the issue, first compile and run the program. Then click the on button. This should bring up an rviz instance. Then click the off button. The instance is now destroyed. Now when you click the on button again the error appears.

I believe that something is being destroyed incorrectly in the librviz code.

wjwwood commented 10 years ago

Maybe related to: https://github.com/ros-visualization/rqt/issues/96

mdedonato commented 10 years ago

Note that the crash only happens after running the Visualizationmanager initialize function

mdedonato commented 9 years ago

Has there been any progress on this? The issue does not seem to be related to the rqt bug.

wjwwood commented 9 years ago

@mdedonato No, I haven't had any time to work on this and I don't know exactly when I will have time. If you find anything else out please let us know.

Eberty commented 5 years ago

I spent a few days studying this bug. It happens that when deleting the last instance of VisualizationManager (In your case you have only one) the program loses the reference to the SceneManager and therefore crashes when calling the method VisualizationManager::initialize(); (NOTE: if you have several widgets, you can delete several widgets and recreate them without crashes, as long as one of them still exists).

Note that this is something not handled by Rviz program (since it has a main 3d window that can never be destroyed/closed).

A workarround is would put the code:

    static rviz::VisualizationManager* manager = new rviz::VisualizationManager(new rviz::RenderPanel());
    manager->initialize();
    manager->startUpdate();

in your main (you do not need to create a widget for this VisualizationManager). This workaround make sure that an Librviz Visualization Manager is always disponible (not destroyed).

Now you can use the on/off button to destroy yor widget.