Intermittent stuttering/jerky/twitchy framerate


(Helmi) #1

Hey thar. So I’ve been learning both FlashPunk and AS3 at the same time (great idea I know) and I’ve run into the first problem that I haven’t been able to solve simply by praying to Google.

Here it is:

No matter what I do, the framerate seems to “stutter” for random periods of time. It feels “silky smooth” at 60fps for several seconds, and then suddenly it looks like it’s 30fps for some time, and this goes back and forth randomly, with no apparent rhyme or reason. Even stranger, FP.framerate always shows ~60 even when it feels like 30.

Tracing “FP.elapsed” each frame:

0.016, 0.016, 0.03, 0.004, 0.016, 0.016 (etc)

or another example:

0.016, 0.016, 0.034, 0.006, 0.01, 0.018, 0.028, 0.006, 0.024, 0.008, 0.024, 0.01, 0.016, 0.016

Normally I would assume that it’s the fault of my computer, but this is super simple, and I have a decent computer (3.07GHz / 12GB ram), and it looks the same on an old computer (2GHz / 2GB ram) and if anything it looks better on a terrible old laptop (1.7GHz / 504mb ram). The laptop has crazy screen tearing but not much visible stuttering.

Also I’m testing this in a browser, exported in “release” mode, with the FlashPunk console disabled. The game uses a variable timestep. My movement code is basically x += speed * FP.elapsed

I’m completely at a loss as to what the issue could be. I can’t imagine that this is “just how Flash works”, because this stuttering looks almost “broken” to me. In a different thread, someone posted an extremely simple test, and to me it stutters almost as much: http://www.dreamspike.com/red/testplane.swf

Here’s my own simple test file (WASD to move the object - don’t press Z or the screen gets cluttered) http://50.16.187.43/fl/VARIABLE-60.swf

So… what the heck? Do you see similar intermittent stuttering? Do I just ignore this and try to work around it? Or is this some known issue? (In the game I’m actually working on, I’m trying to quickly scroll a large map by moving FP.camera while adjusting for FP.elapsed, and it looks terrible.)


(Bora Kasap) #2

your link to VARIABLE-60.swf is not working

It’s just happened to me last night. I tried things but nothing worked except one thing

  • i was used a full red red sprite
  • then i thought about the “the red”, human eye works hard to see the red, i’ve changed it to white sprite and it’s better now.

ALSO(Actually that should be your real problem): Read the conversation HERE


(Jacob Albano) #3

I don’t think we can really say “use red instead of white sprites” for the solution here. :stuck_out_tongue:

As for me, your demo stutters, but the other one doesn’t. I’m using Firefox, so this isn’t a Chrome issue, although that’s probably worth looking into as well. I don’t see this problem using fixed-framerate mode in my projects, but then again I’ve never used variable-framerate so I can’t really compare them.


(Helmi) #4

Dangit. That’s not what I want to hear, but at least if only mine stutters, it means I’m doing something wrong and thus I should be able to find out what.


(Zachary Lewis) #5

That’s what variable time does. The timestep each frame is variable. Computers are always doing billions of things, so it makes sense things would fluctuate.


(Helmi) #6

That’s interesting. So I guess that means that the varying FP.elapsed was unrelated to the stutter? I assumed it shouldn’t be varying by as much as 0.03 (30fps) to 0.004 (250fps), but now I’m wondering if the framerate is really suffering at all, or of it’s just something to do with vsync. The framerate displayed is usually ~60 even when it feels like half of that for several seconds at a time.

Here’s what I’m working on, with placeholder graphics (A/D to scroll) http://50.16.187.43/fl/no-html-wrapper.swf

If I put it in an html wrapper with “wmode = direct”, the stuttering almost completely disappears, with only occasional hiccups: http://50.16.187.43/fl/d/testing-wmode-direct.html This is supposed to be a fix for vsync/screen tearing issues. Does that mean it’s actually vsync and not a code/fps issue?