Jump to content

Penalty for removing all children and adding them again?


Chris Smith
 Share

Recommended Posts

Hi, 

 

just a quick question. Is there any performance penalty for removing all children of a container and adding them again every frame?

My question basically - is pixi doing any diffing on that side or should i do it?

I'm writing simple event based game in 'React' style with Redux as a state container and event emiter if you will and Pixi as rendering layer.

If I should approach it completely differently please let me know.

 

Cheers,

Chris

Link to comment
Share on other sites

No diffing, but you lose static transforms optimization. Its a minor issue, because PixiJS is supposed to handle the stage where everything is moving every frame. Its recent addition, PixiJS v3 didnt have that optimization.

There can be a problem because removeChildren creates extra array with removed elements, and if you do that for every container, and you have a lot of them, each frame, it might clog the GC. Its beetter to avoid constant memory allocations each frame. If you have that problem, please patch removeChildren.

Link to comment
Share on other sites

https://github.com/pixijs/pixi.js/blob/dev/src/core/display/Container.js#L53

https://github.com/pixijs/pixi.js/blob/dev/src/core/display/Container.js#L277

Make your own container if those two methods arent effective for you. PixiJS is not a black box, you are supposed to hack it if your case is performance-heavy. We dont allow over-complicated PR's because of that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...