Jump to content


Timer Fired 2 seconds?

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I was looking in Chrome dev Tools, and while recording a Timeline I see that Tweenmax has a "Timer Fired" every 2 seconds even when nothing is tweening. Is this necessary, or is there a way to turn it off? Just trying anything to improve performance.

Link to comment
Share on other sites

Yep, that's very intentional, and trust me: it's not going to cause ANY problems performance-wise.


One of the most important goals we have is to make GSAP "just work" which entails putting a lot of effort into figuring out browser glitches/bugs/differences, architecting workarounds, etc. We discovered a while back that iOS Safari would sometimes simply not fire requestAnimationFrame when you re-activated a tab/window, causing all animations to permanently stop. Not cool. Again, this had nothing to do with GSAP - it was definitely a browser bug. The only workaround possible was to create a setTimeout() that checked for that particular scenario every so often (2 seconds in this case). It runs a tiny piece of logic which requires less processing than a single update of a single property of a single tween. Seriously, it's trivial, especially in light of the fact that the engine is capable of ripping through thousands of complex tweens 60 times per second, each updating multiple properties. So one tiny check every 2 seconds isn't even a blip on the radar, and it protects you against your animations completely stopping on iOS devices when the user switches tabs and comes back. 


Furthermore, it's not only for iOS devices - that check could also help with future devices that have similar problems down the road. Think of it like getting a $10,000,000 life insurance policy for 1 penny per year. Sign me up!


In short, yes there's a setTimeout() that runs every 2 seconds; it's not a mistake and it won't slow anything down. It's helping the engine deliver on its promise to "just work" in every major browser on the planet ;)

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.