mifi/react-lottie-player

Leaking/performance issues when adding/removing from tree

ccnokes opened this issue ยท 5 comments

If the player is added/removed from the tree, something internally is leaking and it can cause the animation to jank and then the page to crash.

See this sandbox: https://codesandbox.io/s/elated-tdd-pvhkf?file=/src/App.tsx

Click the toggle button once. Everything works and the animation shows. Click it twice and it might be a bit slower. 3-4+ times (at least on my computer) it slows to a crawl and the page becomes unresponsive.

mifi commented

Thanks for nice report! I also managed to reproduce the issue with your codesandbox.

Seems this is an issue with upstream lottie-web. I found these: airbnb/lottie-web#1159 airbnb/lottie-web#2151

The solution is to use something like lodash.clonedeep on the animationData. e.g. animationData={cloneDeep(animationData)}

I will update react-lottie-player with this cloning code, because this is such a sneaky bug and it shouldn't be on the developers' shoulders to have to experience this crash.

mifi commented

this will be fixed in the next version

I upgraded to 1.3.2 but with no result...
Could you help me with this?

https://pensive-gates-96535d.netlify.app/

Schermafbeelding 2021-06-24 om 08 55 21

mifi commented

I believe your issue is #30, please continue discussion there

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰