Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Optimizing battery-life consumption of a mobile game by limiting frame rate

Discussion in 'General Graphics' started by Kazeon, Aug 30, 2020.

  1. Kazeon

    Kazeon

    Joined:
    May 22, 2017
    Posts:
    41
    Hello everyone. Let's just get straight to the point. I'm currently developing a mobile game. It's a simple crossword game, which only use UI objects. And as a crossword game, people will tend to spend a lot of time solving the puzzle. So I recon the game must have very minimal battery-life consumption. So far here are my approaches to achieve it:

    1. Disable animators when not needed
    2. Disable scripts with Update/FixedUpdate when not needed
    3. Being very nitpick in coding the game (using the most efficient practices as possible)
    4. No custom material of any UI element
    5. Delete all camera objects!

    But even after all that, I still haven't reached satisfactory result. The game still consumes ~2% of my phone's battery every 5 minutes even when the game is totally idle and static (stays at title menu), which is totally no good. I made sure that there is no Update/FixedUpdate/Animation running at the title menu. But still the game saps my phone out of its life!

    But today, I think I thought of a little interesting idea: which is limiting the frame rate when there is no player activity (by using Application.targetFrameRate btw). I limit it down to 7 FPS (can't go any further because UI interaction seems to depend on frame update) and reset it back at -1 (using hardware's default) when player interacts with buttons or some other components. At first I thought this is the best idea I'd produced in a while, and I thought it will truly minimize battery-life consumption as the game will draw/render scene less often. Of course it comes with some hiccups and other user-control issues, but who cares about user right? Annnd, well, after testing, the result is... it gives little to no improvements at all!

    I'm confused, why it doesn't work? Can anyone explain why? Does Unity's UI already doing this out of the box by not refreshing static part of the screen? If that is the case, does anyone have any idea of what else can I do to optimize my game's battery consumption? Have I picked the wrong game engine for this game concept?

    I don't know how to profile the game too, as it runs at stable 1400 fps+ on PC, everything seems running at its best.
     
  2. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    479
    You could try to use https://docs.unity3d.com/2019.3/Documentation/ScriptReference/Rendering.OnDemandRendering.html in combination with targetFrameRate.

    Afaik Unity UI has no optimization to render only what changed.
    Some GPUs (e.g. arm Mali) have an optimization to avoid updating the framebuffer when nothing in the tile changed. This saves power but it will still do the actual rendering.

    I would have expected to see a significant improvement when you render at only 7fps.

    One thing that might limit you is the fact that Unity tries to make sure that Unity scripting main and render threads run on big CPU cores. In your case it would most likely be better to run on little cores. There is currently no good way to configure this.
     
  3. Kazeon

    Kazeon

    Joined:
    May 22, 2017
    Posts:
    41
    Thank you very much! I will learn and implement it soon. And I will get back here with the result. Thanks again.
     
  4. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    745
    A good way to identify what is might cause your power consumption is to use the Unity profiler and see what is going on under the hood. Making a game in Unity UI only, is suboptimal, as it has a lot of performance bottlenecks. You can find guides on optimization here: https://docs.unity3d.com/Manual/BestPracticeGuides.html especially Optimize UI!

    Also, depending on your target platform (e.g. Android Samsung), you might also want to look into what Adaptive Performance does and you might get some ideas what do you can do: https://forum.unity.com/threads/adaptive-performance-package.652306/