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

attach/detach issue #134

Open
volcoma opened this issue Mar 17, 2024 · 3 comments
Open

attach/detach issue #134

volcoma opened this issue Mar 17, 2024 · 3 comments

Comments

@volcoma
Copy link

volcoma commented Mar 17, 2024

Hi, after your recent changes i now get an assert in the broadphase destructor event without creating any physics objects.
I am basically doing attach/detach

broadphase::~broadphase() {
    m_connections.clear();

    // This class creates all contact manifolds thus destroy them all.
    auto manifold_view = m_registry->view<contact_manifold>();
    m_registry->destroy(manifold_view.begin(), manifold_view.end());  <---  asserts here

    m_registry->clear<tree_resident>();
}
@volcoma
Copy link
Author

volcoma commented Mar 17, 2024

also i dont know if it is intended but this code is duplicated in edyn::detach

           // All manifolds are created by the engine thus destroy all entities.
    auto manifold_view = registry.view<contact_manifold>();
    registry.destroy(manifold_view.begin(), manifold_view.end());
@volcoma
Copy link
Author

volcoma commented Mar 17, 2024

Screenshot 2024-03-17 191305

here is a screenshot of the backtrace. Looks like its coming from the stepper_async destructor calling broadphase destructor

@volcoma
Copy link
Author

volcoma commented Mar 17, 2024

Seems to me its somehow related to the order of destruction in the simulation_worker's destructor

Manually erasing them seems to fix the crash, but i don't know why

simulation_worker::~simulation_worker() {
    stop();
    m_registry.ctx().erase<contact_manifold_map>();
    m_registry.ctx().erase<broadphase>();
    m_registry.ctx().erase<narrowphase>();
    m_registry.ctx().erase<entity_graph>();
    m_registry.ctx().erase<edyn::settings>();
    m_registry.ctx().erase<registry_operation_context>();
    m_registry.ctx().erase<material_mix_table>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant