Interpolation with Libgdx (UPDATE: openGL render problem)

Anything libgdx related goes here!

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby Sharp » Tue May 21, 2013 8:33 pm

YaW wrote:Nope, we have desisted. We've tried everything, using cpusync, vsync with all diferent values (and the new BackgroundFPS and ForegroundFPS).

The weird thing is that the game in Mac works very very smooth, so I guess there's some problems with the Windows backend of lwjgl... Also on Android, we have some devices which runs the game smoothly and some others (like galaxy s2) that have some hiccups...


And maybe with an older release of lwjgl?
Image
Sharp
 
Posts: 47
Joined: Tue Apr 23, 2013 9:50 am

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby davedes » Tue May 21, 2013 11:02 pm

Did you try the test I posted? To be sure that the problem is related to LWJGL and not LibGDX? If that's the case then the discussion should be moved to the LWJGL forums.
davedes
 
Posts: 434
Joined: Thu Oct 11, 2012 7:51 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby tiarsoft » Wed May 22, 2013 3:12 am

I do not think the problem is with LWGL cause as they the problem in android as me. Sometimes is very smooth running at 60fps and sometimes it has hiccups running at 60fps
Do you want to learn Libgdx? I wrote some tutorials in Spanish.
¿Quieres aprender libgdx?. Sigue mis tutoriales en Español.
http://tutoriales.tiarsoft.com
tiarsoft
 
Posts: 144
Joined: Tue May 08, 2012 12:47 am
Location: Mexico

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby imagnity » Tue Mar 18, 2014 12:54 pm

For the last two years, I have been making a game, on and off. I went back to this stuttering issue several times. I concluded with these-

1. It depends on the device, not necessarily a "ultra-fast modern" device wouldn't have problem with this. I have borrowed many Android devices (around 30) and saw the problem in low-end and high-end both. I have also tested two other games (Jetpack Joyride and Angry Birds) on all those devices. Angry Birds suffers from that a lot. For some reason Jetpack never showed me significant stuttering except a) In low end devices it sometimes misses touch event, b) in low end devices it stutters a bit when too many particles are being rendered say when you use rainbow jetpack. Those guys are rock solid.

2. Just using/multiplying delta time often causes the issue as some update/draw on your specific app/game on a specific time may take more time and hence the difference gets bigger for the next update which makes the entities stutter or as if jumped.

3. Samsung Galaxy Nexus (9250) is a great phone for games. It's a great phone with very poor battery and sound system. If your game stutters on that phone, let me know.

4. Using box2d with interpolation is a great idea for physics based game. This may lessen the fps, but will reduce the stuttering in a big deal.

5. All other performance tips like "no new object on update/render", less "floating point", "less trigonometry", "less texture binding" etc help the game run better.
Check out my games - http://www.imagnity.com/games/
imagnity
 
Posts: 197
Joined: Mon Mar 25, 2013 6:27 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby dzik » Sat Jul 12, 2014 11:56 am

That is a really nice research you have done! Thanks for all the info.
I'm experiencing the same problem. I found some other posts complaining about it as well.

Recently I started developing a new game with 1.1 Ligdx (maven project). It's box2d based. There are boxes flying around being dragged to the center of the screen, one texture in assets. I tested it on 3 devices. Samsung Advanced with 2.3.6 Android and 2 no-name tablets with 4.1.1. Android. Here are my observations and some data from USB debugging:

1. There are small hiccups occurring every once and then on all 3 devices.
2. The interesting thing is one major jerk that seems to happen deterministicly at 355th render() call! The drop is from 61 to 53 frames. There is no gc in the process at this moment. I'm also doing all 'new' initialization and Array 'inflating' before rendering, so there is nothing being allocated. I looked at full logcat and there is nothing suspicious, either. I checked my render loop iteration in millis and there is no significant difference for 61 and 53 frames. It seems the code runs the same but the drop occurs. I tried reducing FPS to 50 via Thread.sleep(). Naively I thought the 10 FPS buffer would take care of FPS drop cases but this time it droped to 43 FPS :). I though the issue was related to box2d. I commented out world.step() and made the boxes fly without physics. Same result for hiccups.
3. This point is less important but for my Samsung with 2.3.6 Android the game sometimes starts and runs at 61 FPS (except for the major drop and 1-2 frame fluctuations) and sometimes starts and stays at around 25 FPS for no particular reason. I profiled both cases and looked at time per call. It is not the entire application that runs slower. Major differences are for box2d.step() and rendering calls. The rest of the methods exectute roughly at the same speed for 25 FPS and 61 FPS.

I have no idea where the hiccups for point 1. and 2. come from. Not sure if it's Ligbdx, Java or the Android itself. Desktop runs smoothly.
Anybody checked if the problem occurs with other game frameworks as well?

Libgdx devs, I can share my game code with you if you would like to take a look at the cases I described.
dzik
 
Posts: 57
Joined: Wed Oct 03, 2012 4:54 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby deepmast » Fri Sep 26, 2014 8:35 pm

I think, I have the same problem

First I see viewtopic.php?f=11&t=7934
But If I understand correct its similar topic and the discussion is here?

I have not smooth movement on some screen resolutions or on some unstable fps (example 58-60)

I try to test some simple code:

Entry point
Code: Select all
public static void main (String[] argv) {
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    //if 59 replace to 60 movement is smooth
    config.foregroundFPS = 59;
    config.backgroundFPS = 59;

    config.width = 300;
    config.height = 400;
    config.title = "Title";

    new LwjglApplication(new GameManager(), config);
}


Game manager
Code: Select all
public class GameManager extends Game {

    public GameManager() {
        super();
    }

    @Override
    public void create() {
        setScreen(new ScreenManager());
    }
}


ScreenManager

Code: Select all
public class ScreenManager implements Screen {

    private ShapeRenderer shapeRenderer;
    private Viewport viewport;

    private float yPosition;

    @Override
    public void render(float v) {
        //act
        yPosition += Gdx.graphics.getDeltaTime() * 400;
        if(yPosition > 1280) {
            yPosition = -240;
        }

        //
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        Gdx.gl.glClearColor(0, 0, 0, 1);

        shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);

        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setColor(1, 0, 0, 1);
        shapeRenderer.rect(10, yPosition, 240, 240);
        shapeRenderer.setColor(0, 1, 0, 1);
        shapeRenderer.rect(1, 1, 718, 1278);
        shapeRenderer.end();
    }

    @Override
    public void resize(int i, int i2) {
        viewport.update(i, i2, true);
    }

    @Override
    public void show() {
        shapeRenderer = new ShapeRenderer();
        batch = new SpriteBatch();
        viewport = new ExtendViewport(720f, 1280f, 720f, 1280f);

        yPosition = -240;
    }
}


And rectangle has some lags
If fps 60 it move smooth in some resolutions and has some different lags on other resolutions

On android devices on sony experia sp and htc one s movement not smooth (fps 56-60). On nexus 7 it more smooth, but sometimes lags.

onCreate
Code: Select all
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new GameManager(), config);
    }


Before this example I try to optimization my game.
But this example has not any problems with performance, I think?
But I can't understand why it looks like slow game.

With texture situation identical.

Has anyone found the solution?

P.S. Sorry for my language, I can try to re-translate bad sentences.
deepmast
 
Posts: 1
Joined: Fri Sep 26, 2014 8:12 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby alonemamont » Fri Feb 27, 2015 7:50 pm

Hi there! Had somebody found a solution of this problem finally?
alonemamont
 
Posts: 1
Joined: Fri Feb 27, 2015 7:31 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby Teyn » Mon Aug 10, 2015 10:09 pm

Yup, has somebody found the solution?


Just running this:
Code: Select all
public class MyGdxGame extends ApplicationAdapter {
   SpriteBatch batch;
   Texture img;
   
   private float x = 0;
   
   private OrthographicCamera cam = new OrthographicCamera();
   
   @Override
   public void create () {
      batch = new SpriteBatch();
      img = new Texture("whateverImage.png");
      
      cam.setToOrtho(false, 1280, 720;
      cam.update();
      batch.setProjectionMatrix(cam.combined);
   }

   @Override
   public void render () {
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      
      x -= 5f;
      
      if (Gdx.input.isButtonPressed(0)) x = 0;
      
      batch.begin();
      batch.draw(img, x, 0);
      batch.end();
   }
}


isn't completly smooth, especially the html version.

Also, sometimes when I run this application, it runs at 60FPS but looks like it's running at 20 FPS and sometimes It's quite okay. There has to be problem in the libGDX's source or in the LWJGL source and I hope it will get fixed.
Teyn
 
Posts: 6
Joined: Mon Dec 22, 2014 7:25 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby exq_bytes » Sun Sep 03, 2017 9:30 am

I've come across this issue with an Alcatel OneTouch Pixi 3 (8). Yes, I know it's a crappy old dual core device, but other simple sprite based games with particle effects (such as Grid Runner and Super Ox Wars by Llamasoft) run perfectly with no stutter. Those games were written in C++ and use their own game engine. And besides, from what imagnity says above, the problem is not related to device performance.

I decided to make a small test using SDL2 in C++ (see here: https://www.reddit.com/r/gamedev/commen ... tuttering/), and the stuttering is still present when moving only 6 small sprites across the screen, which could mean that libGDX and SDL2 are doing something very similar at a low level and have the same problem. I have tried literally everything in both libGDX and SDL2 - all combinations of frame-dependent movement, frame-independent movement, framerate capping, vsync on/off, but nothing fixes the issue. In fact, most so-called solutions make the stuttering worse.

Is anyone developing on similar older devices without these issues? If so, please list them!
exq_bytes
 
Posts: 344
Joined: Sun Jun 10, 2012 5:58 pm

Re: Interpolation with Libgdx (UPDATE: openGL render problem

Postby evilentity » Mon Sep 04, 2017 12:02 pm

But... but... c++!
Try more sprites. 10000 or something.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

PreviousNext

Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest