3
\$\begingroup\$

I'm developing a game in Java for Android, using LibGDX. I'm using Nexus 5 to test my game most of the time and it works great (Minimum FPS it gets is 57 out of 60).

Recently I ran my game in Galaxy S2 and found out the FPS gets to 45-55 most of the time. I started checking what causes it using PerformanceCounter and I couldn't find the reasons that cause this slowness.

Later on I decided I'll disable everything in the game's render() and check one by one what could create this problem. I managed to get to a very minimal code in the render() and still the FPS can get to low values.

This is my render() in it's minimal form:

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 10, Rules.System.HEIGHT_TARGET_RESOLUTION - 100);
    batch.end();

I didn't give much attention to the create() because it only happens once in the beginning so I guess it's not supposed to affect.

I downloaded other games from the Play Store to my Galaxy S2 and they seem to work fine, no noticeable lags (So the device is not that bad).

BTW, I also tested my game in Galaxy S3 and it worked better but still had some lags (not as much as in the S2).

Am I missing something? Maybe you have some tips for me on this? I checked every where for documentation about performance in LibGDX but there aren't much.

Thanks!

\$\endgroup\$
  • 1
    \$\begingroup\$ "and they seem to work fine" -- are you sure they're running at 60 Hz? What if you reduced the frame rate to 30 Hz? You could achieve a constant frame rate and thus get rid of the lag! \$\endgroup\$ – Alexandre Vaillancourt Jul 22 '15 at 12:18
  • 1
    \$\begingroup\$ Well I actually read other forum discussions and some said it not recommended to intervene the FPS (I also thought about lowering it down to 30). Isn't lowering the FPS to 30 is actually getting away from the problem? (Instead of finding out what's wrong) \$\endgroup\$ – Gad Wissberg Jul 22 '15 at 12:21
  • 2
    \$\begingroup\$ By "intervene the FPS" do you mean "fix the FPS"? IMHO not fixing the timestep is the best way to have visible effects of lag. Lowering the FPS to a guaranteed timestep will remove this effect. Food for your thoughts. \$\endgroup\$ – Alexandre Vaillancourt Jul 22 '15 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.