Jump to content
GreenSock

vundev

Members
  • Posts

    4
  • Joined

  • Last visited

vundev's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hm, nothing is wrong with the TweenMax, the preorder recursion doesn't work as expected, because of the wrong usage of hasOwnProperty. So here is the rewritten example. Another odd thing is that if destroyDisplayList is not called, the tweenLoolup map will keep a reference to the Slide object, otherwise not. So the question is how the pixijs display list affects TweenMax, it is very strange...If you can give me some explanation It would be great. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>GASP memory leak</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js"></script> <script src="http://pixijs.download/release/pixi.min.js"></script> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script> window.onload = function () { // starts rendering const renderer = PIXI.autoDetectRenderer(500, 500); $('canvas').append(renderer.view); renderer.backgroundColor = 0x000000; const stage = new PIXI.Container(); animate() function animate() { renderer.render(stage); requestAnimationFrame(function () { animate() }); } // end // Define api here class Slide extends PIXI.Container { constructor(id) { super() this.id = id } } PIXI.DisplayObject.prototype.preorder = function (callback) { const length = this.children.length for (var i = 0; i < length; i++) { if (typeof this.children[i].preorder == 'function') this.children[i].preorder(callback) } callback(this) } // end const navigation = new PIXI.Container() const container = new PIXI.Container() const holder = new PIXI.Container() const slide = new Slide(555) stage.addChild(navigation) navigation.addChild(container) container.addChild(holder) holder.addChild(slide) navigation.name = 'nav' container.name = 'cont' holder.name = 'holder' slide.name = 'slide' function destroyDisplayList(){ navigation.preorder(function (child) { if (child instanceof PIXI.Sprite) child.destroy(false, false); else child.destroy(); }); } setTimeout(function () { stage.removeChild(navigation); TweenMax.killTweensOf(holder); destroyDisplayList() }, 500) } </script> </head> <body> <canvas></canvas> </body> </html>
  2. He there, I have the same problem, with this tweenLookup map, but I have an example of how to reproduce the issue. The example is pretty unnatural because it came from a separate project, but it is pretty simple. So the retained object is from the Slide class. If you do comment over the line: TweenMax.killTweensOf(holder), the object is successfully gc, otherwise not. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>GASP memory leak</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js"></script> <script src="http://pixijs.download/release/pixi.min.js"></script> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script> window.onload = function () { // starts rendering const renderer = PIXI.autoDetectRenderer(500, 500); $('canvas').append(renderer.view); renderer.backgroundColor = 0x000000; const stage = new PIXI.Container(); animate() function animate() { renderer.render(stage); requestAnimationFrame(function () { animate() }); } // end // Define api here class Slide extends PIXI.Container { constructor(id) { super() this.id = id } } PIXI.DisplayObject.prototype.preorder = function (callback) { const length = this.children.length for (var i = 0; i < length; i++) { if (this.children[i].hasOwnProperty('preorder')) this.children[i].preorder(callback) else callback(this.children[i]) } callback(this) } // end // Define the Dsiplay List wich causes the memory leak - Slide object stands forever const navigation = new PIXI.Container() const container = new PIXI.Container() const holder = new PIXI.Container() const slide = new Slide(555) navigation.addChild(container) container.addChild(holder) holder.addChild(slide) stage.addChild(navigation) setTimeout(function () { stage.removeChild(navigation); TweenMax.killTweensOf(holder); // If you comment this line the Slide object will be collected from memory // destroy the navigation without it's textures navigation.preorder(function (child) { if (child instanceof PIXI.Texture) child.destroy(false); else if (child instanceof PIXI.Sprite) child.destroy(false, false); else child.destroy(); }); }, 500) // end } </script> </head> <body> <canvas></canvas> </body> </html>
  3. I perfectly agree with you and wan't intterupt you again with sharedEvents ... For my project it is not important to add listeners to sharedEvents before loading completes. When loading completes I access the reference to the document class of the loaded swf with rawContent property and put my listeners like this: loader.rawContent.loaderInfo.sharedEvents.addEventListeners(...) I was thinking that I'm missing sth into the docs, but ok ... The reason for using sharedEvents is because I want to skip bubbling events from th eexternal swf. Firstly I was adding my listeners directly to the document class and bubbling them into the external.swf -> overheat. With SharedEvents sends everything in target phase .... Thanks for the reply
  4. Hi Jack, I am loading external.swf and want to catch some events from it by the main.swf which loads it. The sheme introduced by adobe is: // ------- Source in the main.swf --------- // external.swf is loaded by the loader instance of Loader class loader.contentLoaderInfo.sharedEvents.addEventListener('MyEvent', onCustomEvent); loader.load() function onCustomEvent(event:Event):void { //events from external.swf are handled here } // ------- Source in the external.swf --------- // the external swf dispatches events like this this.loadirInfo.sharedEvent.dispatchEvent(new CustomeEvent('MyEvent')) I cant figure out how to do that with SWFLoader? I can of course, use loader.rawContent.loaderInfo.sharedEvents, but it limitates the things so that the listeners must be put after loading completes
×