Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I was about to publish my app but I tested it on a cheap Android tablet. It's anew tablet, but a cheap / low spec one.

The game runs, but is pretty choppy. I'm made a discovery that quite surprised me.

The V-Sync seems to be limiting the onDrawFrame calls to 30 times per second. Is this 'normal'? I though 60 was the 'standard' for V-Sync?

I've tested this so far on 3 devices:

  • Nexus 10 Tablet. V-Sync limiting to 60FPS (which I though was a standard thing on new devices)
  • Galaxy Ace Handset (Version 1 - very old) - No VSync limiting.
  • XTouch Android Tablet - VSync limiting to app to 30 FPS

So my app runs 'OK' as in it doesn't slow down, it's using a fixed time-step (see loop below).

If I just put something like:

Logic();
Render();

Then everything runs super-slow and indeed I get around 30 fps. Putting it back to my normal loop, the game runs at the correct speed but 'jerky'/'choppy'.

I just want to say this is nothing to do with the rendering or logic not being efficient enough. I've taken out a log of the drawing from my game and it still runs like a dog on this tablet :-(

I've run some commercial games (Angry / Flappy Bird(s)) and they run super-smooth.

The Game-loop has definitely been the most challenging aspect of my coding.

Would be grateful if someone could clear up my confusion about V-Sync and how it affects my game loop.

Please Note, I've already read Fix your timestep! and mysecretgarden and against the grain (obviam.net) as well as various other 'game loop' tutorials. None of these really help in my situation

My Game Loop

        while(System.currentTimeMillis() > nextGameTick && loops < maxFrameskip){
        updateLogic();
        nextGameTick+=skipTicks;
        timeCorrection += (1000d/ticksPerSecond) % 1;
        nextGameTick+=timeCorrection;
        timeCorrection %=1;
        loops++;

    }

    render();   
share|improve this question
    
V-Sync synchronizes the buffer swapping with the refreshing of your display. If the display refreshes at 30hz, that's what V-Sync will synchronize your application at. –  Ben Jul 2 at 0:17
    
Thanks @Ben, appreciate your comment. Do you know how best to deal with Android devices that have such a low VSync threshold? I've written my app to run at 60fps (Well, actually 60 game tics per second, but render as fast as possible), so I'm guessing that when onDrawFrame is only called 30 times per second, that's where my problems begin (although I'm confused as to why as my game loop has a while-loop so I'm still actually getting 60 ticks as far as I can tell) - super confused. Thanks. –  user22241 Jul 2 at 0:23
    
Are you sure your use of System.currentTimeMillis() is correct? This is my gameloop: pastebin.com/zFDcTYQS Every iteration of the loop, I remember the time of the start of the loop, and then I add the time that iteration took to the "timeBehind". Once timeBehind hits a threshold, I start updating. If one draw takes 5 seconds, I'll do 5 seconds worth of updates before I draw again. If it takes less then the threshold, I'll just draw again. –  Ben Jul 2 at 0:35
    
Thank @Ben, I think the timing in mine is correct. To be honest, I've changed my loop so many times with similar results, I'm not even sure where I am now. I'll take a look at your code. Really appreciate it. –  user22241 Jul 2 at 0:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.