Facebook and Messenger’s recent battery draining issue might have caught a lot of users off-guard, but the company isn’t the only one to have released app versions that chug down too much juice. In fact, it appears that the problem was quite a simple mistake for a developer to make and one that could affect any number of apps. Here’s a closer look at what happened, why, and what you can do if you notice similar problems in the future.

When it comes to Facebook’s power drain the other day, it turns out that a server-side triggered update was causing the app to use additional CPU cycles while also running the CPU at a higher frequency than normal. Of course, using up extra processing power and/or running the CPU at a higher frequency increases the power consumed by your handset, draining your battery faster and even causing it to heat up. Fortunately it was pretty simply for the company to fix, but they haven’t exactly told us what went wrong.

Leading causes of battery drain

What’s interesting about this case is that the power drain was occurring even when users weren’t spending time in the main Facebook and Messenger apps. This is because these app types regularly update in the background, pulling your phone out of sleep and therefore consuming more power. Usually, this is done efficiently by using as little CPU power as possible, but processor power consumption could be kicked into overdrive by misusing Android PowerManager’s WakeLock feature, ignoring default battery optimization settings, or simply accidentally making a high demanding task loop run in the background when it shouldn’t.

PowerManager and WakeLocks are particularly interesting features for developers, as it allows them to gain greater control over the power state of a device, but this obviously requires careful management. A PARTIAL_WAKE_LOCK is most likely to be used for prolonged background updates, as it leaves the screen and keyboard off but the CPU on. However, not releasing a partial wake lock will keep the CPU on, thus consuming more power when the phone should be idle.

It’s also possible that Facebook and Messenger were simply repeatedly requesting data to send to its servers, keeping phones in a high CPU use state. As well as increased processor usage, an overactive background task could begin draining power through repeatedly storing or recalling information from RAM. It’s not as instinctive as understanding CPU power drain, but memory, especially fast RAM, is also a notable battery consumer and reducing the amount of time spent transferring and retrieving bits of data helps your battery to last longer. Furthermore, a memory leak or very high RAM usage can slow down the performance of your devices just like a maxed out CPU can. Closing and refreshing an app is a good way to free up some memory, but it’s not a fix for broken programming.

We don’t know exactly what happened in the case of Facebook, but an awful lot of apps run update tasks periodically in the background, and getting this wrong can lead to exactly the sort of battery drain issues that many users witnessed.

What to do about battery drain

The first port of call when you suspect that your phone’s battery is draining quicker than it should is to scope out what’s actually consuming the most battery. You don’t need a dedicated app to do this, although many are available, you can simply head on into Settings > Battery > Battery Usage. Scroll down to the bottom of the page and you can see exactly which apps and services have been consuming the most battery. It’s not strange to see Android OS, Display, and even Facebook appearing near the top, but if you can see that an individual app is consuming 20 percent or more of your battery, especially when it’s left mostly running in the background, then there’s definitely a problem.

The next step is to see if you can quickly fix the problem by restarting the app. After all, it could be a simple bug. This is also super simple, just open up the running app list, usually the bottom rightmost button, and swipe away the culprit. Then simply enter the app again and check back to see if the problem persists. Failing that, going into Settings > Apps, selecting the app and clicking Force Stop will cause the background task to stop as well.

If there’s still an issue then it’s likely something wrong with the app itself. An obvious solution is to uninstall the app and find an alternative, if available. But that might be a bit drastic if you really want to use the app or if it’s a social network like Facebook. It is possible to disable most apps from running in the background until the developer can update it and fix the problem. To do this, you can use an app like Greenify, even without root, to “hibernate” apps that would usually run in the background. It’s simply enough to use, just select the battery draining app and then force a manual hibernation. You can also setup automatic routines with rooted handsets or unrooted models that meet certain criteria. Once the developer fixed the problem, you can set the app to go back to normal operations.

We should note that Android is very good at handling these background tasks these days, especially thanks to the introduction of Doze. So if you are experiencing battery issues, it’s most likely a rogue app to blame. Hopefully this guide has given you an idea about why these problems can happen and what to do about them. Do you have any of your own battery saving tips to share?