21
Nov
52-car-pile-up

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.

device-2013-11-19-092627device-2013-11-19-092637device-2013-11-19-092645

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.

Cody Toombs
Cody is a Software Engineer and Writer with a mildly overwhelming obsession with smartphones and the mobile world. If he’s been pulled away from the computer for any length of time, you might find him talking about cocktails and movies, sometimes resulting in the consumption of both.

  • Kevin Opeth

    It's funny. I noticed this happening to me for a few weeks now but never nailed down why it was happening. It is very annoying to deal with. I usually clear all the open apps in my mutli-tasking menu which gets things working again.

  • http://www.androidpolice.com/ Artem Russakovskii

    Started happening to my N4 too - it's been so frustrating to find the phone completely broken when I picked it up from the charger every day. Thankfully, it's a test device for me, but if this was my daily driver, I would have smashed it after a few days.

    • Josh Legoza

      I've been close with my N4!

    • gtg465x

      Hi, Google here. Not only are we going to withhold the 4.4 OTA for your Nexus 4, but we are also going to kick you while you're still down on 4.3 :D.

    • Ryan Stewart

      It wasnt that big of a deal when I emailed yall about it. It only seems to happen over a period of inactivity while on the charger. I leave it on the wireless charger at work but am touching it every hour or so, probably breaking the cycle.

      • http://www.androidpolice.com/ Artem Russakovskii

        I don't touch it as much, and every time I took it off the charger, it was doing this. Drove me nuts.

  • Josh Legoza

    Holy crap! Cody, thank you so much for this post! This has been driving me nuts and I couldn't figure out what the issue was. My alarm clock has failed several times in the last few weeks. The first time I was lucky enough to wake up 3 minutes after it should have gone off. Had a backup since then. The last week or so, I haven't seen this issue (curious why?) so I felt like maybe I had fixed it. So I didn't set up a backup alarm today and ended up an hour late to work. Oops! So glad to hear that it seems to be fixed. I was ready to clean flash the factory image of KitKat cause I thought my alarm clock data had somehow corrupted and was taking down my whole system. Glad to know I can still keep my data! Thanks again Cody!

    • http://www.androidpolice.com/author/cody-toombs/ Cody Toombs

      This is why I like writing these!

      I'm glad this was helpful. I like to offer fixes when I can, and at least explain the issue so people know what to expect when there isn't a good solution. I imagine you aren't unlocked, so you'll probably just want to hold out for the OTA, which I imagine should be hitting you pretty soon.

      • cabbiebot

        good guy cody is a good guy

      • Josh Legoza

        I'm actually unlocked and rooted. And my OTAs usually fail, so instead of chase that I've always just torn apart the factory image and flashed the necessary bits and leave data alone. I also had just finally installed Xposed Framework right around the time this started. I ended up disabling it which oddly enough coincided with it behaving better. So glad to hear Xposed has nothing to do with the issue, cause I love it. In fact the incompatibility with 4.4 is why I haven't gone ahead and flashed 4.4 yet. But outside of disabling Xposed, I hadn't had time to investigate or troubleshoot the issue, so I was really glad to see this article.

  • jimsis

    Been there also, didn't connect the two though. Thanks for the info. Since I went N5 haven't had it though so all good.

  • jm9843

    Yep, been happening a lot on my Nexus 4 after wireless charging overnight since installing the latest Play Services. I've just been rebooting when it happens and trying to wait patiently for the OTA. If it's not here by the weekend I'll be flashing the recovery images.

  • Testraindrop

    Hm the Play Services are causing more and more bugs lately, first the continued wakelock for no reason, heavy location tracking even if phone just was laying on the table without moving, now this.

    Google should take this more serious as it is now a core system element for almost all Android devices.

    • Wyatt Neal

      And tis is why the staged roll outs that everyone hates (ermahgerd!!! i needz my new updatez!) are so important.

  • Mystery Man

    Hasn't happened on Note 3.... yet

  • CuriousCursor

    Had this happen on my N5 as well. Worst thing is that I don't even use a wireless charger. Seemed completely random but I know bugs aren't random. :/

  • Chris Caldwell

    lol sensationalism at its best. Talking about a wireless bug causing a freak crash...and then showing a picture of a car pile up. How many folks do you think clicked here to find out why a phone bug caused a huge car pileup?

    • http://www.androidpolice.com/ Artem Russakovskii

      Whoooosh.

      It's a picture of a "crash." That's it. Nothing more to it.

    • jordanjay29

      A 'system pileup' would be the best way to describe the crashes, though. Once they start happening, it's like a cascade failure and the phone just stops working until a restart occurs. It's as pleasant as a car pileup, and until you restart, your phone might as well be totaled.

  • OmniWrench

    According to the AOSP issue tracker they haven't even fixed the wakelock bug relating to wireless charging (the other one referenced in this article), kind of makes me nervous about them fixing this. Honestly between these issues and the Nexus 4 sliding off I really, really regret buying that charging orb.

    • Josh Legoza

      I thought the same thing when I was reading this. Hope they actually jump on this and fix it soon.

    • Ryan Stewart

      They probably wont "fix" this because its something to do with being on the new play services and the old anroid, upgrading Android solves it.

      • Josh Legoza

        But as the article suggests, might point to a memory leak in play services that wouldn't have otherwise been found.

    • Drew M

      Are you sure? There were two commits for the wirelesschargerdetector wakelock in the 4.4 changelog. I've only had this happen to me once in the three months I've had my charger, and that was on 4.3--haven't seen it yet since I flashed 4.4.

  • bob49

    Every time I read Android Police trying to get even a bit technical, I die a little inside.

    • http://www.androidpolice.com/ Artem Russakovskii

      Are you implying that we're technically inept? Care to produce your reasoning here?

    • Scott

      I wish I could downvote you into oblivion.

  • herbivoor

    Not questioning AP here, but doesn't that Jellybean picture in the notification bar mean that Debugging is enabled, as in, connected via usb cable?

    • http://www.androidpolice.com/ Artem Russakovskii

      Yeah, I hooked up the phone to take the screenshots because it was the only way - otherwise everything kept crashing, including the built-in screenshot-taker.

      • herbivoor

        That makes sense, thanks for clearing that out!

  • N-4-N-More

    OH thank god, I thought I was losing my mind.

  • Dennis Ulijn

    Had this problem a few times as well, only my device had crashed and turned off while i was sleeping. I had the feeling this only happened during the 4.2 days, and haven't seen it since 4.3.
    Luckily my wife's alarm (also a N4, but normal, wired charger) goes off in time for me to get to work, so no big problem.

  • Ryan Stewart

    Took yall long enough, emailed yall a week ago. I updated to 4.4 to get it resolved long ago.

  • Nick Marowsky

    Where were you yesterday when I was digging through forum posts and pulling my hair out! I did figure that this was the case and shelved my qi charger (which I got to use for like 3 days before mayhem began...) until I get 4.4. But great to see you guys putting this out there, keep up the good work. Just hope my next phone meltdown comes after you guys make a post about it, and I can save myself some time.

    • http://www.androidpolice.com/author/cody-toombs/ Cody Toombs

      Ahh, you're killin' me. Seriously, I started writing this really early yesterday, but put it on pause to cover the 4.4 OTA changelog. By the time that was finished, I had to check out because of a really bad headache.

      • Nick Marowsky

        Excuses excuses, but it is nice to have confirmation rather than just a vague notion of what's going on (even if a day late). That's what keeps me coming back.

      • Michael

        I'm seeing some errors running on 4.4 while using qi chargers.

        • http://www.androidpolice.com/author/cody-toombs/ Cody Toombs

          I hope that's not the case. KitKat was supposed to massively improve handling of wireless chargers. It's possible that there's still some bugginess in GMS, but hopefully anything in Android is either fixed or lined up for the next OTA. Wireless chargers are legitimately catching on now, and I bet they will be a popular Christmas item this year, so they better not be causing too many problems for people.

        • José Martins

          I experienced the same here yesterday. On the exact time I put the nexus 4 on the wireless charger (official nexus wireless charger btw), G+ crashed.

          Running Android 4.4 (after the 2nd 4.4 OTA) full stock and only 3 or 4 third party apps. :s

  • sam

    Still happens for me on 4.4. Definitely the same issue as going back wired has prevented any occurrences for hours now.

  • Emulators + Android = Win

    Lucky for me I don't use that app so I don't have any issues with this.

  • jordanjay29

    Wow, I'm amazed it took so long to figure out what's going on. I've had this problem for a couple weeks now. Quite annoying to have to restart my phone daily. I've even missed calls when the dialer has shut down.

Quantcast