Jump to content
Search Community

Flash 10.1 in hidden browser tabs

jedrichards test
Moderator Tag

Recommended Posts

Hi Jack

 

I'm noticing some rendering problems when my Flash is left running in a hidden browser tab. The rendering problems centre around tweens seemingly sometimes not starting, and sometimes not completing. I'm using TweenLite 11.39, I'm not 100% whether the problems are in my code, or yours, but I think its due to the large internal changes to timing in Flash 10.1 when in hidden tabs. See:

 

http://blog.kaourantin.net/?p=82

 

Just thought I'd check with you to see what you thought about these changes. As far as you know does TweenLite's timing engine perform robustly when left running in a hidden tab under Flash 10.1? In your experience what kind of timing code could potentially fail when running in a hidden tab? I'd imagine anything running on a timer or setInterval could potentially get out of sync with things when the movie is throttled down to 2fps ... this change to the Flash Player sounds well intentioned but I can imagine it breaking a lot of Flash!

 

Thanks!

 

Jed

Link to comment
Share on other sites

Nope, I'm not aware of any problems that FP 10.1 causes with TweenLite/Max - they're built to be pretty flexible in terms of fps. The default timing mode is seconds which means that even if your frame rate drops significantly, your tweens should still have their timing honored (the only limit/dependency being the potential lag between updates caused by the dropped frame rate). If you have tweens with useFrames set to true, obviously those would slow down during the 2fps hidden state, and the same would happen for all MovieClips in the swf - this isn't a problem specific to TweenLite/Max.

 

If you've got a sample FLA that you'd like to post for review which demonstrates funky behavior that you believe is caused by a bug/problem in TweenLite/Max, I'd be happy to take a peek.

Link to comment
Share on other sites

Thanks Jack, I'll see if I can cobble something simple together. Hopefully in doing so the problem will present itself.

 

In Tinic's post on kaourantin.net he says that [as well as the frame-rate dropping to 2fps] "timers (AS2 Interval and AS3 Timers) are clocked down to 2 a second." So are you saying TweenLite is immune to this throttling and somehow maintains its timing even when throttled? Even its onUpdate and onComplete events firing accurately and so on?

Link to comment
Share on other sites

In Tinic's post on kaourantin.net he says that [as well as the frame-rate dropping to 2fps] "timers (AS2 Interval and AS3 Timers) are clocked down to 2 a second." So are you saying TweenLite is immune to this throttling and somehow maintains its timing even when throttled? Even its onUpdate and onComplete events firing accurately and so on?

The GreenSock platform doesn't use any Timers or setIntervals whatsoever. And no, I didn't mean that TweenLite is completely immune from being affected by kicking the framerate down to 2fps - I just meant that it's built so that when the updates do happen (on the frame renders), the timing of the tweens is honored. For example, let's say your swf typically runs at 30fps and you start a 1.6-second tween. It'll get updated 30 times per second (unless the CPU bogs down of course) which means it'll render 48 times (1.6 seconds x 30fps). If, however, the fps drops to 2, that same tween will only get rendered 4 times and each time it renders, the timing will be exactly what it should be. In other words, 1 frame after creating the tween, it will render the tween as though it is at exactly 0.5 seconds. Another frame later, it'll render it at 1 second. The 3rd time it renders at 1.5 seconds and then the final render at 2 second will trigger the onComplete. It would be absolutely impossible for it to force a custom update at 1.6 seconds which lies between the frame renders of 1.5 and 2 due to the 2fps frame rate. But when the tween renders, it is exactly where it should be in terms of timing/position/progress. The only thing that varies is how often the updates run.

 

And for the record, all the tweens are dynamically interpolated, so even if the fps goes down and up many times, it won't change the accuracy of the tween renders when the updates do happen. In other words, is is NOT as though TweenLite/Max says "well, at 30fps this tween should get rendered 48 times, so let's pre-calculate all those renders now and iterate through them on each frame". That would cause all sorts of trouble. Instead, TweenLite/Max just figures it out on the fly and you can render a tween ANY time and it will be extremely accurate.

 

Make sense now?

Link to comment
Share on other sites

Right, so the actual updates/renders are slaved to the frame-rate, and when they do occur (i.e. when entering a new frame) their results are calculated via an interpolation of the progress based on the time elapsed since the start of the tween, independent of any throttling? If I got that right, its useful to know!

Link to comment
Share on other sites

Right, so the actual updates/renders are slaved to the frame-rate, and when they do occur (i.e. when entering a new frame) their results are calculated via an interpolation of the progress based on the time elapsed since the start of the tween, independent of any throttling? If I got that right, its useful to know!

Exactamundo. You've got it right.

Link to comment
Share on other sites

Hey

 

I've managed to track down the issue, and it seems to revolve around using yoyo:true and the onRepeat callback. I'm not sure what's causing the issue. I've knocked up a quick Flash Builder 4 project that hopefully demonstrates it. The code comments should be fairly self explanatory.

 

[Link removed because it contained a .swc with members-only bonus classes]

 

If Flash Builder 4 is no good I can make an FLA instead.

 

Thanks very much.

 

Jed

Link to comment
Share on other sites

Aha, thanks so much for putting the example together. It helped identify what was going on very quickly. Let me explain...

 

Your tween's duration was only 0.35 and you utilized an onRepeat and yoyo (nothing wrong with any of this). However, when the tab went inactive, Flash dropped to 2fps which means things were updated every 0.5 seconds. Remember, your tween was only 0.35 seconds long, so that means between updates, an entire tween cycle would have completed and started coming back. In TweenMax, there was code that basically prioritized completion code, so if the tween completed, the "else if it repeated..." never ran. I fixed that in the latest release, posted a few minutes ago. According to my tests, it's all working perfectly now even when the tab is inactive.

 

Again, the only time you'd ever see this behavior (before the fix) was when your tween's duration was less than 0.5 seconds and you had an onRepeat - when it completed it would skip the onRepeat.

 

Snag the latest update at Club GreenSock member, log into your GreenSock account at

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.
×
×
  • Create New...