0
\$\begingroup\$

i make a simple 2d scene in unity 2017.3.1f1 (only 5 sprite renderer). I realized that when my Android device's battery is under 20 %, the frame rate will be 60 to 30. I did all the optimizations I heard, like:

DynamicBatching, Sprite Atlas , Quality Setting , sprite Texture Comprestion Override for Android And I emphasize that my scene contains only 5 sprite (one background and several buttons)

i use Application.targetFrameRate = 60; because if don't , all time The motions are stuttering Whether the battery is over 20% or not.

And when the vsync is off, the frame is locked to 30 and when it's turned on, it changes for about half a second between 30 and 60

profiler

according to profiler (on my android device) Gfx.WaitForPresent start growing!!! (if you want to say it is GPU bound , i think render time don't grow And scence is very simple)

In all these modes, The motions are stuttering.

I tested two kinds of moves

1: Moving camera in the update method by the following code:

void Update () {
    if(startMvCm){
        if (cam.position.y > EndCm ) {
            cam.Translate(0f,(speedCm*Time.fixedDeltaTime),0);
        } else {
            cam.position = new Vector2(0,EndCm);
            startMvCm = false;
        }
    }
}

2: An animation of moving an image in canvas (simple UI menu with 5 button) using Animator.

And this low FPS see more in low Battery on my Huawei Mate 10 Lite

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm 99.9% sure it's not because of your camera movement or animations; It's most likely an option that is set on your phone, that limits its performance, thus dropping the fps. Have you tried disabling that option or trying your game on another mobile device? \$\endgroup\$ – Gabriele Vierti Jan 27 at 13:40
  • \$\begingroup\$ @GabrieleVierti i dont want edit any thing in my phone because I can not ask all the users to make changes in their device.. \$\endgroup\$ – sam Jan 27 at 14:44
  • \$\begingroup\$ @sam what Gabriele Vierti is trying to say is, this is a setting most phones have, that is meant to be there to keep your phone alive for longer when low on battery. In which case there's nothing you can do, and there's nothing you should do. If a use has a device configured to limit resources when battery is low, your game overriding them would be considered very disrespectful to the user. The best you can do is make your game FPS independent (using Time.deltaTime). \$\endgroup\$ – TomTsagk Jan 28 at 9:33
  • \$\begingroup\$ @TomTsagk I agree that there is nothing about the battery. I use Time.deltaTime, you can see above. I want to know what other developers are doing when their games run smoothly even when the battery is low And did I ignore a point? \$\endgroup\$ – sam Jan 28 at 18:00
  • \$\begingroup\$ @sam if your game is FPS independent, then what is the problem? Forcing your game to play on 60 FPS on a device that is slowly dying because of low battery, will simply cause users to close your app instead. \$\endgroup\$ – TomTsagk Jan 28 at 18:03
2
\$\begingroup\$

It's likely this is an issue largely outside of your control.

If it is true that the only variable in your tests is your phone's battery percentage, then this is almost certainly the result of your phone trying to throttle itself to conserve battery or (indirectly) to say within a certain thermal profile (depending on how you are getting the phone to 20% battery).

The Android PowerManager API has methods to tell if your application is on the whitelist for ignoring battery optimizations, and suggests how you can prompt the user to put your application on that whitelist. It's not something you can do unilaterally, however. You will have to ask the user for permission because the user is in control of the device. Google also has requirements about what is and isn't considered an appropriate request. And unfortunately I don't see that this is directly exposed through to the Unity API, you may have to write some sort of plugin or whatnot, as this user did for iOS.

Furthermore, nothing you can do is really going to stop the OS or hardware from throttling your CPU or GPU down if it thinks it needs do, e.g., due to thermal conditions.

\$\endgroup\$
  • \$\begingroup\$ thank josh .. I heard that the new phones lock the app at 30 frames-per-second to reduce battery consumption. You mean, we can determine that there is no limit to our app? \$\endgroup\$ – sam Jan 27 at 15:49
  • \$\begingroup\$ You can determine that the app is "exempt from battery optimizations." What that actually means may vary from phone to phone, it's not very specific and seems intentionally so. Only the user of the phone can make that decision, whatever it ends up meaning. \$\endgroup\$ – Josh Jan 27 at 16:23
  • \$\begingroup\$ I do not know if there was any game built with 30 FPS that could run smoothly on the phone, which no longer needed 60 FPS that the phone prevent from it !? \$\endgroup\$ – sam Jan 28 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.