Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OSX crash (fix #1531) #1532

Open
wants to merge 5 commits into
base: noetic-devel
Choose a base branch
from

Conversation

Tobias-Fischer
Copy link
Contributor

@Tobias-Fischer Tobias-Fischer commented Jul 27, 2020

Description

I know that the fixes currently are quite messy, but the best I can do with my very limited knowledge of rviz. Someone else might know how to properly fix things.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed analysis in #1531 and your attempt to fix the issue. Did you gain more insight into the root cause of the race condition? I agree with the cherry-pick of ros2/rviz#319, but I'm not yet convinced about the remaining changes.

delete render_panel_;
delete screen_rect_;
removeAndDestroyChildNode(img_scene_node_->getParentSceneNode(), img_scene_node_);
}
}

void ImageDisplay::preRenderTargetUpdate(const Ogre::RenderTargetEvent& /*evt*/)
{
if (has_run_once_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be at the core of this PR: You need to ignore the first rendering of the scene.
But what is the root of this race condition? Why does it help to drop the first rendering (only)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I didn't get to the root of the race condition. I don't understand the rviz code and the OSX specifics well enough I'm afraid.

Comment on lines +137 to +141
camera_scene_manager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, ss.str());
}

bg_scene_node_ = camera_scene_manager_->getRootSceneNode()->createChildSceneNode();
fg_scene_node_ = camera_scene_manager_->getRootSceneNode()->createChildSceneNode();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you create a separate SceneManager? Isn't this rendering an empty scene - only comprising the camera image, but not the default rviz scene anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I just use the standard SceneManager, rviz crashes when adding a second camera display. I took the idea of having a separate SceneManager from the image display code where this exact code is being used. Again though I'm not sure about the internals; I agree that it should work just using the default SceneManager but I don't understand the code well enough to make this work. On a general note, quite a bit of code is duplicated between the image and camera displays and could probably be abstracted away.

@Tobias-Fischer
Copy link
Contributor Author

Ping @rhaschke - I'd love to see this PR being merged. As previously mentioned I unfortunately don't have in depth knowledge of rviz and can't really explain why the fixes in this PR are required, but in my opinion a workaround a bug is better than having a bug.
Is there anything I can do to push the PR forward?

@rhaschke
Copy link
Contributor

rhaschke commented Dec 6, 2020

As this bug is not reproducible on Linux, I'm hesitating to integrate such a workaround without understanding its root cause.
If you can contribute to this deeper understanding, I will reconsider this PR.

  • Where and why rviz crashes exactly? Provide a backtrace at least. Better explain it.
  • Explain, how your fix addresses the recognized issue (in a minimally invasive fashion)?

@Tobias-Fischer Tobias-Fischer changed the title Fix OSX crash Fix OSX crash (fix #1531) Dec 6, 2020
@Tobias-Fischer
Copy link
Contributor Author

Many thanks for getting back to me so quickly @rhaschke!

There are multiple fixes included in this pull request:

  • Image display bug
    • Open rviz. Then add an Image display (does not need to listen to a topic; an "empty" one is sufficient). Rviz will crash as reported in RViz crash when adding Image Display on OSX #1531.
    • The relevant stacktrace is listed in RViz crash when adding Image Display on OSX #1531.
    • This bug is fixed by 4c0a605
    • Simply applying the fix from Fix bugs causing RViz to crash on macOS ros2/rviz#319 is not sufficient to resolve this bug. Using further investigation with a debugger, I found that the crash occurs when executing img_scene_node_->setVisible(true);. Commenting this line out fixed the issue, but prevented displaying anything. As you have seen earlier, there is some race condition (unfortunately I do not know how to find out where); if executing img_scene_node_->setVisible(true); the second time around all is good. This is what my proposed fix does.
  • Camera display bug
    • Open rviz. Add a Camera display. All is fine. Now, add a second Camera display. Rviz will crash.
    • This bug is fixed by 3b67770
    • The change is copied from Image display, where a new scene manager is created for each display. So this fix is fairly straightforward, I simply checked how image display (the unmodified version by the way) does things and copied it over to camera display.

I hope this helps. Maybe @botteroa-si has more insights (author of ros2/rviz#319)?

@rhaschke
Copy link
Contributor

rhaschke commented Dec 6, 2020

Thanks for this summary. This will hopefully help understanding the problem. However, I will not have time to look into this in the next few weeks. I'm sorry.

@Tobias-Fischer
Copy link
Contributor Author

For all OSX users who observe this crash: There is now a patched version available in https://github.com/RoboStack/ros-noetic (see https://medium.com/robostack/cross-platform-conda-packages-for-ros-fa1974fd1de3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants