Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic handling collision events when despawning entities using TimestepMode Interpolated #285

Closed
briansemrau opened this issue Nov 21, 2022 · 5 comments · Fixed by #563
Closed
Labels
A-Integration very bevy specific C-Bug Something isn't working D-Difficult Needs strong technical background, domain knowledge, or impacts are high, needs testing... P-Medium S-not-started Work has not started

Comments

@briansemrau
Copy link

briansemrau commented Nov 21, 2022

This issue happens rarely.

Version details from Cargo.toml:

[dependencies]
bevy = { version = "0.9.0", default-features = false, features = ["bevy_asset", "bevy_gilrs", "bevy_scene", "bevy_winit", "x11", "render", "png", "filesystem_watcher"] }
bevy_asset_loader = { version = "0.14.1", features = ["stageless"] }
bevy_kira_audio = { version = "0.13.0", features = ["ogg"] }
bevy_rapier2d = { version = "0.19.0", features = ["enhanced-determinism", "debug-render"] }
rand = "0.8.5"
smallvec = "1.10.0"

[profile.dev.package.bevy_rapier2d]
opt-level = 3

My game consists of a pile of blocks and a click-drag angry birds style projectile. The projectile destroys itself after a few seconds.

All the blocks have ActiveEvents::CONTACT_FORCE_EVENTS | ActiveEvents::COLLISION_EVENTS

thread 'Compute Task Pool (13)' panicked at 'Internal error: entity not found for collision event.', C:\Users\brian\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_rapier2d-0.19.0\src\pipeline\events.rs:58:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:142
   2: core::panicking::panic_display<str>
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:72
   3: core::panicking::panic_str
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:56
   4: core::option::expect_failed
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\option.rs:1880
   5: wgpu_core::device::Device<A>::dispose
   6: <bevy_rapier2d::pipeline::events::EventQueue as rapier2d::pipeline::event_handler::EventHandler>::handle_collision_event
   7: rapier2d::geometry::narrow_phase::NarrowPhase::handle_user_changes
   8: rapier2d::pipeline::physics_pipeline::PhysicsPipeline::new
   9: rapier2d::pipeline::physics_pipeline::PhysicsPipeline::step
  10: bevy_rapier2d::plugin::context::RapierContext::step_simulation
  11: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  12: <bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  14: async_task::raw::RawTask<F,T,S>::run
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  17: std::thread::local::LocalKey<T>::with
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The rest of the error output:
thread 'main' panicked at 'task has failed', C:\Users\brian\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.3.0\src\task.rs:426:43
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:142
   2: core::panicking::panic_display<str>
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:72
   3: core::panicking::panic_str
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:56
   4: core::option::expect_failed
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\option.rs:1880
   5: <async_task::task::Task<T> as core::future::future::Future>::poll
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: async_task::raw::RawTask<F,T,S>::run
   9: async_executor::LocalExecutor::try_tick
  10: bevy_tasks::task_pool::TaskPool::scope
  11: <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems
  12: <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run
  13: bevy_ecs::schedule::Schedule::run_once
  14: bevy_app::app::App::update
  15: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}
  16: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  17: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::register_window
  18: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::move_state_to
  19: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  20: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind
  21: winit::platform_impl::platform::event_loop::EventLoopThreadExecutor::execute_in_thread
  22: CallWindowProcW
  23: DispatchMessageW
  24: SendMessageTimeoutW
  25: KiUserCallbackDispatcher
  26: NtUserDispatchMessage
  27: DispatchMessageW
  28: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return
  29: winit::platform_impl::platform::event_loop::EventLoop<T>::run
  30: core::ptr::drop_in_place<hashbrown::map::HashMap<winit::window::WindowId,winit::window::Window>>
  31: <bevy_winit::WinitPlugin as bevy_app::plugin::Plugin>::build
  32: bevy_winit::winit_runner_with
  33: core::ops::function::Fn::call
  34: bevy_app::app::App::run
  35: <bevy_core_pipeline::core_2d::camera_2d::Camera2dBundle as bevy_ecs::bundle::Bundle>::component_ids      
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\release\bevy_game_1.exe` (exit code: 101)
@MJohnson459
Copy link

This is happening consistently for me when I despawn say 10 entities at a time. I played about to see what changed and it looks like this happens when the TimestepMode is Interpolated but doesn't happen when it is Variable. I suppose a system that should run every frame isn't being run.

@JLerxky
Copy link

JLerxky commented Nov 24, 2022

+1

@briansemrau briansemrau changed the title Panic handling collision events when despawning entities Panic handling collision events when despawning entities using TimestepMode Interpolated Dec 6, 2022
AnthonyTornetta added a commit to AnthonyTornetta/bevy_rapier that referenced this issue Mar 29, 2023
@AnthonyTornetta
Copy link
Contributor

This is kinda fixed in #328 -- I wasn't sure why systems weren't running properly, so I prevent the crash from being generated from dead entities. I don't think this will skip over any events, but I'm not 100% sure.

@OwlyCode
Copy link

I'm encountering this issue as well. TimestepMode::Variable doesn't help.

@GrantMoyer
Copy link

I see (probably) this issue only when I despawn an entity after I change the RigidBody component of the entity. I'm struggling to produce a succinct reproducer though.

GrantMoyer added a commit to GrantMoyer/bevy_rapier that referenced this issue Dec 17, 2023
Without updating the IslandsManager after removing rigid bodies, later systems may try to access the removed bodies. For example, calling IslandsManager::active_kinematic_bodies() sometimes returns invalid handles if cleanup_removed_rigid_bodies() is not called after rigid bodies are removed. Potentially fixes issue dimforge#285.
@Vrixyz Vrixyz added C-Bug Something isn't working D-Difficult Needs strong technical background, domain knowledge, or impacts are high, needs testing... P-Medium S-not-started Work has not started A-Integration very bevy specific labels May 24, 2024
Vrixyz added a commit to Vrixyz/bevy_rapier that referenced this issue Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Integration very bevy specific C-Bug Something isn't working D-Difficult Needs strong technical background, domain knowledge, or impacts are high, needs testing... P-Medium S-not-started Work has not started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants