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 gazebo_scene_viewer for macOS and ensure exits cleanly #259

Merged

Conversation

srmainwaring
Copy link
Contributor

🦟 Bug fix

Summary

This is similar to PR #256. The example gazebo_scene_viewer does not display a window on macOS. The example will build and run, the console will display the usage, however the GLUT window does not open. There was also a non-macOS specific issue where the window would segfault on exit when triggered by an ESC keypress in the window.

Configuration

  • OS: macOS Catalina 10.15.7
  • Machine: Mac Pro (2019)
  • Config: ignition-rendering4

Detail

The macOS changes involve setting up and managing the correct OpenGL context. The segfault issue was caused by two things: the first was a potential nullptr dereference in the subscriber callbacks, this is now checked and in any case should not be hit provided the transport is cleaned up before the scene mangers go out of scope. The second issue was the gazebo transport node not being stopped and finalised before exit(0) was executed. This would cause either a segfault or a hang as the application window would go out of scope while a cleanup thread was running resulting in a pthread mutex lock exception.

  1. Add OpenGL context settings for macOS to the CameraWindow.
  2. Move glutInit to main in GazeboDemo and GazeboWorldDemo
  3. Update CMakeLists.txt to exclude libstdc++fs for macOS and add find_package for bullet.
  4. Expose command line option to set either ogre or ogre2 as an engine.
  5. Ensure gazebo::transport is stopped and cleaned up prior to exit.
  6. Use std::unique_ptr to manage current and new scene manager lifetimes.
  7. Disconnect pub/sub from transport on SceneManager Fini.
  8. Add checks in pub/sub callbacks to ensure scene manager pointers are valid.

Tests

Both examples are working correctly in macOS for ogre (ogre2 not tested). The image below is for gazebo_scene_viewer2_demo

gazebo_scene_viewer2_demo_1

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

@github-actions github-actions bot added the 🔮 dome Ignition Dome label Feb 25, 2021
examples/gazebo_scene_viewer/SceneManager.cc Outdated Show resolved Hide resolved
examples/gazebo_scene_viewer/SceneManager.cc Outdated Show resolved Hide resolved
examples/gazebo_scene_viewer/SceneManager.cc Outdated Show resolved Hide resolved
examples/gazebo_scene_viewer/GazeboWorldDemo.cc Outdated Show resolved Hide resolved
examples/gazebo_scene_viewer/GazeboDemo.cc Outdated Show resolved Hide resolved
examples/gazebo_scene_viewer/CMakeLists.txt Outdated Show resolved Hide resolved
1. Add OpenGL context settings for macOS to the CameraWindow.
2. Move glutInit to main in GazeboDemo and GazeboWorldDemo
3. Update CMakeLists.txt to exclude libstdc++fs for macOS and add find_package for bullet.
4. Expose command line option to set either ogre or ogre2 as an engine.
5. Ensure gazebo::transport is stopped and cleaned up prior to exit.
6. Use std::unique_ptr to manage current and new scene manager lifetimes.
7. Disconnect pub/sub from transport on SceneManager Fini.
8. Add checks in pub/sub callbacks to ensure scene manager pointers are valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1. Place return in braces following if
2. Use camel case for variables.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
…_viewer

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@srmainwaring srmainwaring force-pushed the feature/ir4-gazebo_scene_viewer branch from b33c472 to 971f86a Compare March 5, 2021 11:22
@iche033 iche033 merged commit 886d0d9 into gazebosim:ign-rendering4 Mar 8, 2021
@srmainwaring srmainwaring deleted the feature/ir4-gazebo_scene_viewer branch January 29, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants