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: destroy and removeChild performance #10505

Merged
merged 11 commits into from May 14, 2024
Merged

Fix: destroy and removeChild performance #10505

merged 11 commits into from May 14, 2024

Conversation

GoodBoyDigital
Copy link
Member

@GoodBoyDigital GoodBoyDigital commented May 2, 2024

Description of change

The way rendergroup was being stored kind of bugged me as it was not as intuative as it could be. Consequentially, this meant its a bit harder to understand some of the checks that happen in the code around render groups.

Essentially the renderGroup property on Container could either be the Containers owned render group or its parent render group. Which is kind of weird!

I have modified this so we now have

  • renderGroup which is the the containers renderGroup created when enableRenderGroup is called
  • parentRenderGroup a new property which is the render group that is responsible for rendering the container. this is set when a container is added to a rendergroup.

Modifications to RenderGroup

  • i remove the _children property on renderGroup - we don't actually use it anywhere, so not point pushing and splicing it!
  • added getChildren which will return them all should someone want to get the list of all renderables in a render group.
  • tidied and streamlined some of the functionality of add / removing from a renderGroup to be a bit faster and easier to understand.
  • I also added a removeChildren function to renderGroup.

Benchmark:
removeChildren / destroy is now 1000x faster in the demo from this issue: #10345

Will update a demo once a branch is built.

fixes #10345 and #10377

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

Copy link

codesandbox-ci bot commented May 2, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2f10ef4:

Sandbox Source
pixi.js-sandbox Configuration

@GoodBoyDigital GoodBoyDigital marked this pull request as ready for review May 2, 2024 22:35
@GoodBoyDigital GoodBoyDigital requested a review from Zyie May 2, 2024 22:35
@GoodBoyDigital GoodBoyDigital marked this pull request as draft May 3, 2024 10:32
update tests tio be more readable
@GoodBoyDigital GoodBoyDigital marked this pull request as ready for review May 3, 2024 12:57
@GoodBoyDigital
Copy link
Member Author

/korbit-review

Copy link

korbit-ai bot commented May 8, 2024

/korbit-review

@GoodBoyDigital I have started a new review of this pull request. You will see my feedback shortly.

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I have reviewed your code and found 4 potential issues. To discuss my individual comments that I have added, tag me in replies using @korbit-ai.


Please react with a 👍 to my comments that you find helpful and a 👎 to those you find unhelpful - this will help me learn and improve as we collaborate.

@@ -79,7 +79,7 @@ describe('Container Tests', () =>
// wrong!
expect(child.toGlobal({ x: 0, y: 0 }, null, true)).toEqual({ x: 0, y: 0 });

updateRenderGroupTransforms(container.renderGroup, true);
updateRenderGroupTransforms(container.parentRenderGroup, true);
Copy link

Choose a reason for hiding this comment

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

category Tests

The changes in the test cases are in line with the refactoring of the 'renderGroup' property in the 'Container' class. However, it would be beneficial to add new test cases to specifically test the new 'parentRenderGroup' property and the new 'getChildren' method in the 'RenderGroup' class. This will ensure that the new changes are working as expected and do not introduce any regressions.

else if (this.renderGroup)
{
this.renderGroup.onChildUpdate(this);
this.parentRenderGroup.onChildUpdate(this);
}
}

set isRenderGroup(value: boolean)
Copy link

Choose a reason for hiding this comment

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

category Error Handling

The 'isRenderGroup' property has been refactored, and the setter now throws an error if trying to set it to false. This could be a breaking change for any code that relies on toggling this property. Consider providing a migration path or additional documentation to handle this change.

tests/scene/scene.tests.ts Outdated Show resolved Hide resolved
tests/scene/scene.tests.ts Outdated Show resolved Hide resolved
tests/scene/scene.tests.ts Outdated Show resolved Hide resolved
tests/scene/scene.tests.ts Outdated Show resolved Hide resolved
tests/scene/scene.tests.ts Outdated Show resolved Hide resolved
@Zyie Zyie changed the title RenderGroup updates Fix: destroy and removeChild performance May 14, 2024
@Zyie Zyie added ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t v8 labels May 14, 2024
@Zyie Zyie added this pull request to the merge queue May 14, 2024
Merged via the queue into dev with commit da12bce May 14, 2024
4 checks passed
@Zyie Zyie deleted the chore/optimise-remove branch May 14, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
korbit-code-analysis ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t v8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance: [v8 regression] Container.destroy() is very slow on crowded containers
2 participants