cycler hangs IE after a while

Page: 1

Author Post
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
After about 10 minutes, IE (10 & 11) hangs with the cycler running. I thought maybe it was something in my code, but it happens with your example, too. Any ideas? Thanks!
Administrator
Registered: Aug 2008
Posts: 3382
I can't reproduce this. I've been running my demo page cycler examples in IE 11 for an hour now and it just keeps motoring on without incident. I've been monitoring memory usage and there is no memory leakage going on. I have no guesses as to why your IE instance is having trouble.
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
Yes, after I left you a message I left it open all night with Task Manager running also to see if there was a memory leak. Interestingly, it was not hung when I came in this morning. The hang appears to only occur when multiple tabs are open - to verify this I just opened the page with the cycler in one tab, this forum in another, and Google in a third tab. After 10 minutes or so, with the focus on another tab, try to go back to the cycler tab and bang! I opened Task Manager but I don't see any inordinate memory usage. CPU usage does increase for that tab's process though, and apparently if I am patient enough the tab does recover.
Administrator
Registered: Aug 2008
Posts: 3382
Ah... From your description, I'm pretty sure I know the scoop.

The cyclers use requestAnimationFrame to do the cycler animation. One of the advantages of this approach is that it is easy on the cpu when the animated component is not visible (such as when it is on a non-active tab).

It seems IE (and maybe others?) are queuing the animation requests and firing them all in sequence when the element becomes visible. There's around 60 animation requests made every second, so after 10 minutes there are around 36000 animation calculations to be made. Each calculation must be followed by a re-layout of the page so that subsequent calculations are correct. This is all done on a single thread which works the cpu hard and suspends all other processing for the page until it's complete and the queued animations are caught up.

For browsers that don't make requestAnimationFrame available, good old setTimeout is used. This will keep chugging away in real time on content whether it is being displayed or not. You can break requestAnimationFrame in IE with the following script, thereby forcing it to use setTimeout. The script should be fired prior to loading floatbox.js.
<script>
window.requestAnimationFrame = null;
</script>
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
Thanks for the quick replies. I tried that workaround but unfortunately the problem persists. Is it possible to determine when the window is in a tab that does not have the focus and to suspend redraw events until the window receives the focus again?
Administrator
Registered: Aug 2008
Posts: 3382
I can't think of a hook that could be used to suspend animation requests when the page is not active.

I'll put automatic suspension in the next major release.

If you're very determined, you may be able to do something with the Page Visibility API that's implemented in modern browsers. I think you would have to do drastic surgery to the page such as removing the entire cycler div from the page when the doc goes into hiding, then rewriting and activating a replacement div when the page is brought to the foreground. Probably not worth it....
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
Thanks - I'm not that determined! I'll wait for the next release.
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
I noticed that your latest release 6.1.0 has some cycler fixes in it. Is this issue one of them?
Administrator
Registered: Aug 2008
Posts: 3382
No. The soon-to-be-released version 7 suspends animations on documents that report themselves as "hidden", but 6.1.0 does not.
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
Thank you! I will keep checking back.

Page: 1