I have been working on an Android game for the past 6 months or so, and have posted on here several times about various lag issues that I cannot get rid of.
I ended up grabbing the LunarLander example and stripping it down to its very core components to see if I could make anything at all that doesn't lag. All it really does is change the amount the canvas is translated each frame, and then draw a background onto the canvas. EVEN THIS, about as simple as you can get for a surfaceView application - stutters...
My game is a scrolling game where you continuously move up the screen (think of a flying game), but the way I am currently doing the background results in constant stuttering every second or so for about 50-100ms. This isn't game breaking, but it is very distracting and makes the game seem as if it was programmed by a complete moron (though I am starting to suspect this might be the case).
No, it is not the garbage collector, there are no new objects being created at all during the game's run loop, and the GC barely ever runs while my game is running.
I am practically tearing my hair out with frustration. I have spent over 40 hours just trying to get rid of the lag on this simple application example over the past week alone and it is driving me crazy. How can an application as simple as the one I have linked possibly have lag issues? You wouldn't think a scrolling background could get much simpler than that...
NOTE: This demonstration constantly gets about 60fps on my phone (A Motorola Milestone). Uncomment the FPS code in the example to see the FPS.
TL;DR: Extraordinarily simple program that is just a scrolling background shows stuttering. Please have a look...
Link to download simple stuttering example based off the LunarLander example: http://dl.dropbox.com/u/4972001/LunarLander.rar
If you don't have enough RAM, your computer can't process the information it needs quickly enough, which leads to overall poor performance and game stuttering.
If you don't want to lower settings, disable vsync, or buy a G-Sync or FreeSync display, there are still ways to try to reduce micro stutter. Updating to the latest graphics drivers might help (or in some cases, you might try rolling back to older drivers), though this is often on a game-by-game basis.
Texture-related settings are known to cause stutter lag if set too high for your system to cope with. Textures are everywhere in a game, and the more detailed they are, the larger the amount of data that has to be transferred back and forward on your system, and the more hitching and stuttering you're likely to get.
I have downloaded the RAR file with your scrolling background (looks like a grassy field), and installed it on my Motorolla Droid.
I can perceive no stuttering as it scrolls, I've watched it for well over a minute.
Based on your description I'd wager the Milestone hardware/platform has some weird video drawing/timing issue.
Perhaps the explanation is something along the lines of this: The Milestone's diplay refreshes at 60 Hz (just picking a number here, I don't know what it really is), and your frame rate is just slightly off that - say 63 or 57 Hz ... is it not conceivable that approx once a second the timing of your draw, and the timing of the hardware display update mismatch just enough that the background doesn't get a re-draw that one time, and has to wait until your next frame? And that occasionally the timing lines up just enough that you might miss the timing of two or three draws in a row (depending upon how far off your frame-cycle is from the actual screen refresh cycle).
EDIT: Actually, I watched it for another minute I did did see one very short (just perceivable) stutter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With