Skip to content

Commit

Permalink
Fix panicking on another scope (#6524)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
james7132 committed Nov 21, 2022
1 parent 15ea93a commit 210979f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_tasks/src/task_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_transform/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 210979f

Please sign in to comment.