Chris Smith Posted March 4, 2018 Share Posted March 4, 2018 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 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 4, 2018 Share Posted March 4, 2018 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 4, 2018 Share Posted March 4, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.