Foreground app activity over 100%? - ios

I was just monitoring my iOS game's energy usage and I see that the foreground app activity often goes as high as 126%. I am just wondering if this is something I should be concerned about? The energy usage shows a constant value of 1/20--- yet the time column is always "00:00 - 00:00", so I am a little confused about what that means.
Also, is there a way to disable bluetooth, gps in my app since those features are unused? I assume they would contribute to some sort of energy usage. Instruments shows no information other than state is "on" with a time of "00:00".

Based on the Apple docs: https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/MonitorEnergyWithInstruments.html
The Energy Usage instrument indicates a level from 0 to 20, indicating
how much energy your app is using at any given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use the GPS while performing complex network
operations. This is valid energy use. What you should look for are
spikes or areas of high energy use that are unexpected or that could
be performed at more optimal times.
I don't think I'd sweat what you are seeing too much. What is your FPS? Are you maintaining a 60 fps? Your main time is spent on your foreground app, so if you're looking to thin it down you should looking at what your CPU is doing. You an look at Time Profiler if you want to see if you can improve performance there.
That being said, I think users do realize battery life will suffer if you're playing a game. However, that comment should be tempered with the type of game. If you're doing Tic Tac Toe and you're sucking the life out of a battery, I think you'll raise some brows.
You don't have means (which won't get you rejected) to forcibly turn off things. And even if you could you also could end up with angry users too. Say you're using a bluetooth headset ... and you kill bluetooth?
Just make sure your game is fun and people will forgive you ;)

Related

Battery impact of keeping microphone on while in-app

I've been looking around for a while but couldn't find much about this. I have an AudioComponentInstance that I use to continuously record the user while in-app. This doesn't get written to a file, but I do some light processing in a recording callback. This light processing is basically an offline, lightweight voice activity detection system on every 100ms of audio data.
So essentially what I have is like the Hey Siri feature. While in-app, the microphone is always on. It waits for the user to start talking, and once the lightweight recognizer detects speech, other stuff happens.
I know this can be very battery efficient because Hey Siri is a system-wide feature. But at the same time, I have no clear idea of the impact on battery life. I only have anecdotal data – for example, the Sleep Cycle app uses 30% of battery if your phone is not charging while you sleep. So in that case, 30% battery for 8 hours of mic use. But that might be high because they're constantly doing some sort of sleep processing?
Is there a way to use Instruments or something to do an isolated battery test, or someone who has a better understanding of the microphone's impact on battery life? Thanks!
In your case, using "Hey Siri" as a comparison is not accurate because this feature relies on a dedicated SoC, specifically to optimize power usage. In your scenario, you have no choice but to consume CPU resources which will result in a higher power draw.
While further testing would be required, my assumption is that your power usage will be no better than an app in idle state at best (YMMV based on what else your app is doing).
https://machinelearning.apple.com/2017/10/01/hey-siri.html
To avoid running the main processor all day just to listen for the
trigger phrase, the iPhone’s Always On Processor (AOP) (a small,
low-power auxiliary processor, that is, the embedded Motion
Coprocessor) has access to the microphone signal (on 6S and later). We
use a small proportion of the AOP’s limited processing power to run a
detector with a small version of the acoustic model (DNN).
The acoustic model it is referring to is the trigger phrase "Hey Siri", which it has been highly optimized to detect, again circling back to power and performance considerations.

Power consumption of an iOS application

I want check power usage of my iOS application.
I tried with the Instruments.
In the 'Energy Usage Level' it shows values 1/20 (0 to 20),indicating how much energy your app is using at any given time.
What the value meant 0 to 20?.
And how Can I export the value in to text document
Edit : How can I convert it to percentage of energy usage ?
What Apple mentioned is the following :
The Energy Usage instrument shows a level from 0 to 20, indicating how
much energy your app is using at a given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use GPS while performing complex network operations.
This is valid energy use. What you should look for are spikes or areas
of high energy use that are unexpected or that could be performed at
more optimal times.
the numbers are subjective it just can be used as an indicator on how high your usage is, thats all.
the link also provides a way to log the energy usage level.

Location Update and sending location to server causing iphone heats and restarts automatically

I am fetching user location using CLLlocationManager and running webservice when lcoation is updated in background but it causes iphone heating up and battery Drains? Any one have solution for this ?
Getting your position drains power, you can do few things to avoid that:
use significant location changes (it is good if you do not need precise locations per time)
limit the accuracy (changing this can make you avoid the use of GPS that it is really a battery drainer)
I'm do not understand the heat, yes GPS make the device become hotter, but I've never experienced a restart due to heat.
Are you sure that you are not getting also into an expensive computational tasks?, you can check this by using profiler or the later versions of xcode.
You can also set the distance filter, this will continue to get the position (it will not reduce the battery drain) but will call the delagate callback only when the distance threshold is reached.
On iOS6 it has been introduced also the concept of deferring location updates in background, that probably is the best solution also for managing network traffic outgoing from your device.
In fact you have only the decision between low location accuracy (1000km) and high (3-6m).
In the first case the GPS chip is disabled, in the second it is enabled.
If it is enabled, and you need that precise locations you can do nothing.
GPS needs power, and that power last for a bit more than 8 hours full precision locations (measured on my iphone4)
warming up is no problem, however I cannot remember a warming up on my phone caused by GPS (I will check that soon). But for sure it never warms up so much that it will restart,
So your case this is a bit strange, that also could be a defect of your device.
The cause for warming up can be also that you try to comminicate very often with the server.
You can check that yourself, just download a decent GPS aplication, and let it record a track.
If it does get hot too, your device might have a problem. (Or you are living in a extremly hot environment and the sun shines strongly on your phone.)
Test also by disabling your network code.

Explain the statistics of Energy Usage Instrument in iOS

I am trying to find Energy Usage for my iOS App using Instrument.
I got the statistics like Time, Total Activity, Foreground App Activity, Audio Processing and
Graphics in Percentage format. The sum of Foreground App Activity, Audio Processing and
Graphics is different from Total Activity !
But I am not understanding what are the meaning of these columns? Can anybody please explain me the meaning of these statistics and how to use this?
Latest Energy Diagnostics documentation says:
The Energy Usage instrument shows a level from 0 to 20, indicating how
much energy your app is using at a given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use GPS while performing complex network operations.
This is valid energy use. What you should look for are spikes or areas
of high energy use that are unexpected or that could be performed at
more optimal times.
yes, sure there is difference. The best way to use it; do one at a time. observe each Activity Consumption and target optimizing that.

iOS Testing with Instruments - Best Practices

Since I'm developing iOS based applications, I'm also spending much time on getting started with testing applications and debugging performance issues.
After reading the instruments user guide, I'm now able to detect memory leaks, record the current memory size and cpu-usage and much more, which quiet helps a lot!
Now, in order to improve my testing strategy, I'm looking for a kind of bench mark values or standard values for the different instruments (such as cpu- usage, energy consumption, ...). You know what I mean? For example: I have a cpu-usage of 80% over a period of 10 seconds. Is that okay or should I think about performance optimization? Sure, in case of cpu-usage, it depends on the action that the app does over that period of time (e.g. reloading some data or something like that) but is there any rule of thumb or best practices for that?
I already did a research on the internet and only found a video of the iOS tech talk in london from Michael Jurewitz. In that talk, i figured out the following statements that are properly useful for me:
Activity Monitor: Can only be used to compare your app's resource usage to other apps
Allocations: A constantly growing allocations chart is obviously a bad sign for memory leaks. Allocations does not show the real memory size the app uses
VM Tracker: Show overall memory size; Rule of thumb: more than 100 MB dirty size of an app is far too much
...
Now I need some "rules of thumb", especially for the CPU Monitor (where is the boundary between good case and bad case?) and Energy Consumption (Level..?).
Do you have any tips for me or do you know some articles I can read through?
Thanks a lot!
Philipp

Resources