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

Added a JS function to clean up orphaned entities #664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ksuprynowicz
Copy link
Member

This allows removing orphaned entities that cannot be removed by other means and persist even in JSON files in backups. It's not tested yet.

@ksuprynowicz ksuprynowicz added needs CR This pull request needs to be code reviewed needs QA This pull request needs to be tested labels Oct 14, 2023
Q_ASSERT(sessionID.isNull());
entity->collectChildrenForDelete(entitiesToDeleteImmediately, sessionID);
_deletedEntityCounter += entitiesToDeleteImmediately.size();
_entityTree->deleteEntitiesByPointer(entitiesToDeleteImmediately);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to delete entities while iterating over them? Perhaps this needs doing after forEachEntity is done?

@HifiExperiments
Copy link
Member

why does this need to be invokeable from JS? shouldn't this be run purely from the c++ side? maybe when domains first load and then again on backups or somewhat regularly?

also what if someone deletes a parent entity on purpose and just hasn't done anything to handle the child entity yet? should create automatically try to clear the parentID of the children and maybe correct the transform to stay in the same place?

@ksuprynowicz
Copy link
Member Author

ksuprynowicz commented Feb 26, 2024

I totally agree - probably calling this once entity mixer starts could make most sense.
Right now messages about orphaned entities are filling up the logs at Overte Hub, and there is completely no way of removing them. I think they may also be affecting the performance.

also what if someone deletes a parent entity on purpose and just hasn't done anything to handle the child entity yet?

As far as I know deleting an entity normally deletes all its chldren too - please correct me if I'm wrong. I think it's just that there's some bug that makes it not work on some rare occasions.

@HifiExperiments
Copy link
Member

ah yeah you're totally right

you could take a look at EntityTree::readFromMap for a good place to do this!

@AleziaKurdis
Copy link
Contributor

This is a bit a freaky PR. ;-)

If i remember well, one of the cause of getting orphan was the delete and copy/paste
I fixed this one years ago. But there are probably other usecase.

I have domain that I know that contain some. If you need a copy to make test... I can check for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs CR This pull request needs to be code reviewed needs QA This pull request needs to be tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants