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

IGE-ES6 - Default behavior of _resizeEvent on IgeObject causes performance hit #468

Open
beyond-code-github opened this issue Sep 26, 2018 · 2 comments

Comments

@beyond-code-github
Copy link
Contributor

By default every IgeObject gets an implementation of _resizeEvent that loops each child entity and calls their _resizeEvents in turn:

_resizeEvent: function (event) {

For a basic Isometric tile game with hundreds of entities belonging to a tilemap, this causes a significant lag each tick as we iterate every child but then take no action as nothing needs to respond to these events other than the scene, viewport etc which already have their own overrides for _resizeEvent anyways.

In my fork, I've simply commented out this entire method which has improved performance with no side effects but as I have a limited use-case I was wondering what a better solution to this might be before I sent a PR that might break things for others. Thanks!

@beyond-code-github
Copy link
Contributor Author

Hello @Irrelon, I've re-opened this as the issue has returned in the new branch.

The issue is with adding entities to a tilemap in bulk. For each call to mount() on the parent, we iterate all the children and call their _resizeEvent() method, which ends up in the method being invoked n! (factorial) times.

I have a custom tilemap class so I've worked around this by overriding the _resizeEvent method to be a no-op. I do wonder if it's worth changing the default behaviour though as this could catch people out.

@beyond-code-github beyond-code-github changed the title Default behavior of _resizeEvent on IgeObject causes performance hit IGE-ES6 - Default behavior of _resizeEvent on IgeObject causes performance hit Apr 26, 2023
@Irrelon
Copy link
Owner

Irrelon commented May 2, 2023

Hmm, yeah that does not sound good!! Can you share your usage snippet here so I can understand the flow?

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

No branches or pull requests

2 participants