dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.22k stars 259 forks source link

The bevy_rapier2d examples are panicking on macOS #230

Closed adrien-turiot-maxa closed 2 years ago

adrien-turiot-maxa commented 2 years ago

On my machine (macOS), all the examples for the bevy_rapier2d panics whereas the ones in bevy_rapier3d work fine.

For instance:

cargo run --example boxes2

The output is:

   Compiling bevy_rapier2d v0.16.0 (/Users/me/dev/bevy_rapier/bevy_rapier2d)
    Finished dev [unoptimized + debuginfo] target(s) in 0.57s
     Running `target/debug/examples/boxes2`
2022-08-03T18:13:38.117365Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon Pro 5300M", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }
2022-08-03T18:13:38.177400Z  INFO bevy_rapier2d::render::lines: Loaded 2d debug lines plugin.
2022-08-03T18:13:38.601808Z ERROR wgpu::backend::direct: Shader translation error for stage VERTEX | FRAGMENT | VERTEX_FRAGMENT: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth"    
2022-08-03T18:13:38.601853Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga    
2022-08-03T18:13:38.601919Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default    
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
    Internal error in VERTEX | FRAGMENT | VERTEX_FRAGMENT shader: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth"

', /Users/adrienturiot/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2391:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: segmentation fault  cargo run --example boxes2

It seems to be caused by the RapierDebugRenderPlugin as it's a shader issue and mostly because it works when removing the plugin from the example.

I also tested with --release but the error remains.

Hardware Overview:
  MacBook Pro - macOS Version 11.6 (20G165)
  Processor: 2.6 GHz 6-Core Intel Core i7
  Memory: 16 GB 2667 MHz DDR4
  Graphics: AMD Radeon Pro 5300M 4 GB, Intel UHD Graphics 630 1536 MB

I unfortunately do not know about the status of other platforms.

mw8 commented 2 years ago

Similar error in gfx-rs/naga#226

CleanCut commented 2 years ago

This is happening to me as well on an M1 Mac in my own projects whenever I add .add_plugin(RapierDebugRenderPlugin::default())

Note that I don't even have to be using any physics at all, just adding the debug renderer causes the crash.

Without backtrace ``` 2022-08-13T20:37:20.089844Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M1 Ultra", vendor: 0, device: 0, device_type: IntegratedGpu, backend: Metal } 2022-08-13T20:37:20.243357Z INFO bevy_rapier2d::render::lines: Loaded 2d debug lines plugin. 2022-08-13T20:37:20.381191Z ERROR wgpu::backend::direct: Shader translation error for stage VERTEX | FRAGMENT | VERTEX_FRAGMENT: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth" 2022-08-13T20:37:20.381224Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga 2022-08-13T20:37:20.381259Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default thread 'main' panicked at 'wgpu error: Validation Error Caused by: In Device::create_render_pipeline Internal error in VERTEX | FRAGMENT | VERTEX_FRAGMENT shader: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth" ', /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2391:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [1] 71329 segmentation fault cargo run assets/asteroid-large.png ```
With backtrace ``` 2022-08-13T20:42:31.055547Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M1 Ultra", vendor: 0, device: 0, device_type: IntegratedGpu, backend: Metal } 2022-08-13T20:42:31.208067Z INFO bevy_rapier2d::render::lines: Loaded 2d debug lines plugin. 2022-08-13T20:42:31.336202Z ERROR wgpu::backend::direct: Shader translation error for stage VERTEX | FRAGMENT | VERTEX_FRAGMENT: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth" 2022-08-13T20:42:31.336238Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga 2022-08-13T20:42:31.336279Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default thread 'main' panicked at 'wgpu error: Validation Error Caused by: In Device::create_render_pipeline Internal error in VERTEX | FRAGMENT | VERTEX_FRAGMENT shader: new_render_pipeline_state: "depthAttachmentPixelFormat is not valid and shader writes to depth" ', /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2391:5 stack backtrace: 0: rust_begin_unwind at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14 2: wgpu::backend::direct::default_error_handler at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2391:5 3: core::ops::function::Fn::call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:77:5 4: as core::ops::function::Fn>::call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/boxed.rs:1886:9 5: wgpu::backend::direct::ErrorSinkRaw::handle_error at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2377:17 6: wgpu::backend::direct::Context::handle_error at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:261:9 7: ::device_create_render_pipeline at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:1400:13 8: wgpu::Device::create_render_pipeline at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/lib.rs:2110:17 9: bevy_render::renderer::render_device::RenderDevice::create_render_pipeline at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.8.0/src/renderer/render_device.rs:99:36 10: bevy_render::render_resource::pipeline_cache::PipelineCache::process_render_pipeline at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.8.0/src/render_resource/pipeline_cache.rs:457:24 11: bevy_render::render_resource::pipeline_cache::PipelineCache::process_queue at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.8.0/src/render_resource/pipeline_cache.rs:529:21 12: bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.8.0/src/render_resource/pipeline_cache.rs:545:9 13: core::ops::function::FnMut::call_mut at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:164:5 14: core::ops::function::impls:: for &mut F>::call_mut at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:290:13 15: >::run::call_inner at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/system/function_system.rs:564:21 16: >::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/system/function_system.rs:567:17 17: as bevy_ecs::system::system::System>::run_unsafe at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/system/function_system.rs:403:19 18: bevy_ecs::schedule::executor_parallel::ParallelExecutor::prepare_systems::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/schedule/executor_parallel.rs:194:30 19: as core::future::future::Future>::poll at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/future/mod.rs:91:19 20: async_executor::Executor::spawn::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:144:19 21: as core::future::future::Future>::poll at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/future/mod.rs:91:19 22: async_task::raw::RawTask::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.3.0/src/raw.rs:511:20 23: async_task::runnable::Runnable::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.3.0/src/runnable.rs:309:18 24: async_executor::Executor::try_tick at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:181:17 25: bevy_tasks::task_pool::TaskPool::scope::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.8.0/src/task_pool.rs:201:21 26: std::thread::local::LocalKey::try_with at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/thread/local.rs:445:16 27: std::thread::local::LocalKey::with at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/thread/local.rs:421:9 28: bevy_tasks::task_pool::TaskPool::scope at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.8.0/src/task_pool.rs:148:9 29: ::run_systems at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/schedule/executor_parallel.rs:126:9 30: ::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.8.0/src/schedule/stage.rs:884:17 31: ::build::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.8.0/src/lib.rs:290:21 32: as core::ops::function::Fn>::call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/boxed.rs:1886:9 33: bevy_app::app::App::update at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.8.0/src/app.rs:121:13 34: bevy_winit::winit_runner_with::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.8.0/src/lib.rs:618:21 35: as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/app_state.rs:101:13 36: winit::platform_impl::platform::app_state::EventLoopHandler::with_callback at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/app_state.rs:79:13 37: as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/app_state.rs:100:9 38: winit::platform_impl::platform::app_state::Handler::handle_nonuser_event at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/app_state.rs:206:21 39: winit::platform_impl::platform::app_state::AppState::cleared at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/app_state.rs:387:9 40: winit::platform_impl::platform::observer::control_flow_end_handler::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/observer.rs:180:21 41: winit::platform_impl::platform::observer::control_flow_handler::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/observer.rs:142:57 42: std::panicking::try::do_call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:492:40 43: ___rust_try 44: std::panicking::try at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:456:19 45: std::panic::catch_unwind at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panic.rs:137:14 46: winit::platform_impl::platform::event_loop::stop_app_on_panic at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/event_loop.rs:229:11 47: winit::platform_impl::platform::observer::control_flow_handler at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/observer.rs:142:5 48: winit::platform_impl::platform::observer::control_flow_end_handler at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/observer.rs:175:9 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: <() as objc::message::MessageArguments>::invoke at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:128:17 60: objc::message::platform::send_unverified at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:27:9 61: objc::message::send_message at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:178:5 62: winit::platform_impl::platform::event_loop::EventLoop::run_return::{{closure}} at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/event_loop.rs:188:22 63: objc::rc::autorelease::autoreleasepool at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/rc/autorelease.rs:29:5 64: winit::platform_impl::platform::event_loop::EventLoop::run_return at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/event_loop.rs:178:9 65: winit::platform_impl::platform::event_loop::EventLoop::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/macos/event_loop.rs:157:9 66: winit::event_loop::EventLoop::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/event_loop.rs:154:9 67: bevy_winit::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.8.0/src/lib.rs:240:5 68: bevy_winit::winit_runner_with at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.8.0/src/lib.rs:663:9 69: bevy_winit::winit_runner at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.8.0/src/lib.rs:280:5 70: core::ops::function::Fn::call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:77:5 71: as core::ops::function::Fn>::call at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/boxed.rs:1886:9 72: bevy_app::app::App::run at /Users/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.8.0/src/app.rs:135:9 73: bevy_rapier2d_assets::main at ./src/main.rs:8:5 74: core::ops::function::FnOnce::call_once at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:248:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. [1] 71698 segmentation fault RUST_BACKTRACE=1 cargo run assets/asteroid-large.png ```
CleanCut commented 2 years ago

Corresponding upstream report: https://github.com/gfx-rs/wgpu/issues/4526

CleanCut commented 2 years ago

@sebcrozet If there is anything I can do to help debug this, please let me know. I have access to several different Macs, both M1 and Intel.

adrien-turiot-maxa commented 2 years ago

Just confirming that it works now thanks to the fix from @sebcrozet ! Thanks a lot πŸ˜ƒ

CleanCut commented 2 years ago

Works for me on M1 as well πŸ‘πŸ»

CleanCut commented 2 years ago

If we could get this in a patch release, that would be fantastic.

adrien-turiot-maxa commented 2 years ago

@CleanCut In the meantime, you can set your Cargo.toml to point to a fixed version of the master branch:

bevy_rapier2d = { git = "https://github.com/dimforge/bevy_rapier", rev = "9386e32" }
CleanCut commented 2 years ago

πŸ‘πŸ» Absolutely, I'm tracking the master branch at the moment and it works. However, I won't be able to cut a release if I'm depending on a version outside of crates.io. I'm probably not going to be ready to cut a release for several days, so it's not a rush--it would just be nice if it happened sometime this week.