ige icon indicating copy to clipboard operation
ige copied to clipboard

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

Open beyond-code-github opened this issue 6 years ago • 2 comments

By default every IgeObject gets an implementation of _resizeEvent that loops each child entity and calls their _resizeEvents in turn: https://github.com/Irrelon/ige/blob/cd4f470e828bc0f960b1023b515cde398ad9e188/engine/core/IgeObject.js#L1663

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 avatar Sep 26 '18 19:09 beyond-code-github

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 avatar Apr 26 '23 04:04 beyond-code-github

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

Irrelon avatar May 02 '23 14:05 Irrelon