diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index c8248cedab..397d4937d5 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -74,13 +74,13 @@ impl Plugin for LogPlugin { app.resources_mut().insert_thread_local(guard); let subscriber = subscriber.with(chrome_layer); bevy_utils::tracing::subscriber::set_global_default(subscriber) - .expect("Could not set global default tracing subscriber."); + .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins"); } #[cfg(not(feature = "tracing-chrome"))] { bevy_utils::tracing::subscriber::set_global_default(subscriber) - .expect("Could not set global default tracing subscriber."); + .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins"); } } @@ -91,14 +91,14 @@ impl Plugin for LogPlugin { tracing_wasm::WASMLayerConfig::default(), )); bevy_utils::tracing::subscriber::set_global_default(subscriber) - .expect("Could not set global default tracing subscriber."); + .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins"); } #[cfg(target_os = "android")] { let subscriber = subscriber.with(android_tracing::AndroidLayer::default()); bevy_utils::tracing::subscriber::set_global_default(subscriber) - .expect("Could not set global default tracing subscriber."); + .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins"); } } } diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index c93c227fc7..9302bf4669 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -336,11 +336,19 @@ pub fn winit_runner(mut app: App) { let mut focused_events = app.resources.get_mut::>().unwrap(); let winit_windows = app.resources.get_mut::().unwrap(); - let window_id = winit_windows.get_window_id(winit_window_id).unwrap(); - focused_events.send(WindowFocused { - id: window_id, - focused, - }); + match (winit_windows.get_window_id(winit_window_id), focused) { + (Some(window_id), _) => focused_events.send(WindowFocused { + id: window_id, + focused, + }), + // unfocus event for an unknown window, ignore it + (None, false) => (), + // focus event on an unknown window, this is an error + _ => panic!( + "Focused(true) event on unknown window {:?}", + winit_window_id + ), + } } _ => {} }, diff --git a/examples/app/return_after_run.rs b/examples/app/return_after_run.rs index ab951341a6..f35c29ba72 100644 --- a/examples/app/return_after_run.rs +++ b/examples/app/return_after_run.rs @@ -8,6 +8,7 @@ fn main() { }) .add_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8))) .add_plugins(DefaultPlugins) + .add_system(system1.system()) .run(); println!("Running another App."); App::build() @@ -15,7 +16,18 @@ fn main() { return_from_run: true, }) .add_resource(ClearColor(Color::rgb(0.2, 0.8, 0.2))) - .add_plugins(DefaultPlugins) + .add_plugins_with(DefaultPlugins, |group| { + group.disable::() + }) + .add_system(system2.system()) .run(); println!("Done."); } + +fn system1() { + info!("logging from first app"); +} + +fn system2() { + info!("logging from second app"); +}