Sometimes relatively insignificant software bugs come together in what can only be described as a perfect storm, wreaking havoc and leaving the victims without recourse. Only a few days after the KitKat announcement, complaints of some rather odd behavior on Nexus devices (mostly Nexus 4s) running Android 4.3 started popping up around XDA, the Google Product Forum, and the AOSP Issue Tracker. People were waking up to find alarms failing to go off and most of their apps crashing instantly. A reboot would fix the problem for a while, but it often returned the next day with no explanation. Fortunately, the likely culprit has been found and the bug is pretty easy to avoid.

Symptoms

Reports seemed to be all over the place, with the only truly common factor being that apps were crashing for no clear reason. Most people saw this happening in the morning when taking their phone off the charger. Alarms were an obvious issue, as they would crash at the moment they were supposed to go off. The combination of exploding alarms and the proximity to daylight savings prompted some to blame the time change. However, some people weren't using alarms and still others noted their issues began prior to the DST adjustment.

One other early observation was that the crashes produced an EGL_BAD_ALLOC error, which means there had been a failed attempt to allocate RAM to a process. The memory issue historically indicates too many background apps are running, but it was happening even to people with a freshly factory reset device, leaving only a memory leak as an explanation.

The (Likely) Cause

Disclaimer: This is speculation based on available evidence. A few assumptions are made and there are outlaying reports that may contradict the assertions made here.

After much discussion, the only common factor among the people was the use of an induction charger. This isn't the first time wireless chargers have crossed the Bug Watch desk or turned up in other complaints, so it's not surprising to see them making a return. For most people, switching to a wired charger alleviated the problem. However, the problem was still present for a minority of people with wired chargers, but a few realized their connectors were faulty, causing interruptions in the flow of power. Anybody familiar with how induction charging works will probably know that trickle charging isn't possible, so a cycle of charging and discharging is used to account for this weakness; that pattern is likely replicated by the faulty wired chargers.

Still, people have been using wireless chargers for months without this problem. Something had to have changed for this behavior to emerge so suddenly. A few people attempted factory resets without updating or installing any apps and still witnessed the same results, bringing about the revelation that two things were still changing thanks to automatic updates occurring in the background: the Play Store and the Google Play Services framework, both of which had just started shipping new versions. Further testing effectively eliminated the Play Store.

We now know that Play Services (v4.0.30) is probably at the center of this, frequent power cycling appears to be the catalyst, and the end result is a memory error. It almost goes without saying that the Play Services framework monitors powers states, mostly to determine how aggressively it should read from sensors and to efficiently manage core services like Google Cloud Messaging. Based on the evidence, it looks like there is a memory leak that builds up each time charging starts and stops. The side effect is insignificant and goes unnoticed for those with wired chargers, while those with wireless chargers unknowingly incapacitate their devices. It's still unclear if the issue is completely flooding the system RAM or if it merely overflows what is allowed to Play Services, which might cause apps dependent on the framework to fail.

Fixes And Solutions

While this is a particularly nasty bug, there are a couple of very simple solutions. The first solution is obvious - put the wireless charger in a drawer and use that old-school cable until Play Services is fixed. I understand, you hate cords, but this is obviously going to be a short-lived problem and soon you will be able to return to your regularly scheduled induction charging.

On the other hand, if you can't bear to tether yourself to a wall ever again, there is another alternative. Everybody who has updated to Android 4.4 KitKat is reporting no signs of this issue. As if you didn't already have enough reasons to be excited for the update, right? While OTAs were delayed by a few days due to a critical bug, they are again creeping out to the general public. For those who can't wait, take a look at our instructions on how to manually update your Nexus device.

Wrap-Up

It looks like this was just unfortunate timing, as most people never would have noticed this happening if Play Services 4.0 hadn't rolled out until after the KitKat OTAs. Even so, it's good that it was discovered now, as it might help to expose potential memory leaks. So far, I haven't been able to find reports of these crashes happening outside of the Nexus family, but it's entirely possible that it's not an isolated issue. In any case, hopefully Google can find the bug and get it fixed up in the event any non-Nexus devices are also affected, especially for those which won't see an update to 4.4 in the immediate future.

Thanks, Ryan Stewart.