Skip to content

Commit bc9e159

Browse files
Revert App::run() behavior/Remove winit specific code from bevy_app (#10389)
# Objective The way `bevy_app` works was changed unnecessarily in #9826 whose changes should have been specific to `bevy_winit`. I'm somewhat disappointed that happened and we can see in #10195 that it made things more complicated. Even worse, in #10385 it's clear that this breaks the clean abstraction over another engine someone built with Bevy! Fixes #10385. ## Solution - Move the changes made to `bevy_app` in #9826 to `bevy_winit` - Revert the changes to `ScheduleRunnerPlugin` and the `run_once` runner in #10195 as they're no longer necessary. While this code is breaking relative to `0.12.0`, it reverts the behavior of `bevy_app` back to how it was in `0.11`. Due to the nature of the breakage relative to `0.11` I hope this will be considered for `0.12.1`.
1 parent efc7dc0 commit bc9e159

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

crates/bevy_app/src/app.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,6 @@ impl App {
309309
panic!("App::run() was called from within Plugin::build(), which is not allowed.");
310310
}
311311

312-
if app.plugins_state() == PluginsState::Ready {
313-
// If we're already ready, we finish up now and advance one frame.
314-
// This prevents black frames during the launch transition on iOS.
315-
app.finish();
316-
app.cleanup();
317-
app.update();
318-
}
319-
320312
let runner = std::mem::replace(&mut app.runner, Box::new(run_once));
321313
(runner)(app);
322314
}
@@ -986,20 +978,14 @@ impl App {
986978
}
987979

988980
fn run_once(mut app: App) {
989-
let plugins_state = app.plugins_state();
990-
if plugins_state != PluginsState::Cleaned {
991-
while app.plugins_state() == PluginsState::Adding {
992-
#[cfg(not(target_arch = "wasm32"))]
993-
bevy_tasks::tick_global_task_pools_on_main_thread();
994-
}
995-
app.finish();
996-
app.cleanup();
981+
while app.plugins_state() == PluginsState::Adding {
982+
#[cfg(not(target_arch = "wasm32"))]
983+
bevy_tasks::tick_global_task_pools_on_main_thread();
997984
}
985+
app.finish();
986+
app.cleanup();
998987

999-
// if plugins where cleaned before the runner start, an update already ran
1000-
if plugins_state != PluginsState::Cleaned {
1001-
app.update();
1002-
}
988+
app.update();
1003989
}
1004990

1005991
/// An event that indicates the [`App`] should exit. This will fully exit the app process at the

crates/bevy_app/src/schedule_runner.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ impl Plugin for ScheduleRunnerPlugin {
8484

8585
let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
8686
match run_mode {
87-
RunMode::Once => {
88-
// if plugins where cleaned before the runner start, an update already ran
89-
if plugins_state != PluginsState::Cleaned {
90-
app.update();
91-
}
92-
}
87+
RunMode::Once => app.update(),
9388
RunMode::Loop { wait } => {
9489
let mut tick = move |app: &mut App,
9590
wait: Option<Duration>|

crates/bevy_winit/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ impl Default for WinitAppRunnerState {
349349
/// Overriding the app's [runner](bevy_app::App::runner) while using `WinitPlugin` will bypass the
350350
/// `EventLoop`.
351351
pub fn winit_runner(mut app: App) {
352+
if app.plugins_state() == PluginsState::Ready {
353+
// If we're already ready, we finish up now and advance one frame.
354+
// This prevents black frames during the launch transition on iOS.
355+
app.finish();
356+
app.cleanup();
357+
app.update();
358+
}
359+
352360
let mut event_loop = app
353361
.world
354362
.remove_non_send_resource::<EventLoop<()>>()

0 commit comments

Comments
 (0)