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

Fix the issue that can not destroy Node in contract listener call back in Box2D #17701

Merged
merged 5 commits into from
Oct 12, 2024

Conversation

minggo
Copy link
Contributor

@minggo minggo commented Oct 11, 2024

Steps to reproduce the issue:

  • open the project
    Hello384_1.zip

  • then will see error message when two objects collides

Reason:

  • destroy a Node will inactive all components
  • inactive Box2D rigidbody will trigger exception in contract listener call back as physics world is locked

How to fix:

  • check physics world status before active/inactive rigidbody

Indeed there are more codes should do check, but it is more common to destroy node in call back. And it invokes physics codes indirectly, so it is not easy to notice error usage here. If invoke other physics codes directly in call back is not allowed.

It works before v3.8.0 because of the PR: #14026. That PR will delay emitting contract listener. And this PR is reverted in #15564. I don't know why to revert the implementation.

Copy link

Interface Check Report

This pull request does not change any public interfaces !

@minggo minggo requested a review from dumganhar October 12, 2024 02:16
@minggo minggo merged commit 186fa0f into cocos:v3.8.5 Oct 12, 2024
25 of 26 checks passed
@minggo minggo deleted the fix-box2d-contract-call-back branch October 12, 2024 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants