Gamote / lottie-react

A lightweight React library for rendering complex After Effects animations in real time using Lottie.
https://lottiereact.com
Other
786 stars 59 forks source link

Large Memory Leak #63

Closed StephenEsser closed 2 years ago

StephenEsser commented 2 years ago

Describe the bug The lottie-react animations are causing large memory leaks. We use multiple animations on a single page within our application. These animations are routinely unmounted and remounted. This leak eventually causes an out of memory browser crash over the course of several hours while our application is running. There is something within the lottie animation not being cleaned up.

To Reproduce

I've created a project here to reproduce the issue. This example just mounts and unmounts multiple example lottie walking animations.

A gh-deployment is here to reproduce: https://stephenesser.github.io/lottie-memory-leak/

Steps to reproduce the behavior:

  1. Go to https://stephenesser.github.io/lottie-memory-leak/
  2. Open the chrome developer tools and start analyzing the memory
  3. Repeatedly (10+ times) click the "Switch" button
  4. Observe the browser memory continues to climb

I am unable to tell if clicking "Switch" before the animation completely finishes makes a difference. Sometimes if you let the animation complete before clicking "Switch" it looks like the browser will attempt to reclaim that memory, but it is not consistent.

Expected behavior When a lottie animation unmounts it should cleanup any memory references.

Screenshots The memory will continuously climb as animations are mounted and unmounted.

image

image

image

Gamote commented 2 years ago

Hi @StephenEsser thank you for taking the time to report this and add the necessary details in order for me to reproduce it. I will take care of it tonight.

Gamote commented 2 years ago

This issue was fixed in v2.3.1.