Actuate tween error in inactive browser tab

#1

I using openfl/ starling framework and animating with actuate. animation is looping like
Tween function > On Complete > Tween function again and etc.
when my browser tab is inactive tween goes crazy…
is there any solution for that?

0 Likes

#2

Is there anything we can use to reproduce this? I have not seen trouble in PiratePig or other demos

0 Likes

#3

see this please.
i dont know its maybe browser is pausing and continuing or something.
on the second try animation goes far above and then to its regular position…

0 Likes

#5

is there any way javascript not to be paused when tab is inactive?

0 Likes

#6

Why should it? This behaviour is managed manually – https://developer.mozilla.org/en-US/docs/Web/Events/visibilitychange

0 Likes

#7

because code doesnt stop just tweens are paused and then when tab is active again all the tweens runs at the same time just like in this video https://streamable.com/sfy81

0 Likes

#8

Probably related – https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout

Timeouts in inactive tabs throttled to >=1000ms

To reduce the load (and associated battery usage) from background tabs, timeouts are throttled to firing no more often than once per second (1000 ms) in inactive tabs.

Firefox implements this behavior since version 5 (see bug 633421, the 1000ms constant can be tweaked through the dom.min_background_timeout_value preference). Chrome implements this behavior since version 11 (crbug.com/66078).

Firefox for Android uses a timeout value of 15 minutes for background tabs since bug 736602in Firefox 14, and background tabs can also be unloaded entirely.

So, if animation tick is bound to interval, then it should be reimplemented with requestAnimationFrame (I believe it is not affected).
Also you could pause/resume animations on visibility change event.

1 Like

#9

you are right the main problem for me in this case is that onUpdate function isnt working when tab is inactive

0 Likes

#10

So i made VisibilityChange event and if tab is not active pause all the tweens and timers and resume when tab is active. all good!

1 Like