From f213c14d90fd5afb65fc11803777ef7f1c3fbe1b Mon Sep 17 00:00:00 2001 From: B_head Date: Sun, 9 Jul 2023 13:25:12 +0900 Subject: [PATCH] Fix not calling `App::finish` and `App::cleanup` in `ScheduleRunnerPlugin` (#9054) This pull request is mutually exclusive with #9066. # Objective Complete the initialization of the plugin in `ScheduleRunnerPlugin`. ## Solution Wait for asynchronous tasks to complete, then `App::finish` and `App::cleanup` in the runner function. --- crates/bevy_app/src/schedule_runner.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_app/src/schedule_runner.rs b/crates/bevy_app/src/schedule_runner.rs index c143f75c42f53..d303769f92696 100644 --- a/crates/bevy_app/src/schedule_runner.rs +++ b/crates/bevy_app/src/schedule_runner.rs @@ -71,6 +71,13 @@ impl Plugin for ScheduleRunnerPlugin { fn build(&self, app: &mut App) { let run_mode = self.run_mode; app.set_runner(move |mut app: App| { + while !app.ready() { + #[cfg(not(target_arch = "wasm32"))] + bevy_tasks::tick_global_task_pools_on_main_thread(); + } + app.finish(); + app.cleanup(); + let mut app_exit_event_reader = ManualEventReader::::default(); match run_mode { RunMode::Once => {