Battery statistical issue for Packet Tunnel Provider

Hi guys,

I'm developing a custom VPN client with NEPacketTunnelProvider which tunnels all device traffic. All is going well so far but I've noticed that iOS battery statistics (Settings -> Battery) is claiming that our client has consumed a significant amount of energy (10%~30%). I though it was true for a while, but then I conducted some basic testing which suggested this is more likely a statistical issue.


I set up my device (rebooted with clean battery cosumption statistics) with ~80% battery capacity and started to watch "NASA Live" channel in Youtube app with 1080p60 quality, for 3 hours, and taking notes every hour. I cross referenced the data of the same scenario (same device as well) collected with our custom VPN provider enabled and disabled. I made sure when the VPN client is enabled, I can actually see the Youtube traffic tunneled. Actually the video feed can generate ~1GiB traffic per hour pretty stably. I can provide detailed numbers if necessary, but generally, after 3 hours, both scenarios showed an overal of ~50% battery consumption (from the battery indicator on the status bar on top of the phone screen), there was no significant difference in the battery consumption. However when I looked at the statistics in Settings -> Battery, the scenario without our VPN client was showing 100% battery consumption from Youtube app (which is expected), and the scenario with VPN was showing 68% for Youtube, and 32% for our VPN client app!


32% battery consumption in statistics is scaring. But what confuses me is that the actual device battery consumption didn't increase. My theory is that without the VPN client, individual apps are sending out their traffic on their own so the battery consumption are calculated on their head. But now with our VPN client, we are actually sending out traffic for every applications so iOS will blame us for that part of energy consumption. I'm not sure if the theory is true but it certainly explains the behavior.


I'm wondering if Apple can look at the issue at if proved to be a statistical issue then fix it. Because 10%+ battery consumption on our app would be enough to scare away our customers. We can explain to them there is no actual extra energy consumption but customers will be suspicious. Whenever they feel their phone's having a shortened battery life they'll come to see the list and they will blame us.


Thanks in advance!

I'm wondering if Apple can look at the issue at if proved to be a statistical issue then fix it.

The best way to get this request in front of the folks who can actually do this work is to file a bug report about the issue you’re seeing. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Eskimo. I've filed a bug with number 38787938.

Hi there! We have the same issue in our VPN app. Any updates on this issue? Was it resolved by Apple?
That specific bug (r. 38787938) did not result in any action on Apple’s part. It’s hard to say whether QAZ123436 was able to take our feedback and make improvements at their end.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thank you for your quick response!
Where I can find that feedback from Apple and suggested improvements? I would like to try them as well in our app.

We would be interested as well to see the suggested improvements from Apple, as we have the same concerns. Can someone post this?

@eskimo - I and others with PacketTunnelProvider implementation would benefit from the feedback. Presumably they affect every other vendor. How can we get access to these suggestions, e.g. do we need to file our own bug or ?

There is not, in general, a way to see other folk’s bug reports. See my Bug Reporting: How and Why? for more background on this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo - Filed bug report FB13425443, so hopefully we can get some guidance on how to address this for our VPN implementation.

@eskimo We would similarly love if Apple could provide more guidance on best practices to optimize network extensions for battery life, and what exactly drives the power consumption data displayed in Settings.

Some of our customers complain to us about battery life due to the scary data reported in Settings, but we don't really know for sure what is driving those numbers up. We have very few tools at our disposal to diagnose issues. No powerlog data is available outside of the plsql files in a sysdiagnose, and it is really hard to get customers to submit one of those.

It would really help if MetricKit could be used to extract power consumption data in a privacy-aware fashion, for instance giving us powerlog data for processes in our bundle. Data points that are fundamental for battery life investigation, like cellular / Wi-Fi modem wakes, are not currently available outside of sysdiagnoses which means that we cannot collect them in bulk.

Hi Quinn

Any way we can push Apple from our side? It's pending for quite some time. OR at least can we have some public documentation from Apple about this behaviour?

It’s hard to say exactly what the status of this is. At least one of the bugs referenced above has changes that rolled out in iOS 17.4. Have you re-tested on that release?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Battery statistical issue for Packet Tunnel Provider
 
 
Q