Skip to content

Commit

Permalink
Rework bevyengine#9826 + Partial revert of bevyengine#10195
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Nov 5, 2023
1 parent 32a5c7d commit 6113c31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
26 changes: 6 additions & 20 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,6 @@ impl App {
panic!("App::run() was called from within Plugin::build(), which is not allowed.");
}

if app.plugins_state() == PluginsState::Ready {
// If we're already ready, we finish up now and advance one frame.
// This prevents black frames during the launch transition on iOS.
app.finish();
app.cleanup();
app.update();
}

let runner = std::mem::replace(&mut app.runner, Box::new(run_once));
(runner)(app);
}
Expand Down Expand Up @@ -986,20 +978,14 @@ impl App {
}

fn run_once(mut app: App) {
let plugins_state = app.plugins_state();
if plugins_state != PluginsState::Cleaned {
while app.plugins_state() == PluginsState::Adding {
#[cfg(not(target_arch = "wasm32"))]
bevy_tasks::tick_global_task_pools_on_main_thread();
}
app.finish();
app.cleanup();
while app.plugins_state() == PluginsState::Adding {
#[cfg(not(target_arch = "wasm32"))]
bevy_tasks::tick_global_task_pools_on_main_thread();
}
app.finish();
app.cleanup();

// if plugins where cleaned before the runner start, an update already ran
if plugins_state != PluginsState::Cleaned {
app.update();
}
app.update();
}

/// An event that indicates the [`App`] should exit. This will fully exit the app process at the
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_app/src/schedule_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ impl Plugin for ScheduleRunnerPlugin {

let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
match run_mode {
RunMode::Once => {
// if plugins where cleaned before the runner start, an update already ran
if plugins_state != PluginsState::Cleaned {
app.update();
}
}
RunMode::Once => app.update(),
RunMode::Loop { wait } => {
let mut tick = move |app: &mut App,
wait: Option<Duration>|
Expand Down
8 changes: 8 additions & 0 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ impl Default for WinitAppRunnerState {
/// Overriding the app's [runner](bevy_app::App::runner) while using `WinitPlugin` will bypass the
/// `EventLoop`.
pub fn winit_runner(mut app: App) {
if app.plugins_state() == PluginsState::Ready {
// If we're already ready, we finish up now and advance one frame.
// This prevents black frames during the launch transition on iOS.
app.finish();
app.cleanup();
app.update();
}

let mut event_loop = app
.world
.remove_non_send_resource::<EventLoop<()>>()
Expand Down

0 comments on commit 6113c31

Please sign in to comment.