Inconsistant Browser Framerates

11 posts

Flag Post

I made a little demo program that runs fine at 60 fps when I run the swf directly in flash player, but jumps around from 30-60 fps in browsers. Do I have to just cut back on the processing and expect lower frame rates in the browser? I tested many computers and browsers, and for some reason Mozilla on my desk top ran it at 60fps, but internet explorer didn’t. Plus a friends computer (that accually has better specs) didn’t make 60 fps on either browser. Am I missing something here? I am using AS3 and CS3 to compile the swf.

Here’s a link to the demo:

http://eatjason.googlepages.com/collide.html

 
Flag Post

Thats typical and has been for the history of Flash. There are some tricks that I occasionally use, but generally developers target a specific browser framerate by publishing at a higher setting. Yes, its a pain.

 
Flag Post

small suggestion: dont upd fps counter every frame – do it every second.
what fps is set for swf?
and just for the record remember that in browser player u will always get less fps than u set (little old stuff but seems to be still current http://www.kaourantin.net/2006/05/frame-rates-in-flash-player.html)

 
Flag Post

I set it to 60 fps. Maybe I will have to add setting for if someone happens to have a browser/setup that actually maintains the set frame rate, otherwise some people would have it be too fast. I don’t see what not updating the fps counter would do, I turned it off entirely, and can tell it still falls to 30 fps. Thanks for the info.

 
Flag Post

well, why would you have to have an FPS of 60, ussualy maintaining at least 45 is decent. I say, unless what you doing requires it, dont fret too much over it.

 
Flag Post

I guess I need to test lower frame rates more, but I was mostly concerned with its inconsistancy. I was afraid it was something I was doing, and if I set at 30 it would be something like 10-30 fps. I’m going to try locking at 30 fps, but then having to world updates each frame. The simulation is slightly smoother with 60 fps. Plus I made some snes style tile and sprite engine, usually snes was 60 fps, but I guess that will be fine with 30 with 2 updates as well.

*EDIT: That does seem to be the case, that when I lower it to 30 fps, it jumps around from 13-29 fps. Which is really bad. Even when I just leave it at one world update per frame. I guess I have to do some testing without any logic going on.

 
Flag Post

He’s telling you to change your fps counter because its likely inaccurate (he is right about not updating it every frame). Setting the framerate to 30 is not going to produce a playback of 13fps unless you are doing something overly cpu intensive. Generally, setting to about 35fps will produce a 30fps playback, give or take a little.

 
Flag Post

This time I had each frame counted until the timer got larger than the start time by one second. It seems to stay between 25-35 now, 35 only happening for a brief moment. Now I’m really curious as to how I somehow got my Mozilla to play them at the proper framerate (stays consistently at 35) It only works on this computer, and not even my new one that is 10 times faster than this one. What kind of settings would make the swf play at the proper speed? I’m actually noticing that every game on here runs seemingly a bit too fast in this browser and this computer…..

 
Flag Post

Firefox and IE differ in their implementations of the player, so variations in framerates are different between the two. Changing the window mode setting in the html will often produce consistent and full framerates, but it should be used with discretion as it can sometimes cause more problems than it fixes – like messing with mouse and keyboard events in some browsers.

 
Flag Post

Given that different browsers yield different frame-rates, my suggestion is that you set the frame-rate quite a bit higher (2-4 times your desired rate) than what you want, track the time using getTimer(), and don’t draw on the screen at all if it returns too early. But this won’t work if your frame-rate is too high – I’d suggest you target 30fps, max.

 
Flag Post

Tracking with getTimer() is clearly the way to go. I can get my 60 fps without even skipping rendering frames. I use all bitmaps, so rendering happens really fast. One or two computer browsers do something strange and make it go 12-25 fps, but most seem to keep up. Even with 12-20 fps, my game logic always keeps up at 60 fps, although it gets choppy at that point. I have the stage frame rate set to 1000 fps, just to get it to call the function as fast as it possibly can.

http://eatjason.googlepages.com/monkey.html