Fix gazebo_scene_viewer for macOS and ensure exits cleanly #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🦟 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
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.
Tests
Both examples are working correctly in macOS for ogre (ogre2 not tested). The image below is for
gazebo_scene_viewer2_demo
Checklist
codecheck
passed (See contributing)