bevy
bevy copied to clipboard
Headless renderer example has been added
Objective
Fixes #11457.
Solution
Based on another headless application
Changelog
- Adopted to bevy 0.14
- Panic fixed by disabling PipelinedRenderingPlugin instead of disabling "multithreaded" bevy feature completely
@alice-i-cecile May I ask you for a review?
@IceSentry , may I ask you for a rereview?
could you add objects to the scene, so that it doesn't render just a black picture?
the example panics for me:
Adding CaptureFramePlugin
Saving image to: "bevy/test_images"
thread 'Compute Task Pool (3)' panicked at examples/app/headless_renderer.rs:300:22:
Failed to send data to main world: "SendError(..)"
stack backtrace:
0: rust_begin_unwind
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
1: core::panicking::panic_fmt
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1649:5
3: core::result::Result<T,E>::expect
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1030:23
4: headless_renderer::frame_capture::image_copy::receive_image_from_buffer
at ./examples/app/headless_renderer.rs:298:17
5: core::ops::function::FnMut::call_mut
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:166:5
6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:294:13
7: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2) .> Out>>::run::call_inner
at ./crates/bevy_ecs/src/system/function_system.rs:665:21
8: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2) .> Out>>::run
at ./crates/bevy_ecs/src/system/function_system.rs:668:17
9: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
at ./crates/bevy_ecs/src/system/function_system.rs:507:19
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `headless_renderer::frame_capture::image_copy::receive_image_from_buffer`!
Is it possible to not surface that panic?
thread 'Compute Task Pool (3)' panicked at examples/app/headless_renderer.rs:300:22: Failed to send data to main world: "SendError(..)" Is it possible to not surface that panic?
The reason of this panic is attempt to send image data to nonexistent receiver, because MainWorld destroyed while RenderWorld still renders. For such case I left comment
// This could fail on app exit, if Main world clears resources while Render world still renders
Simple solution is ignoring Result of that send (there is .expect("...") now), more complex solution is to notify RenderWorld that an exit event has emitted, may be via some Atomic<bool>.
@mockersf May I ask you for a rereview?
@alice-i-cecile Looks like no one dares to approve, but there are no more changes requested left. We are stuck. Can you invite some one else?
Yeah, I'll ask around :) There's been a long history of subtle challenges with headless rendering, so I suspect that's driving the difficulty.
@bugsweeper those suggestions look solid, but once CI is green I'll merge this in either way :)
@mockersf May I ask you for a rereview?
@alice-i-cecile Ci is green now