-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 memory leak on mesh collider destroy #5106
Conversation
Hey @LeXXik - you submitted the original issue. Got any thoughts here? 😄 |
@willeastcott so, are we keeping the data object on the collision component then? I thought you might have been cooking an update for it, hence the last one didn't go through. @MushAsterion, I think it would be good if we add a test that covers this change. If you are short on time, I can add it later this week. The test would need to cover at least clearing of the collision shapes (primitive, compounds, mesh and triggers). We don't need to test Ammo, so its methods can be stubbed. We just need to make sure we are calling the destroy methods on our side whenever needed. |
That makes sense and time is not really a problem to me. However I have to admit that I have absolutely no knowledge or skills on this matter and when I look at the existing tests none already handle Ammo which sound quite complex to mirror especially on complex shapes... I would love to learn so if you have any example I can use to do so I'll be more than happy to give it a try! |
@MushAsterion you can take a look at these tests that handle Ammo, as an example: |
Thank you @LeXXik! Took a bit of time but I managed to mirror Ammo based on the IDL from playcanvas/ammo.js repo and added the tests for destruction. Did my best to keep it simple but it might be still a bit messy... I wasn't sure about creating a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing. I'd say you went a bit overkill with the Ammo stub module :) However, as you mentioned it can definitely be used to cover all current and potential future features we add to the engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks amazing. I added a small suggestion to the code, to make it slightly more compact.
The test looks a lot better than expected, I'm happy here.
Approving, but would like @willeastcott's thoughts here as well.
In fact it was based on the ammo IDL from archived playcanvas/ammo.js, I think it might be useful to wait for the addition of latest Ammo.js version as @willeastcott told me it should come soon, unless it's not anymore it would then be beneficial to know the current IDL to make sure the Ammo tested version is the one actually used within editor as I was not aware the repo was outdated. |
Perhaps you can then split this PR into two .. one which fixes the memory leak, and the test as a separate. This would allow us to merge the fix while waiting for latest Ammo. |
Co-authored-by: Martin Valigursky <[email protected]>
Moved the tests to #5322! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
Fixes #4267
I know it doesn't match the suggestion from the issue. However I think having a
CollisionSystemImpl#destroyShape
function sound more beneficial than making the parent class aware of an extension. It also removes override of theCollisionMeshSystemImpl#remove
function and make sure there is an actual shape to destroy.I confirm I have read the contributing guidelines and signed the Contributor License Agreement.