question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Large delta after pause/resume (Android)

See original GitHub issue

If a game (or in my case a live wallpaper) is paused for a long time, after resuming, Gdx.graphics.getDeltaTime() will give the delta of the entire pause duration. This causes freeze/stutter on resume as the game tries to process possibly hours worth of delta.

Adding this to onDrawFrame before the delta calculation in AndroidGraphics/AndroidGraphicsDayDream/AndroidGraphicsLiveWallpaper should fix this I believe.

if (lresume)
    lastFrameTime = System.nanoTime()

I’m currently using this workaround

private boolean resuming;

    public void render()
    {
        float delta;
        if(resuming)
        {
            delta = 0f;
            resuming = false;
        }
        else
        {
            delta = Gdx.graphics.getRawDeltaTime();
        }

        ...
    }

    public void resume()
    {
        resuming = true;
    }

However, now I can’t use the smoothed delta because it includes the large delta from the pause.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hneuercommented, Jan 15, 2014

Look into #1133, this is maybe what you need.

0reactions
chandujrcommented, May 23, 2017

This bug still exists in iOS. I’m porting my game using Intel MOE and the delta value adds up when paused and resumed. I have a countdown in my game depending on the delta time and this bug is causing problems.

Edit: I guess capping is a workaround for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LibGDX stop time counter on pause - java - Stack Overflow
Because delta is now 0 the timer will not increase and not increase until the game state it back to GAME_RUNNING after resume()...
Read more >
Pause or resume data for a Flexible group plan - Google Fi Help
Under "Your group plan," select Manage Plan. Select Pause Data. View a tutorial on how to pause data for an account member on...
Read more >
Uploading and copying objects using multipart upload
Pause and resume object uploads – You can upload object parts over time. After you initiate a multipart upload, there is no expiry;...
Read more >
How Do I Pause a Recorded Activity? - Garmin Support
Select Garmin watches feature Auto Pause, which will pause the timer ... Select watches come with the Resume Later function, which allows you...
Read more >
The right way to pause a game in Unity - Game Dev Beginner
deltaTime when moving objects. When pausing the game using the time scale method, instead of the time since the last frame, Time.deltaTime will ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found