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

Always reset internal asset and model references on ModelComponent onRemove #3527

Merged
merged 1 commit into from
Oct 7, 2021

Conversation

jpauloruschel
Copy link
Contributor

@jpauloruschel jpauloruschel commented Sep 29, 2021

Fixes playcanvas/editor#159 and playcanvas/editor#365.

This PR fixes issues on model instances not being correctly "freed" when a ModelComponent is deleted by always calling model and asset setters to null when the component is removed/deleted. Although in most cases modelComponent.model would never be set when modelComponent.type is asset, this is not guaranteed.

The two issues linked above happen because the Collision "preview" models are created in code, but are not properly freed because the type is left at asset (which is the default). There are actually multiple ways of fixing those particular bugs (like setting a custom value to type, or manually setting modelComponent.model to null on the CollisionComponent), but this fixes the most underlying issue.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@jpauloruschel jpauloruschel requested a review from a team September 29, 2021 15:06
@jpauloruschel jpauloruschel self-assigned this Sep 29, 2021
Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems good to me.
RenderComponent sets asset to null at all times, so this should be safe here to do as well.

@mvaligursky mvaligursky added the release: next minor Ticket marked for the next minor release label Oct 6, 2021
@jpauloruschel jpauloruschel merged commit bc49584 into master Oct 7, 2021
@willeastcott willeastcott deleted the jpauloruschel-reset-model-component-model branch January 31, 2022 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug release: next minor Ticket marked for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes are not visible until refresh of browser
3 participants