Hacker News new | past | comments | ask | show | jobs | submit login
Facebook iOS App Battery Explanation (facebook.com)
76 points by milen on Oct 22, 2015 | hide | past | favorite | 45 comments

"The second issue is with how we manage audio sessions. If you leave the Facebook app after watching a video, the audio session sometimes stays open as if the app was playing audio silently. This is similar to when you close a music app and want to keep listening to the music while you do other things, except in this case it was unintentional and nothing kept playing. The app isn't actually doing anything while awake in the background, but it does use more battery simply by being awake. Our fixes will solve this audio issue and remove background audio completely."

So after all the accusations of Facebook exploiting background audio to steal cycles for downloading content or tracking people's location it's just another case of Hanlon's Razor.

To be fair, accusations tend to fly faster when trust in maintaining users privacy has been previously eroded. When there is goodwill built up, people tend to be more forgiving.

To be fair, it's hard to imagine that a company as massive as Facebook, with an application that's got probably the highest install rate on iPhone of any app not shipped on the device, would be so mind-numbingly stupid as to overlook such a prevalent battery-draining issue as this for so long.

Combined with auto-playing videos to make the bug a ton more pronounced.

I deleted the facebook app because of this horseplay. Auto-playing videos I don't care about is not ok.

There's a setting that tells your Facebook app to not autoplay videos.

I actually looked for this and couldn't find it. Where is it? Should definitely be more obvious, unless I'm completely missing something :)

More > Settings > Account Settings > Videos and Photos

Autoplay: Never Autoplay Videos

Deleting the app is a very reliable setting as well.

We (Spire, building breath tracking wearables) have an unfortunate amount of experience troubleshooting these issues. The developer tooling around measuring battery drain/energy usage is not useful for debugging this sort of thing.

We ended up wiring a disassembled iPhone to battery simulation hardware and are now able to measure battery drain while stepping through a debugger/pushing the phone through an integration test to identify power usage regressions.

Curious how other folks handle these issues.

This is actually really neat, do you guys have a blog post detailing how you do this?

At mozilla - for B2G battery drain issues there is a project for building battery harnesses - the work of one man working in low level power measurements


Curious how other folks handle these issues.

One approach might be to use a thermometer or IR camera to keep track of the phone's temperature relative to ambient. If something is causing unusual amounts of battery drain, the phone is going to get (much) hotter.

I remember a presentation by Amazon at AnDevCon describing a similar setup they use internally as part of their validation. The built in Android battery profile wasn't sufficiently accurate to what was actually causing drain (most OEMs don't modify the default AOP power profile to represent what their system components actually consume in power). They actually went to the point to connecting into the battery electronics on the battery side to monitor drain. Unfortunately I don't see the presentation available online and this was at least 4 years ago.

Recent talk by John Carmack mentioned the same, in their case they hooked up a measured DC power supply in place of the battery to measure power usage for GearVR

Importantly, this explains why a number of Facebook on iOS users were reporting that the app was showing background usage even when background refresh was turned off. Many people thought Facebook was using a private API to track people when they weren't using the app. In reality, it was just a mistake. This is a great example of Hanlon's Razor [1]

[1] "Never attribute to malice that which is adequately explained by stupidity." https://en.wikipedia.org/wiki/Hanlon%27s_razor

However, either case is an equally valid reason to uninstall the app.

It would be helpful if Apple included tracking on background time and other battery-usage metrics along with crash reporting for users that opt into it.

Facebook has no by-the-books way to realize some issues like this are happening, largely because iOS makes this difficult to watch.

iOS 9 does include a breakdown now.

"To see how long each app has been open and onscreen, and running in the background, tap <clock icon>.


Screenshot of the feature, since that page lacks it:


I think the OP was talking about (aggregate) telemetry going back to facebook (crash reports yes, battery usage stats nope).

Battery stats telemetry is almost certainly only available to Apple, and not shared with third parties. (If you dig into your device's settings->logs, there are log files that seem to record every imaginable interaction with the device)

Also, for a long while, ios devices that have mounted the developer disk image provide some extra battery logging in settings, but that will only provide insight on the developer's own devices.

But is that data reported back to the developer? When you have half a billion users, what anyone one person sees isn't very representative. This iOS 9 feature is focused on helping the end user (which is great), not the developer (which would also be great).

It shouldn't require specialized tools to figure out that your app is continuing to run in the background when it has no reason to do so.

Li-ion can't handle our scale.

iOS SDK can't handle our scale.

Doesn't an iOS app have to declare that it is going to do background audio? If so, what was their original legitimate use case for having background audio?

Edit: Here's a link to the apple docs that show apps have to declare what tasks they will perform in the background.


Presumably so that way you can start playing a video, go into the background, and have the audio keep playing.

It plays sounds when you interact with the app (liking a post, etc.)

An app does not have to request the special permission to play background audio in order to play sounds.

Audio calls, maybe?

handled by the Messenger app these days. Not sure why they would need it in the Facebook app

Legacy code?

When I read the title I got excited because I thought that Apple had implemented some battery abstraction for iOS that gives a virtual battery to each application. Now I'm curious to know if there would be any benefit to something like that, or if it would be at all useful in any way?

Would allow app-specific battery usage, and an upper limit on how much power an app can use? But you could already do both of those things, I guess.

I hope there's a fix soon, because I'm tired of having to force-kill the app.

I don't know what tipped me off that Facebook was the culprit but I was driving one day and my podcast went quiet, like a notification sound was about to happen. But nothing came and the audio stayed quiet for at least 30 seconds before I pulled over, opened the app list, and killed Facebook. Problem solved.

Also, coincidentally, I forgot to kill Facebook last night and when I picked up my phone this morning it was warm. Glad I remembered to leave it plugged in.

I would put your phone in low power mode. It seems to have all the benefits of straight up killing apps without having to bootstrap them each time you want to use them.

Downside of course is lack of push notifications and the like.

>> Also, coincidentally, I forgot to kill Facebook last night and when I picked up my phone this morning it was warm. Glad I remembered to leave it plugged in.

Maybe, just maybe, it was warm because it was being charged.

I wouldn't have mentioned it if it wasn't out of the norm after leaving it plugged in for 8+ hours.

force quitting might not work if you have push notifications enabled, you can get silent app notifications (content available notifications) and the app can be relaunched in the background.

Anyone know how to disable those Facebook notifications that say "Do you know X?". Can't find it in the options at all. Feels like an attempt to get engagement.

I really want access to the code base so I can diff the changes.

I guess we'll just have to trust this explanation?

Of course. Why would they show you their proprietary code for a totally unnecessary app?

Alternately, you can grab the binary from the .ipa and decompile it. Objective-C/Swift code effectively can't be symbol-stripped; objc_msgSend takes a string selector, and those selectors remain evident in the binary. (This also makes writing cracks/keygens for Obj-C apps very, very easy.)

Or you can just uninstall the app.

Well, Facebook is hiring ;-)

The easiest answer is to just not let Facebook anywhere near your phone.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact