question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak using goToAndStop and destroy

See original GitHub issue

Tell us about your environment

  • Browser and Browser Version: Chrome 66.0.3359.181

  • After Effects Version: Last version

I have a page in an angular application with around 20 animations rendered by SVGRenderer. And I’m using goToAndStop for displaying specific frame of animations (like preview of an animation).

When I leave that page, I’m calling destroy method for every animation, so all resources should be freed up. But then I’m opening the page with animations several times, at some time the whole page freezes and becomes unresponsive (actually it’s always 4th time). The page memory consumption is increasing very fast. In that case I only can kill the page in process manager.

First finding was the typo in property name (https://github.com/airbnb/lottie-web/blob/master/player/js/elements/svgElements/SVGShapeElement.js#L303):

SVGShapeElement.prototype.destroy = function(){
    this.destroyBaseElement();
    this.shapeData = null; // <--- there is no "shapeData" property, it's called "shapesData" (plural form)
    this.itemsData = null;
};

But it didn’t help unfortunately. Then I added breakpoint here https://github.com/airbnb/lottie-web/blob/master/player/js/elements/ShapeElement.js#L24 and saw that number of shapes on every page opening dramatically increases:

renderModifiers: function() {
    if(!this.shapeModifiers.length){
        return;
    }
    var i, len = this.shapes.length; // <--- on first open it's 11, then 121 (11^2) and then 1331 (11^3) 
    for(i=0;i<len;i+=1){
        this.shapes[i].sh.reset();
    }

    len = this.shapeModifiers.length;
    for(i=len-1;i>=0;i-=1){
        this.shapeModifiers[i].processShapes(this._isFirstFrame);
    }
}

Looks like not all resources are freed up after animation desctruction and search through shapes is broken.

Hope it will give you some insight into the issue

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

4reactions
zeorincommented, Oct 20, 2020

Sorry to necro this issue, but wow it’s wild that Lottie mutates animationData! That should really be documented behaviour. Nowadays with hot reload even if you’re not explicitly reusing an instance of animationData, you may still be doing so on hot-reload. In my case on a Gatsby site, but that doesn’t really matter.

Deep cloning the animationData worked. Wasted a whole day on this.

3reactions
Jokerocommented, Sep 7, 2018

Your cached animation JSON can be mutated by Lottie, so try to clone deeply it every time you create a new animation

Read more comments on GitHub >

github_iconTop Results From Across the Web

can it be memory leak? - smartfoxserver.com
Our socket server starts to running out of memory and start to die with a new popular game added recently. The game is...
Read more >
Perl/Tk Memory Leak When Using destroy() Command
Basically I am running a GUI where a frame is destroyed and repopulated regularly. This seems to cause a large memory leak that...
Read more >
Detached window memory leaks - web.dev
Detached windows are a common type of memory leak that is particularly difficult to find and fix.
Read more >
Preventing Memory Leaks in Angular Observables with ...
Reproduce a memory leak in it. Fix the memory leak with the takeUntil + ngOnDestroy pattern. To accomplish these tasks, make sure you:...
Read more >
Debug DOM memory leaks with the Detached Elements tool
Identify the DOM node causing others to be retained · Click the Detach Elements ( The Detach Elements icon. ) icon to destroy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found