Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird stuttering issues that I cannot get rid of (full source included)

Tags:

java

android

I based my game off the lunarlander example and have been having stuttering issues since I first started making it. Nothing I have tried has gotten rid of them so I have gotten to the point where I have spent a few hours creating a stripped down version of the lunarlander example, and put a simple scrolling image in to show the stuttering. NOTE: it is not related to the garbage collector. If you think it is, just look at the log, the garbage collector runs no-where near as often as the stutter appears.

The image that scrolls down the screen stutters approximately every second for about 1/10th of a second on my phone (Motorola Milestone, 2.2). This kind of stuttering does not exactly completely destroy gameplay, but it is very distracting and frustrating. My game also involves a lot of fast scrolling and quick movements so it is generally more obvious there.

If any of you have the time could you take a quick look at this eclipse project and see if:

  1. It stutters for you on your phone (look closely as it scrolls, it has a small hitch every half second to second and a half)
  2. If you can see any way to fix the stuttering

I am hoping I simply have a retarded line of code that is causing this whole thing without me realising. I just can't believe that even after stripping out this much it still has the exact same amount of stutter as my full game with 1000 objects, especially since it runs at a solid 60fps on my phone.

EDIT: Have profiled my game on Traceview, it seems fine.

Source download link: http://dl.dropbox.com/u/4972001/LunarLander.rar

like image 407
Smills Avatar asked Feb 02 '11 20:02

Smills


People also ask

How do you get rid of stuttering Elden Ring?

Why Is Elden Ring So Choppy? To fix Elden ring, FPS drops, modify the Nvidia Control Panel Options. Please navigate to the Nvidia Control Panel > Manage 3D Settings > Shader Cache Size and set it to Unlimited. After that, see whether you're still experiencing stuttering or frame dips in Elden Ring.

What is FPS stutter?

What is Game Stuttering with FPS Drops. It's a rendering issue where content on your screen changes all of a sudden. This can happen for many reasons, but, if the GPU takes longer to render a frame than expected, it might even skip the frame or result in lag. This is easily noticeable during multiplayer games.

What causes micro stuttering?

Micro stutters occur when the next frame is not ready to be displayed when it is supposed to be displayed. And this can happen due to a lack of processing speed, outdated GPU drivers, lack of storage space, poor system optimization, and not meeting the game requirements.


1 Answers

I tried it on my phone (nexus one), it was the same for me.

I made a few changes which made it better for me:

  1. Instead of declaring new variables every time during loop, i declared the as properties of the class

    Canvas c = null; // becomes

    private Canvas c;

    // in the loop now just use

    c = null

Do this for all the variable you declare over and over again in the doDraw and updatePhysics function.

  1. instead of increasing the viewY until forever, i just put a little if statemant

    if(viewY > mCanvasHeight){

      viewY -= mCanvasHeight;   
    

    }

I am not sure if it's working 100% now but seems much better to me.

like image 133
Tosa Avatar answered Nov 15 '22 12:11

Tosa