angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

Timer doesn't work when window is inactive

Open schlegel opened this issue 10 years ago • 5 comments

Hi, I'm using the angular-timer for countdown to a specific time. But unfortunately when the windows is inactive (another window overlays the browser window), the timer doesn't work correct anymore. A 20 minutes countdown can take about 2 hours. I think its a "energy saving" feature for setTimeout/setInterval. Is there a way to overcome this problem?

schlegel avatar Jan 15 '15 13:01 schlegel

Can you create a plunkr for this issue? It's just using browser's setTimeout & I am not sure if there is anything else we can do to avoid this.

siddii avatar Jan 15 '15 14:01 siddii

The browser throttle setTimeout and setInterval calls to no more than once per second when run inside of an inactive or minimized tab. Example: http://jsfiddle.net/simevidas/gHZSW/ ---> when windows is inactive the timeout of 100ms is not adhered.

http://stackoverflow.com/questions/6585112/javascript-performance-when-running-in-an-unfocused-tab

schlegel avatar Jan 16 '15 09:01 schlegel

here another post about that problem: http://stackoverflow.com/questions/5927284/how-can-i-make-setinterval-also-work-when-a-tab-is-inactive-in-chrome/5927432#12522580

web workers are not affected, but I don't see how web workers could be used in this context.

schlegel avatar Jan 16 '15 09:01 schlegel

Having the same problem. Is there a fix coming anytime soon? Thanks

barbecube avatar May 24 '18 08:05 barbecube

I think this is related to the browser. I am facing the same issue when my website need to send an ajax request every 5 minutes, but when the tab is inactive for some time (>20 minutes I think), the setInterval callback is not executed at all.

crizant avatar Sep 06 '19 07:09 crizant