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. Dismiss Notice

Android Battery/CPU Consumption

Discussion in 'Android' started by justoon, Jan 15, 2015.

  1. justoon

    justoon

    Joined:
    Nov 7, 2013
    Posts:
    9
    Hello -

    We're in the process of building a 2D game for iOS and Android. During our Alpha testing, one of our testers noted that after playing the game for 10+ minutes the device would get warm to the touch and showed up as one of the biggest battery consumers in the summary screen.

    Sure enough, we've been able to reproduce this on various Android devices. The game itself runs smoothly, we're not seeing any pauses, stuttering or slow-downs, but seems to be a battery hog, draining approx 4% of the total battery for every ~10 minutes of play and the device gets warm.

    We've hooked up the internal profiler, the Unity visual profiler (using trial license) and monitoring via top to look at the consumption. For the most part, the game is averaging 44-50% cpu usage (looking at top). Unity visual profiler showed us that Camera > Render Transparent Geometry is the biggest consumer of CPU @ ~25%.

    To give an idea of scope:
    Our game uses skeletal sprite animations driven by Mecanim. We are also using Unity UI with Mecanim-driven animations to animate things like score and bonuses. We're using particle systems to bring the game to life. For example each enemy has fire and smoke particle systems that play when they are struck by fire. The game is faced paced but there's not any camera movement, all the action takes place with a fixed background.
    At a given point in time we have up to 15 enemies on the screen (which we cap).

    Some stuff we've done to try and address the issue:
    1. Reduce draw calls - changing our sprite characters to use z-ordering instead of order in layer and making some other adjustments we've brought our average/peak draw calls to 50/100 respectively
    2. We've ensured that our particle systems are using very simple materials and mobile shaders
    3. We've disabled animations to measure their impact
    4. We've tried disabling v-sync and capping FPS to 30

    None of these actions have made any discernible difference to the battery consumption.

    Using: Unity Free 4.6.0p1
    Devices: Nexus 7, Samsung Illusion, Motorola MotoX

    Questions:
    1. Is this just normal consumption we're seeing? We've played other games (albeit non-Unity) and they never seem to make the device get warm.
    2. If we interpret the profiler correctly, are the transparent edges of our sprites the cause of this high CPU usage? If that is the case, what solutions are there?
    3. If you've made a game for Android, what cpu usage/battery consumption have you observed ?

    Thanks for taking the time to read this.
     
  2. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    i observed the same thing and arrived to this conclusion: unity games use always the best performance they can.
    this is my thought, i hope i can be refuted.
    sorry for the bad english
     
  3. shihab37

    shihab37

    Joined:
    Jul 7, 2015
    Posts:
    28
    Justoon,
    We are facing exactly the same problem with our unity 2D game. Did you find some sort of solution to this issue?
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The issue is probably that Unity is getting better threaded so more of the phone is being used. If you think this is not the problem please file a bug report, as it's the best way to evaluate it. And vsync on is a better plan than vsync off for battery life.
     
  5. shihab37

    shihab37

    Joined:
    Jul 7, 2015
    Posts:
    28
    you mean I should set vsync as every second v blank?
    and better threaded ??? Honestly this is way above my head. could you please explain a bit