In Facebook’s latest iOS update, Facebook addressed the infamous battery drain issue being faced by many of their iOS application consumers. Recently, many of the users running Facebook on iOS have complained about their batteries being drained unusually fast when the Facebook app is running in the background. The problem managed to persist even when ‘background App refresh’ was turned off through the settings.
Facebook’s engineering manager Ari Grant explained the reasons as to why the problem occurred and what their team has done to fix these issues. Apparently, there were numerous factors affecting the App when this problem occurred; one of which was a “CPU spin” in the framework and a bug that made the processor think the App was active even when it wasn’t.
“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 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.”
Incidentally, when news of this bug first arose, Federico Vittici from Macstories predicted that the cause for it may be silent audio in the background which was confirmed today by Grant’s blog post. Vittici further speculated that the audio sessions were kept running on purpose, so as to load content before a user actually opened the App. Grant, however, is claiming that this was merely a bug in the code and was not at all intended.
Grant goes on to say that user should expect a much better version of Facebook with the latest update and that Facebook will continuously try to improve the battery life on its App.