Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Game gets slower over time (half FPS)

Discussion in 'Android' started by Irrgeist, Jun 10, 2018.

  1. Irrgeist

    Irrgeist

    Joined:
    Jul 9, 2015
    Posts:
    28
    Hi,

    my prototype runs fine in the editor (except of some micro stuttering). On my Nexus 5X it runs fine to. 60 FPS (some stuttering, okaaay...). I am using Unity 2018.1.0f2.

    Here are the FPS upon start (on my device):

    After about 30 seconds in game:

    Here are my device specs:

    I set Application.targetFrameRate = 60; And use medium Android profile, happens also on low Quality profile.

    When I close the game and restart it directly, it's FPS are slow from the start. If I wait some minutes the FPS start with 60 FPS.

    I connected the Unity Profiler to ADB, here's a screenshot of when the FPS dropped:


    I also saved the data, you can download them here and load them in your profiler if you like:
    https://drive.google.com/file/d/1AZqe3K5veP0j5wWhfhtPf2HrvJgu8WyW/view?usp=sharing

    I am not quite sure how to interpret the data I got from the profiler. The CPU seems to have much more to do.

    My Draw calls are at about 20. All objects get destroyed and reinstantiated (endless runner). about 68 GameObjects in the scene, no audio

    Hope someone can give me some advice.
     
    Last edited: Jun 10, 2018
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,419
    Firemaw and Irrgeist like this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    Yeah, sounds like throttling to me as well.

    It seems these days throttling on all kinds of devices (phones, laptops etc) is very acceptable, which is very sad.
     
    Irrgeist likes this.
  4. Irrgeist

    Irrgeist

    Joined:
    Jul 9, 2015
    Posts:
    28
    Hey,

    So yeah ... i've put my phone into the freezer and it got better. Without the freezer it varies from 30-60 FPS (which makes sense)...then I've put my phone onto a cooling pad and had no more FPS drops. So yes, it seems to be the CPU throttling.

    Are there any recommended settings for mobile physics? I guess that's my bottleneck, even though I just "push" some kinematic backgrounds and obstacles to the left (with position.x, not adding a force) and throw some bouncy balls to destroy the obstacles. Doesn't sound like much.

    Thank you very!
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,419
    According to Epic Games, their approach to achieve a stable frame-rate was to optimize the game to run at 60fps and then clamp it to 30fps via vsync (in Unity QualitySettings.vSyncCount=2). So the device would be half the time in idle and has enough time to cool down.

    Running a mobile game at full speed, such as 60fps, just heats up the device, which tends to be uncomfortable for consumers and drains the battery very fast.

    According to your Profiler screenshots, it looks like the bottleneck is rendering. I guess if you expand that node, it shows "WaitForGfxPresent", which hints that the CPU is waiting for the GPU. In that case the game would be GPU bound and optimizing physics etc don't make your game run faster. You would need to optimize on the GPU side, shaders, fewer overdraw, smaller resolution, etc.

    Here are a few links regarding (mobile) optimizations...





    Optimizing graphics performance
    https://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html

    Optimizing Unity UI
    https://unity3d.com/learn/tutorials/topics/best-practices

    Spotlight Team Best Practices: Optimizing the Hierarchy
    https://blogs.unity3d.com/2017/06/2...-the-spotlight-team-optimizing-the-hierarchy/

    10000 Update() calls
    https://blogs.unity3d.com/2015/12/23/1k-update-calls/

    ParticleSystem Performance – Culling
    https://blogs.unity3d.com/2016/12/20/unitytips-particlesystem-performance-culling/

    Spotlight Team Best Practices: Collision Performance Optimization
    https://blogs.unity3d.com/2017/07/2...practices-collision-performance-optimization/

    Optimizing Physics Performance
    https://docs.unity3d.com/Manual/iphone-Optimizing-Physics.html
     
    RomBinDaHouse, senkal_ and JuliusM like this.
  6. Irrgeist

    Irrgeist

    Joined:
    Jul 9, 2015
    Posts:
    28
    Hi,

    wow thank you. I will dig through all your links :) I am atm trying to remove everything from my game. Even the textures. Using no Physics or decreasing the fixed timestep to 0.05, still gets down to 30 FPS ... I will try the vSyncCount as well.

    Maybe my Nexus 5X is just no good at games. Into The Dead 2 seems to run smoothly on my device though (except for the loading times). I'll keep trying and post the results, if I get any x_X
     
  7. Irrgeist

    Irrgeist

    Joined:
    Jul 9, 2015
    Posts:
    28
    Okay, it must be the Nexus 5X and the summer temperatures. Created a new project, selected low quality settings. it only contains a spinning cube with an empty mobile/diffuse material. After a while it drops down to 39 fps. Too bad, takes away all the "fun" of mobile development. Maybe I have to adjust my game to good 30 FPS game play.

    Thanks for all the help. Will still try to optimize it as much as possible, so it maybe even runs on a Samsung A5. The Game "Cube Dodge" from Matthew Palaje runs fine on both devices, so it should be possible to get there too (it's made with Unity).
     
    Firemaw likes this.