motion: [BUG] Laggy in Firefox
Description
When using framer-motion, all used animations are lagging on Firefox, even the ones from the Example page. I’ve tried it on Chromium and saw no issue whatsoever in a laggy animation. FPS also seem fine (28-30fps).
CodeSandbox
Even tho you require a CodeSandbox for reproduction, it’s not actually needed, as this also happens with the Examples on the Framer Motion page (or Docs). https://www.framer.com/api/motion/examples/
Code example I’m using as of now:
const variants = {
open: { opacity: 1, y: 0 },
closed: { opacity: 0, y: '15px' },
}
<motion.div initial={false} animate={shareBarVisible ? 'open' : 'closed'} variants={variants}>
<ShareBar>
<QuickShareBar>
<FacebookShareButton url="https://google.com/">
<FacebookIcon size={32} round />
</FacebookShareButton>
<TwitterShareButton url="https://google.com/">
<TwitterIcon size={32} round />
</TwitterShareButton>
<EmailShareButton url="https://google.com/">
<EmailIcon size={32} round />
</EmailShareButton>
</QuickShareBar>
</ShareBar>
</motion.div>
Steps to reproduce
Steps to reproduce the behavior:
- Go to https://www.framer.com/api/motion/examples/
- Scroll down to any animation
- See laggyness
Expected behavior
The animation should not be laggy. See following Video: https://streamable.com/g97k9
Video
Current behavior in Firefox: https://streamable.com/m392r
Environment details
OS: macOS Catalina Browser: Firefox Developer Edition (recent public build)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 21
- Comments: 31
this is still a major issue concerning framer-motion. animation works with all other major browsers but the laggyness of animation is still prominent in Firefox v78.0.2 (64-bit). any solutions concerning this? framer-motion is really nice and fun to work it, but Firefox support is a must.
This can be fixed on a per-site basis by serving content with the following headers:
From https://developer.mozilla.org/en-US/docs/Web/API/Performance/now#Reduced_time_precision
I think this video explains everything. Firefox is hard to love
Its been two years since my last comment, I want to add a comment on this because i saw this issue on my inbox. I can say that the code you write affects general performance of your application, especially if you have framer motion involved. Use memos and callbacks more. Dont be concerned if your animations aren’t smooth in firefox, your 5K monthly user base will use 2.54% firefox potentially (~100 people) and its not a big of a deal. Also, try using gsap, give it a shot, its neat.
Crazy find! Here’s the bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1394735#c1
Great quotes from Theo in the first minute of this video/its description:
Oh boy 😂😂
Still no fix. Here is another comparison:
Firefox
https://github.com/user-attachments/assets/5d6f3c67-98b9-484d-96e5-e94e2b36579b
Chrome/Any Chromium-Based Browser
https://github.com/user-attachments/assets/9d86441c-cd4d-4232-8de3-b024159168d4
Hi I am a super beginner running into the same problem, I have adopted @visualcookie 's suggestion to add the COOP and COEP headers to enable the high precision timer, yet the problem persisted on Firefox (Mobile mode / on Mobile device only).
May I ask @visualcookie whether you have resolved this problem completely? Thank you!
I am using Next js hosted on Vercel and I added the headers via next.config.js
Evidence of high precision timer is successfully turned on via adding COOP and COEP:
When it will be fixed? Very laggy on firefox
Neat idea. How will this work with SPA applications deployed to Heroku, Vercel and Co?
What did it for me was setting
privacy.resistFingerprintingtofalsein theabout:config. Apparently that also worked forreact-springanimations, as things that were usingreact-springin my code were not even showing up.I know it’s only a temporary fix, but maybe it helps the guys behind this library to figure out a way to actually remove the laggyness.
I’m also experiencing laggy animations in FF. Using Developer edition 73.0b12 (64-bit)
Closing as wontfix (cantfix). This is really crazy but Firefox is throttling all requestAnimationFrame animations until the page is interacted with (scroll and then replay the first animation to see)
@erenkulaksiz This issue is not just the result of “bad code” as the issue persists on the main framer preview site. I daily drive firefox and is very annoying when having to open a separate browser just I can develop in peace. To just ruin the experience for a minority of people due to either lazyness or not wanting to care is crazy to me.
It’s 2024 today, and yet, there’s still no fix. This was the reason I stopped using Firefox. Two years ago, when I was learning Framer Motion in React, I wasted a lot of time trying to find my mistake, but it turned out it was the browser’s fault. The code was just a simple motion.div with a variant that had initial and animate properties. To keep it short, I was animating a basic opacity change from 0 to 1. It flickers at the end when the animation is almost done.
Firefox:
https://github.com/user-attachments/assets/7f227b23-df6f-4436-a8bc-f315f3400600
Chrome:
https://github.com/user-attachments/assets/3051f3d5-7a1f-45bf-bff7-65a8a80ce7cc
Has anyone found any other possible solution to this problem? Passing COOP and COEP headers achieved nothing in my project and some of my animations remain choppy. Weirdly enough I experience this only on yoyo animation that changes scale, other animations are completely fine.
Weird, tried that on the examples page, but still experience the laggyness.
Hmm yeah this is really noticeable. Thanks for letting me know, I’ll look into it.
At first glance I reckon something is skipping every other frame. As the “laggyness” looks pretty consistent to me, possibly a solid 30fps.