Skip to content

Gazebo Harmonic crashed with ROS 2 Jazzy on macOS #2877

@atinfinity

Description

@atinfinity

Environment

  • OS Version: macOS Sonoma 14.4
  • Source or binary build?
  • If this is a GUI or sensor rendering bug, describe your GPU and rendering system. Otherwise delete this section.
    • Rendering plugin: ogre2
      • Sensor rendering error.
      • GUI rendering error.
    • EGL headless mode:
      • Running in EGL headless mode
    • Generally, mention all circumstances that might affect rendering capabilities:
      • running on a dual GPU machine (integrated GPU + discrete GPU)
      • running on a multi-GPU machine (it has multiple discrete GPUs)
      • running on real hardware
      • running in virtual machine
      • running in Docker/Singularity
      • running remotely (e.g. via SSH)
      • running in a cloud
      • using VirtualGL, XVFB, Xdummy, XVNC or other indirect rendering utilities
      • GPU is concurrently used for other tasks
        • desktop acceleration
        • video decoding (i.e. a playing Youtube video)
        • video encoding
        • CUDA/ROCm computations (Tensorflow, Torch, Caffe running)
        • multiple simulators running at the same time
      • other...
    • Rendering system info:
      • On Linux, provide the outputs of the following commands:
        LANG=C lspci -nn | grep VGA  # might require installing pciutils
        echo "$DISPLAY"
        LANG=C glxinfo -B | grep -i '\(direct rendering\|opengl\|profile\)'  # might require installing mesa-utils package
        ps aux | grep Xorg
        sudo env LANG=C X -version  # if you don't have root access, try to tell the version of Xorg e.g. via package manager
      • On Windows, run dxdiag and report the GPU-related information.
      • On Mac OS, open a terminal and type system_profiler SPDisplaysDataType. Copy the output here.
    • Please, attach the ogre.log or ogre2.log file from ~/.gz/rendering
# paste log here

Description

  • Expected behavior: User can spawn robot with sensor
  • Actual behavior: Gazebo Harmonic crashed

I reported this problem to pixi in RoboStack/ros-jazzy#52. Please read this issue.

I suspect the problem may be that on macOS only the main thread is supported for creating Metal context, and while using rendering-based sensors, gz-sim/gz-sensors (or perhaps the ros_gz_sim::GzServer) creates Metal context not in the main thread, and this triggers the failure that you are seeing. As this problem is not directly related to the robostack packaging, it could make sense to open an issue on this in https://github.com/gazebosim/ros_gz/ .

Steps to reproduce

I install ROS 2 Jazzy and Gazebo Harmonic on pixi.

curl -fsSL https://pixi.sh/install.sh | sh
pixi init my_ros2_project -c robostack-jazzy -c conda-forge
cd my_ros2_project
pixi add ros-jazzy-desktop-full ros-jazzy-rmw-cyclonedds-cpp colcon-common-extensions setuptools ros-jazzy-joint-state-publisher ros-jazzy-xacro ros-jazzy-ros-gz-bridge ros-jazzy-ros-gz-sim ros-jazzy-ros-gz-image ros-jazzy-ros-gz-interfaces ros-jazzy-slam-toolbox ros-jazzy-nav2-bringup ros-jazzy-navigation2
touch activate.sh

I add the following description to activate.sh.

export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

I add the following description to pixi.toml.

[activation]
scripts = ["activate.sh"]
mkdir src
cd src
git clone https://github.com/atinfinity/megarover_samples_ros2.git -b jazzy
cd ..
pixi run colcon build --symlink-install

I add "install/setup.bash" to pixi.toml.

[activation]
scripts = ["activate.sh", "install/setup.bash"]
pixi run ros2 launch megarover_samples_ros2 vmegarover_with_sample_world.launch.py gui:=false

Output

As a result, the following error message is displayed.

[create-2] [INFO] [1745153221.979601000] [ros_gz_sim]: Waiting messages on topic [robot_description].
[create-2] [INFO] [1745153221.981409000] [ros_gz_sim]: Entity creation successfull.
[create-2] [ERROR] [1745153222.194662000] [rclcpp]: unhandled exception in ~Context(): mutex lock failed: Invalid argument
[INFO] [create-2]: process has finished cleanly [pid 13638]
[gazebo-1] Warning [Utils.cc:132] [/sdf/model[@name="vmegarover"]/link[@name="base_footprint"]/sensor[@name="front_camera_sensor"]/camera/depth_camera/image:<urdf-string>:L0]: XML Element[image], child of element[depth_camera], not defined in SDF. Copying[image] as children of [depth_camera].
[gazebo-1] Warning [Utils.cc:132] [/sdf/model[@name="vmegarover"]/link[@name="base_footprint"]/sensor[@name="front_lrf_sensor"]/gz_frame_id:<urdf-string>:L0]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
[gazebo-1] libc++abi: terminating due to uncaught exception of type Ogre::RenderingAPIException: OGRE EXCEPTION(3:RenderingAPIException): Failed to created pipeline state for rendering, error output of type float4 is not compatible with a MTLPixelFormatRGBA32Uint color attachment. in MetalRenderSystem::_hlmsPipelineStateObjectCreated at /Users/runner/miniforge3/conda-bld/ogre-next_1724198796583/work/RenderSystems/Metal/src/OgreMetalRenderSystem.mm (line 1733)
[gazebo-1] Stack trace (most recent call last) in thread 6144258048:
[gazebo-1] #27   Object "libsystem_pthread.dylib", at 0x182c36f93, in _pthread_start + 135
[gazebo-1] #26   Object "libgz-sim8-sensors-system.8.6.0.dyl", at 0x12cf716df, in void* std::__1::__thread_proxy[abi:ne180100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (gz::sim::v8::systems::SensorsPrivate::*)(), gz::sim::v8::systems::SensorsPrivate*>>(void*) + 87
[gazebo-1] #25   Object "libgz-sim8-sensors-system.8.6.0.dyl", at 0x12cf582f7, in gz::sim::v8::systems::SensorsPrivate::RenderThread() + 295
[gazebo-1] #24   Object "libgz-sim8-sensors-system.8.6.0.dyl", at 0x12cf5766f, in gz::sim::v8::systems::SensorsPrivate::RunOnce() + 891
[gazebo-1] #23   Object "libgz-sensors8.8.2.0.dylib", at 0x12e628f4b, in gz::sensors::v8::Manager::RunOnce(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>> const&, bool) + 71
[gazebo-1] #22   Object "libgz-sensors8.8.2.0.dylib", at 0x12e62cdaf, in gz::sensors::v8::Sensor::Update(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>> const&, bool) + 187
[gazebo-1] #21   Object "libgz-sensors8-rgbd_camera.8.2.0.dy", at 0x12cf0b0ef, in gz::sensors::v8::RgbdCameraSensor::Update(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>> const&) + 931
[gazebo-1] #20   Object "libgz-sensors8-rendering.8.2.0.dyli", at 0x12e2b94db, in gz::sensors::v8::RenderingSensor::Render() + 267
[gazebo-1] #19   Object "libgz-rendering8-ogre2.8.2.0.dylib", at 0x1641595a7, in gz::rendering::v8::Ogre2DepthCamera::Render() + 123
[gazebo-1] #18   Object "RenderSystem_Metal.2.3.3.dylib", at 0x16469611b, in Ogre::MetalRenderSystem::compositorWorkspaceUpdate(Ogre::CompositorWorkspace*) + 43
[gazebo-1] #17   Object "libOgreNextMain.2.3.3.dylib", at 0x164c6a60f, in Ogre::CompositorWorkspace::_update(bool) + 775
[gazebo-1] #16   Object "libOgreNextMain.2.3.3.dylib", at 0x164c5e357, in Ogre::CompositorNode::_update(Ogre::Camera const*, Ogre::SceneManager*) + 151
[gazebo-1] #15   Object "libOgreNextMain.2.3.3.dylib", at 0x164c7bd23, in Ogre::CompositorPassQuad::execute(Ogre::Camera const*) + 1695
[gazebo-1] #14   Object "libOgreNextMain.2.3.3.dylib", at 0x164b22a03, in Ogre::RenderQueue::renderSingleObject(Ogre::Renderable*, Ogre::MovableObject const*, Ogre::RenderSystem*, bool, bool) + 347
[gazebo-1] #13   Object "libOgreNextMain.2.3.3.dylib", at 0x164a483cf, in Ogre::HlmsLowLevel::createShaderCacheEntry(unsigned int, Ogre::HlmsCache const&, unsigned int, Ogre::QueuedRenderable const&) + 823
[gazebo-1] #12   Object "RenderSystem_Metal.2.3.3.dylib", at 0x164693a0b, in Ogre::MetalRenderSystem::_hlmsPipelineStateObjectCreated(Ogre::HlmsPso*) + 3163
[gazebo-1] #11   Object "RenderSystem_Metal.2.3.3.dylib", at 0x16467e733, in Ogre::ExceptionFactory::throwException(Ogre::Exception::ExceptionCodes, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const*, long) + 315
[gazebo-1] #10   Object "libc++abi.dylib", at 0x182bf028b, in __cxa_throw + 307
[gazebo-1] #9    Object "libc++abi.dylib", at 0x182bf0347, in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 87
[gazebo-1] #8    Object "libc++abi.dylib", at 0x182bed0f3, in std::__terminate(void (*)()) + 15
[gazebo-1] #7    Object "libobjc.A.dylib", at 0x18287c1df, in _objc_terminate() + 159
[gazebo-1] #6    Object "libc++abi.dylib", at 0x182bddfcb, in demangling_terminate_handler() + 319
[gazebo-1] #5    Object "libc++abi.dylib", at 0x182bedd2f, in abort_message + 131
[gazebo-1] #4    Object "libsystem_c.dylib", at 0x182b43a1f, in abort + 179
[gazebo-1] #3    Object "libsystem_pthread.dylib", at 0x182c36c1f, in pthread_kill + 287
[gazebo-1] #2    Object "libsystem_platform.dylib", at 0x182c67583, in _sigtramp + 55
[gazebo-1] #1    Object "libgz-tools2-backward.2.0.1.dylib", at 0x1030b1a5b, in backward::SignalHandling::sig_handler(int, __siginfo*, void*) + 19
[gazebo-1] #0    Object "libgz-tools2-backward.2.0.1.dylib", at 0x1030b1ac3, in backward::SignalHandling::handleSignal(int, __siginfo*, void*) + 75
[ERROR] [gazebo-1]: process has died [pid 13637, exit code -6, cmd 'ruby $(which gz) sim /Users/dandelion/my_ros2_project/install/megarover_samples_ros2/share/megarover_samples_ros2/worlds/gz/vmegarover_sample.sdf -v 1 -r --headless-rendering -s --force-version 8'].

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions