I got an error in my project after using bevy_splash_screen, I thought I was using it incorrectly because cargo run --example simple -F dev
works fine.
I create a new project and copy-paste the code from simple.rs
example.
The structure of my test project:
- assets/bevy_logo.png
- src/main.rs
- .gitignore
- Cargo.lock
- Cargo.toml
main.rs:
use std::time::Duration;
use bevy::prelude::*;
use bevy_splash_screen::{SplashAssetType, SplashItem, SplashPlugin, SplashScreen};
use bevy_tweening::EaseFunction;
#[derive(Clone, Copy, Debug, Default, States, Hash, PartialEq, Eq)]
enum ScreenStates {
#[default]
Splash,
Menu,
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_state::<ScreenStates>()
.add_plugins(
SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu)
.skipable()
.add_screen(SplashScreen {
brands: vec![
SplashItem {
asset: SplashAssetType::SingleImage("bevy_logo.png".to_string()),
tint: Color::WHITE,
width: Val::Percent(60.),
height: Val::Px(150.),
ease_function: EaseFunction::QuinticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: true,
},
],
background_color: BackgroundColor(Color::BLACK),
..default()
}),
)
.add_systems(Startup, create_scene)
.run()
}
fn create_scene(mut cmd: Commands) {
cmd.spawn(Camera2dBundle::default());
}
Cargo.toml:
[package]
name = "test-splash-screen"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.11.3"
bevy_splash_screen = "0.4.4"
bevy_tweening = "0.8.0"
The project starts and closes after a few seconds with a panic.
Output:
nikita@Air-Nikita test-splash-screen % cargo run --release
Compiling test-splash-screen v0.1.0 (/Users/nikita/Desktop/test/test-splash-screen)
Finished release [optimized] target(s) in 2.69s
Running `target/release/test-splash-screen`
2023-10-10T17:16:27.617327Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M1", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2023-10-10T17:16:27.631529Z INFO bevy_winit::system: Creating new window "App" (0v0)
2023-10-10T17:16:27.723033Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M1", core_count: "8", memory: "8.0 GiB" }
thread 'Compute Task Pool (0)' panicked at library/core/src/time.rs:930:31:
overflow when subtracting durations
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_tweening::plugin::component_animator_system<bevy_ui::ui_node::BackgroundColor>`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
thread '<unnamed>' panicked at /Users/nikita/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.11.3/src/storage/resource.rs:56:13:
Attempted to access or drop non-send resource bevy_render::view::window::NonSendMarker from thread Some(ThreadId(1)) on a thread ThreadId(12). This is not allowed. Aborting.
Output with RUST_BACKTRACE=full
:
nikita@Air-Nikita test-splash-screen % RUST_BACKTRACE=full cargo run --release
Finished release [optimized] target(s) in 0.40s
Running `target/release/test-splash-screen`
2023-10-10T17:21:50.342948Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M1", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2023-10-10T17:21:50.357772Z INFO bevy_winit::system: Creating new window "App" (0v0)
2023-10-10T17:21:50.411605Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M1", core_count: "8", memory: "8.0 GiB" }
thread 'Compute Task Pool (0)' panicked at library/core/src/time.rs:930:31:
overflow when subtracting durations
stack backtrace:
0: 0x103b8f848 - std::backtrace_rs::backtrace::libunwind::trace::h0796f85062d1d110
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x103b8f848 - std::backtrace_rs::backtrace::trace_unsynchronized::h37131743b7742f35
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x103b8f848 - std::sys_common::backtrace::_print_fmt::h3d721b30e6a02b1e
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:67:5
3: 0x103b8f848 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8895b8b562a90ee4
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:44:22
4: 0x103bac3d4 - core::fmt::rt::Argument::fmt::h9b2906ecdd0d5723
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/fmt/rt.rs:138:9
5: 0x103bac3d4 - core::fmt::write::h7a9cc4d1d610bd71
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/fmt/mod.rs:1114:21
6: 0x103b8d190 - std::io::Write::write_fmt::h87ff59bc697656ff
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/io/mod.rs:1763:15
7: 0x103b8f688 - std::sys_common::backtrace::_print::hc66b79e8f0b7efad
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:47:5
8: 0x103b8f688 - std::sys_common::backtrace::print::ha692d990665b4a43
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:34:9
9: 0x103b90c88 - std::panicking::default_hook::{{closure}}::hf23c7dbcec5e5d80
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:272:22
10: 0x103b909a0 - std::panicking::default_hook::h6d5fe0c884e09021
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:292:9
11: 0x103b911cc - std::panicking::rust_panic_with_hook::h7c3b2a0098acc318
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:731:13
12: 0x103b910d4 - std::panicking::begin_panic_handler::{{closure}}::h5a56c37d4253c5c6
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:609:13
13: 0x103b8fcd4 - std::sys_common::backtrace::__rust_end_short_backtrace::h6240b1fcaf592476
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:170:18
14: 0x103b90e40 - rust_begin_unwind
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:597:5
15: 0x103c87a50 - core::panicking::panic_fmt::h665dccaf061d2198
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/panicking.rs:72:14
16: 0x103c87a1c - core::panicking::panic_display::h49e3c7b392046f5b
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/panicking.rs:168:5
17: 0x103c87a1c - core::panicking::panic_str::h7e8114befff17681
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/panicking.rs:152:5
18: 0x103c87a1c - core::option::expect_failed::h63330624641ca5a1
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/option.rs:1988:5
19: 0x103bb09dc - core::option::Option<T>::expect::ha4cf28e79fdb7377
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/option.rs:898:21
20: 0x103bb09dc - <core::time::Duration as core::ops::arith::Sub>::sub::hb274b849eac081e1
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/time.rs:930:31
21: 0x102a59b20 - <bevy_tweening::tweenable::Sequence<T> as bevy_tweening::tweenable::Tweenable<T>>::tick::h94415d339fb142f5
22: 0x102a59b4c - <bevy_tweening::tweenable::Sequence<T> as bevy_tweening::tweenable::Tweenable<T>>::tick::h94415d339fb142f5
23: 0x102a3dce4 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h06b13d9fef497d2c
24: 0x102a3d61c - <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe::hf4d53360a974de2e
25: 0x103adfbd8 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h5d9322fbfbbeb733
26: 0x103ab5bc0 - async_task::raw::RawTask<F,T,S,M>::run::he53ad1554f021c10
27: 0x103ae72fc - async_executor::Executor::run::{{closure}}::h9c33a5e6061a86b6
28: 0x103ae5d7c - futures_lite::future::block_on::hedf76c808ab2ed55
29: 0x103aea924 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1d4f3216771bcb3d
30: 0x103ae9f04 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8f9ca3da47ed068d
31: 0x103b93654 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb4255ffe78e3d6be
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/alloc/src/boxed.rs:2007:9
32: 0x103b93654 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6065d76bfdbb846b
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/alloc/src/boxed.rs:2007:9
33: 0x103b93654 - std::sys::unix::thread::Thread::new::thread_start::h86fccd826fc7dcb1
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys/unix/thread.rs:108:17
34: 0x18b093034 - __pthread_joiner_wake
Encountered a panic in system `bevy_tweening::plugin::component_animator_system<bevy_ui::ui_node::BackgroundColor>`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
thread '<unnamed>' panicked at /Users/nikita/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.11.3/src/storage/resource.rs:56:13:
Attempted to access or drop non-send resource bevy_render::view::window::NonSendMarker from thread Some(ThreadId(1)) on a thread ThreadId(12). This is not allowed. Aborting.
stack backtrace:
0: 0x103b8f848 - std::backtrace_rs::backtrace::libunwind::trace::h0796f85062d1d110
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x103b8f848 - std::backtrace_rs::backtrace::trace_unsynchronized::h37131743b7742f35
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x103b8f848 - std::sys_common::backtrace::_print_fmt::h3d721b30e6a02b1e
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:67:5
3: 0x103b8f848 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8895b8b562a90ee4
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:44:22
4: 0x103bac3d4 - core::fmt::rt::Argument::fmt::h9b2906ecdd0d5723
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/fmt/rt.rs:138:9
5: 0x103bac3d4 - core::fmt::write::h7a9cc4d1d610bd71
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/fmt/mod.rs:1114:21
6: 0x103b8d190 - std::io::Write::write_fmt::h87ff59bc697656ff
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/io/mod.rs:1763:15
7: 0x103b8f688 - std::sys_common::backtrace::_print::hc66b79e8f0b7efad
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:47:5
8: 0x103b8f688 - std::sys_common::backtrace::print::ha692d990665b4a43
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:34:9
9: 0x103b90c88 - std::panicking::default_hook::{{closure}}::hf23c7dbcec5e5d80
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:272:22
10: 0x103b909a0 - std::panicking::default_hook::h6d5fe0c884e09021
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:292:9
11: 0x103b911cc - std::panicking::rust_panic_with_hook::h7c3b2a0098acc318
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:731:13
12: 0x103b910d4 - std::panicking::begin_panic_handler::{{closure}}::h5a56c37d4253c5c6
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:609:13
13: 0x103b8fcd4 - std::sys_common::backtrace::__rust_end_short_backtrace::h6240b1fcaf592476
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys_common/backtrace.rs:170:18
14: 0x103b90e40 - rust_begin_unwind
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/panicking.rs:597:5
15: 0x103c87a50 - core::panicking::panic_fmt::h665dccaf061d2198
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/core/src/panicking.rs:72:14
16: 0x1034b1154 - bevy_ecs::storage::resource::ResourceData<_>::validate_access::hfbf63342c0eaef1c
17: 0x10339986c - <alloc::vec::Vec<T,A> as core::ops::drop::Drop>::drop::hc8aa114fff7f0f74
18: 0x10347e3f8 - core::ptr::drop_in_place<bevy_ecs::storage::resource::Resources<_>>::h65896e25a806697f
19: 0x10347b374 - core::ptr::drop_in_place<bevy_ecs::world::World>::h18b3e044d6c35157
20: 0x10347ad70 - core::ptr::drop_in_place<bevy_app::app::App>::h89ab75b986ac2e8f
21: 0x103484850 - <concurrent_queue::single::Single<T> as core::ops::drop::Drop>::drop::hbe929fe978ee1d26
22: 0x103436fd0 - core::ptr::drop_in_place<async_channel::Channel<bevy_app::app::SubApp>>::hc87d9539f76495ea
23: 0x1034389a0 - alloc::sync::Arc<T,A>::drop_slow::h8389202de96ae474
24: 0x10344c238 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd5329426e268dc18
25: 0x1033a6b34 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hf5bcd5d821f393c2
26: 0x103b93654 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb4255ffe78e3d6be
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/alloc/src/boxed.rs:2007:9
27: 0x103b93654 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6065d76bfdbb846b
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/alloc/src/boxed.rs:2007:9
28: 0x103b93654 - std::sys::unix::thread::Thread::new::thread_start::h86fccd826fc7dcb1
at /rustc/8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72/library/std/src/sys/unix/thread.rs:108:17
29: 0x18b093034 - __pthread_joiner_wake
But cargo run --example simple -F dev
works:
nikita@Air-Nikita bevy_splash_screen % cargo run --example simple -F dev
Finished dev [optimized + debuginfo] target(s) in 0.34s
Running `target/debug/examples/simple`
2023-10-10T17:24:19.617050Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M1", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2023-10-10T17:24:19.630684Z INFO bevy_winit::system: Creating new window "App" (0v0)
2023-10-10T17:24:19.707455Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M1", core_count: "8", memory: "8.0 GiB" }
2023-10-10T17:24:32.528119Z INFO bevy_window::system: No windows are open, exiting
2023-10-10T17:24:32.528460Z INFO bevy_winit::system: Closing window 0v0