Skip to content

Fix running server and GUI together on macOS#3405

Merged
azeey merged 2 commits intogazebosim:mainfrom
azeey:fix_joint_server_gui_macos
Mar 20, 2026
Merged

Fix running server and GUI together on macOS#3405
azeey merged 2 commits intogazebosim:mainfrom
azeey:fix_joint_server_gui_macos

Conversation

@azeey
Copy link
Copy Markdown
Contributor

@azeey azeey commented Mar 18, 2026

🦟 Bug fix

Summary

On macOS Metal API is requires initialization from the main thread. As a result, we currently cannot run worlds with rendering sensors on macOS without running the server and GUI seprately, i.e, gz sim camera_sensors.sdf crashes with the following stacktrace

#6    Object "libsystem_pthread.dylib", at 0x195c9bbc7, in _pthread_start + 135
#5    Object "libgz-sim-sensors-system.11.0.0~pre", at 0x120c3f56b, in void* std::__1::__thread_proxy[abi:ne190102]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (gz::sim::v11::systems::SensorsPrivate::*)(), gz::sim::v11::systems::SensorsPrivate*>>(void*) + 71
#4    Object "libgz-sim-sensors-system.11.0.0~pre", at 0x120c28b9f, in gz::sim::v11::systems::SensorsPrivate::RenderThread() + 175
#3    Object "libgz-sim-sensors-system.11.0.0~pre", at 0x120c27a57, in gz::sim::v11::systems::SensorsPrivate::WaitForInit() + 691
#2    Object "libsystem_platform.dylib", at 0x195cd56a3, in _sigtramp + 55
#1    Object "gz-sim-main", at 0x104fd002f, in backward::SignalHandling::sig_handler(int, __siginfo*, void*) + 19
#0    Object "gz-sim-main", at 0x104fd0087, in backward::SignalHandling::handleSignal(int, __siginfo*, void*) + 59
[1]    21922 segmentation fault  gz sim -v4 camera_sensor.sdf

This PR fixes this be ensuring the server runs on the main thread (using the blocking=true flag on Server::Run) and creating a separate thread to monitor the GUI process.

joint_server_gui.mp4

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-By: Gemini 2.5 Pro

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

The server has to run as the main thread in order for Metal APIs to
initialize properly

Generated-By: Gemini 2.5 Pro

Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
Copy link
Copy Markdown
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

Nice! Tested it on my mac and it works. We seem to have broken Bazel for mac os in gz-common?

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Mar 19, 2026
@iche033
Copy link
Copy Markdown
Contributor

iche033 commented Mar 19, 2026

Nice! Tested it on my mac and it works. We seem to have broken Bazel for mac os in gz-common?

gazebosim/gz-common#795 should fix the bazel builds

@azeey azeey merged commit 7dd25f6 into gazebosim:main Mar 20, 2026
19 of 21 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Core development Mar 20, 2026
@azeey
Copy link
Copy Markdown
Contributor Author

azeey commented Mar 25, 2026

@Mergifyio backport gz-sim10

@azeey azeey deleted the fix_joint_server_gui_macos branch March 25, 2026 06:33
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

backport gz-sim10

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Mar 25, 2026
On macOS the Metal API requires initialization from the main thread. As a result, we currently cannot run worlds with rendering sensors on macOS without running the server and GUI seprately. This PR fixes this be ensuring the server runs on the main thread (using the blocking=true flag on Server::Run) and creating a separate thread to monitor the GUI process.

Generated-By: Gemini 2.5 Pro

Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
Co-authored-by: Arjo Chakravarty <arjoc@intrinsic.ai>
(cherry picked from commit 7dd25f6)
azeey added a commit that referenced this pull request Mar 25, 2026
On macOS the Metal API requires initialization from the main thread. As a result, we currently cannot run worlds with rendering sensors on macOS without running the server and GUI seprately. This PR fixes this be ensuring the server runs on the main thread (using the blocking=true flag on Server::Run) and creating a separate thread to monitor the GUI process.

Generated-By: Gemini 2.5 Pro

Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
Co-authored-by: Arjo Chakravarty <arjoc@intrinsic.ai>
(cherry picked from commit 7dd25f6)
jasmeet0915 pushed a commit to jasmeet0915/gz-sim that referenced this pull request Mar 28, 2026
On macOS the Metal API requires initialization from the main thread. As a result, we currently cannot run worlds with rendering sensors on macOS without running the server and GUI seprately. This PR fixes this be ensuring the server runs on the main thread (using the blocking=true flag on Server::Run) and creating a separate thread to monitor the GUI process.

Generated-By: Gemini 2.5 Pro

Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
Co-authored-by: Arjo Chakravarty <arjoc@intrinsic.ai>
(cherry picked from commit 7dd25f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants