
Facebook iOS App Battery Explanation - milen
https://www.facebook.com/arig/posts/10105815276466163
======
jobu
_" 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.

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

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

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

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

~~~
needcaffeine
More > Settings > Account Settings > Videos and Photos

Autoplay: Never Autoplay Videos

------
matsur
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.

~~~
mey
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.

~~~
cma
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

------
josephpmay
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](https://en.wikipedia.org/wiki/Hanlon%27s_razor)

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

------
zacwest
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.

~~~
scott_karana
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>.

[https://support.apple.com/en-ca/HT201264](https://support.apple.com/en-
ca/HT201264)

Screenshot of the feature, since that page lacks it:

[http://cdn.iphonehacks.com/wp-
content/uploads/2015/06/ios-9-...](http://cdn.iphonehacks.com/wp-
content/uploads/2015/06/ios-9-battery-usage.jpg)

~~~
0x0
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.

------
epx
Li-ion can't handle our scale.

~~~
vinceyuan
iOS SDK can't handle our scale.

------
soccerdave
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.

[https://developer.apple.com/library/ios/documentation/iPhone...](https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html)

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

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

------
wppick
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?

~~~
TazeTSchnitzel
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.

------
orbitur
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.

~~~
tomelliott
>> 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.

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

------
IBM
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.

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

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

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

~~~
derefr
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.)

