Recently, users experienced the Facebook app causing significant battery drain on iOS devices even without using the app. Users reported high rate of background activity without using the app and Background App Refresh turned-off.
In line with that, Facebook today has released an update for its iOS app highlighting two major issues with the previous version; continuous CPU spin and mishandled audio sessions.
As discussed by Facebook Engineer, Ari Grant. With CPU spin, the app was continuously instructing the CPU to do “something”, thus running the device’s CPU without doing anything which caused significant battery drain.
Second issue was because of mishandling audio sessions, causing the app to keep silently playing the audio playback of the video you just watched on Facebook, even if you paused the video and left the app.
In addition to that, Facebook also fixed some issues with location to optimize the app with battery usage. Here is the official Facebook post from Ari Grant discussing the said issues.
The first issue we found was a “CPU spin” in our network code. A CPU spin is like a child in a car asking, “Are we there yet? Are we there yet? Are we there yet?”with the question not resulting in any progress to reaching the destination. This repeated processing causes our app to use more battery than intended. The version released today has some improvements that should start making this better.
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.
The issues we have found are not caused by the optional Location History feature in the Facebook app or anything related to location. If you haven't opted into this feature by setting Location Access to Always and enabling Location History inside the app, then we aren't accessing your device's location in the background. The issues described above don't change this at all.
According to Facebook, the company is committed to improve battery usage of Facebook app and will push further improvements in the coming updates. You can download the latest version of app from the App Store.