Wanderer777 Posted September 8, 2015 Share Posted September 8, 2015 When trying to clean up my stage on game over, I loop through my game object groups and destroy all children inside explicitly. Then I destroy the (now empty) groups:cleanGroup(Grp1); // Grp1 is child of Stage groupcleanGroup(Grp2); // Grp2 is child of Stage groupcleanGroup(Grp3), // Grp3 is child of Stage groupcleanGroup(Stage);var cleanGroup = function(Grp) { if (Grp.children) { while (Grp.children.length) Grp.removeChildAt(0).destroy(); } Grp.destroy(); }However, this always gives me a hole bunch of error messages like: this.children is nullthis.parent is nullo is null The error messages are constantly repeating as if it where within a loop anywhere inside the Pixi render enginge. Why is this and how could this be solved? Do I need to destroy my created sprites and groups at all or is it enough just to remove all of my references to them and let the garbage collection do the rest? Would this be reliable? Quote Link to comment Share on other sites More sharing options...
xerver Posted September 8, 2015 Share Posted September 8, 2015 Do you have a jsfiddle or similar the reproduces? It is really just a matter of breaking on the error and walking the stack trace to see where it is coming from. Quote Link to comment Share on other sites More sharing options...
Wanderer777 Posted September 8, 2015 Author Share Posted September 8, 2015 Could this be a synch problem with the internal Pixi render engine that still tries to access objects that already have been removed manually? I found a thread here that described exactly this behaviour in a previous Pixi version. This just happens when I try to manually destroy (nested) objects. If I just unreference them and remove them from stage, everything seems ok -also garbage collection seems to take those objects into account. So I assume it would be also ok NOT to destroy objects manually to clean up and just unreference / unparent them and let the garbage collection do it's thing? Quote Link to comment Share on other sites More sharing options...
xerver Posted September 8, 2015 Share Posted September 8, 2015 If you destroy them without removing them first, you could get an error. If you are removing, and doing it outside a render loop then that probably isn't the case. We don't cache the scene tree, it is walked each time. So I assume it would be also ok NOT to destroy objects manually to clean up and just unreference / unparent them and let the garbage collection do it's thing? That is the only way to destroy objects is manually, the GC can't help with WebGL memory. You must call destroy manually, that is why it is exposed. Quote Link to comment Share on other sites More sharing options...
Wanderer777 Posted September 9, 2015 Author Share Posted September 9, 2015 If you destroy them without removing them first, you could get an error. If you are removing, and doing it outside a render loop then that probably isn't the case. We don't cache the scene tree, it is walked each time. So I assume the method I posted above should work. I can't see any reason why this would cause any interference. And do we have to destroy every single object manually or would it be enough to destroy the parent group only? Does Pixi automatically destroy all of its children then? Quote Link to comment Share on other sites More sharing options...
xerver Posted September 10, 2015 Share Posted September 10, 2015 http://pixijs.github.io/docs/PIXI.Container.html#destroy 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.