Fix panicking on another scope (#6524)

# Objective
Fix #6453. 

## Solution
Use the solution mentioned in the issue by catching the unwind and dropping the error. Wrap the `executor.try_tick` calls with `std::catch::unwind`.

Ideally this would be moved outside of the hot loop, but the mut ref to the `spawned` future is not `UnwindSafe`.

This PR only addresses the bug, we can address the perf issues (should there be any) later.
This commit is contained in:
James Liu 2022-11-21 12:59:08 +00:00
parent 15ea93a348
commit 210979f631
2 changed files with 6 additions and 6 deletions

View File

@ -299,8 +299,11 @@ impl TaskPool {
break result;
};
self.executor.try_tick();
task_scope_executor.try_tick();
std::panic::catch_unwind(|| {
executor.try_tick();
task_scope_executor.try_tick();
})
.ok();
}
}
}

View File

@ -318,10 +318,7 @@ mod test {
let mut temp = World::new();
let mut app = App::new();
// FIXME: Parallel executors seem to have some odd interaction with the other
// tests in this crate. Using single_threaded until a root cause can be found.
app.add_stage("single", SystemStage::single_threaded())
.add_system_to_stage("single", transform_propagate_system);
app.add_system(transform_propagate_system);
fn setup_world(world: &mut World) -> (Entity, Entity) {
let mut grandchild = Entity::from_raw(0);