komadori / bevy_mod_outline

Apache License 2.0
123 stars 10 forks source link

Invalid DepthMode value panic #17

Closed barsoosayque closed 1 year ago

barsoosayque commented 1 year ago

I've just updated my project to bevy 0.10, and with that I also updated bevy_mod_outline to 0.4, which introduced an odd panic in pipeline.rs:119:18:

_thread 'Compute Task Pool (1)' panicked at 'Invalid value for DepthMode: 0', /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_modoutline-0.4.0/src/pipeline.rs:119:18

As far as I could understand, bevy_mod_outline 0.4 didn't introduce anything that require migration, so I'm not really sure why does my code suddenly panics. I've only used OutlineBundle { outline: OutlineVolume { visible: true, width: 3.0, colour: Color::BLACK }, ..default() } similar to the shapes example. I don't do anything with depth, so I don't even know if it's something with my code or a bug in the lib


Panic trace ``` 2023-03-31T09:11:45.761478Z ERROR project::utils::log: Panic at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_mod_outline-0.4.0/src/pipeline.rs:119:18: "none". Backtrace: 0: ::build::{{closure}} at ./src/utils/log.rs:60:29 1: as core::ops::function::Fn>::call at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/alloc/src/boxed.rs:2002:9 2: std::panicking::rust_panic_with_hook at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:692:13 3: std::panicking::begin_panic_handler::{{closure}} at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:579:13 4: std::sys_common::backtrace::__rust_end_short_backtrace at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/sys_common/backtrace.rs:137:18 5: rust_begin_unwind at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:575:5 6: core::panicking::panic_fmt at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/panicking.rs:64:14 7: ::specialize 8: bevy_render::render_resource::pipeline_specializer::SpecializedMeshPipelines::specialize at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/render_resource/pipeline_specializer.rs:117:34 9: bevy_mod_outline::draw::queue_outline_stencil_mesh at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_mod_outline-0.4.0/src/draw.rs:70:32 10: core::ops::function::FnMut::call_mut at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/ops/function.rs:166:5 11: core::ops::function::impls:: for &mut F>::call_mut at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/ops/function.rs:298:13 12: Out>>::run::call_inner at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:629:21 13: Out>>::run at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:632:17 14: as bevy_ecs::system::system::System>::run_unsafe at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:466:19 15: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}}::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:448:26 16: core::ops::function::FnOnce::call_once at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/ops/function.rs:250:5 17: as core::ops::function::FnOnce<()>>::call_once at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/panic/unwind_safe.rs:271:9 18: std::panicking::try::do_call at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:483:40 19: std::panicking::try at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:447:19 20: std::panic::catch_unwind at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panic.rs:140:14 21: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:446:23 22: async_executor::Executor::spawn::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:139:19 23: async_task::raw::RawTask::run at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/raw.rs:563:17 24: async_task::runnable::Runnable::run at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/runnable.rs:782:18 25: async_executor::Executor::run::{{closure}}::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:230:21 26: as core::future::future::Future>::poll at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33 27: async_executor::Executor::run::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:237:31 28: futures_lite::future::block_on::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27 29: std::thread::local::LocalKey::try_with at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/local.rs:446:16 30: std::thread::local::LocalKey::with at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/local.rs:422:9 31: futures_lite::future::block_on at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5 32: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:171:37 33: std::panicking::try::do_call at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:483:40 34: std::panicking::try at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:447:19 35: std::panic::catch_unwind at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panic.rs:140:14 36: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:165:43 37: std::thread::local::LocalKey::try_with at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/local.rs:446:16 38: std::thread::local::LocalKey::with at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/local.rs:422:9 39: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}} at /project/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:158:25 40: std::sys_common::backtrace::__rust_begin_short_backtrace at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/sys_common/backtrace.rs:121:18 41: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}} at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/mod.rs:558:17 42: as core::ops::function::FnOnce<()>>::call_once at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/panic/unwind_safe.rs:271:9 43: std::panicking::try::do_call at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:483:40 44: std::panicking::try at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panicking.rs:447:19 45: std::panic::catch_unwind at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/panic.rs:140:14 46: std::thread::Builder::spawn_unchecked_::{{closure}} at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/thread/mod.rs:557:30 47: core::ops::function::FnOnce::call_once{{vtable.shim}} at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/core/src/ops/function.rs:250:5 48: as core::ops::function::FnOnce>::call_once at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/alloc/src/boxed.rs:1988:9 49: as core::ops::function::FnOnce>::call_once at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/alloc/src/boxed.rs:1988:9 50: std::sys::unix::thread::Thread::new::thread_start at /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de/library/std/src/sys/unix/thread.rs:108:17 51: start_thread 52: clone3 ```
komadori commented 1 year ago

What scheduling constraints are there on the system which adds the OutlineBundle? Theoretically, I think this could happen if you added an OutlineBundle in between computed depth propagation and rendering. I will investigate.

barsoosayque commented 1 year ago

I was spawning entities via a custom Command in OnEnter(GameState::Game) scheduler, and also in one system that ran on CoreSet::PostUpdate. I have since rewrote my code to use normal CoreSet::Update systems instead of commands, and it works just fine except for that one CoreSet::PostUpdate system which I had to move to CoreSet::Update otherwise it would still crash.

komadori commented 1 year ago

0.4.1 is released with fix.