19

I've got a Nexus 4 on OS version 4.2.1 that suddenly started to drain it's battery very quickly. When looking in the battery usage I see "Mediaserver"eating 60% of the battery over time, with several minutes of CPU time logged and several hours of Keep Awake time. Typically the screen, phone idle or other services eat up the majority of battery life.

I tried closing all apps and charging it up, and sure enough overnight it still drained significant battery, again Mediaserver was the culprit as reported in the Battery usage chart; it had kept the device awake all night and drained 10% of my battery despite zero use. I haven't added a large number of files and I'm not playing music/etc so Mediaserver shouldn't be doing very much on the drive.

How can I stop Mediaserver from eating my battery life like this?

6 Answers 6

8

Killing all running apps didn't solve the problem, nor did disabling the automatic sync for Google account items like videos/photos (which I heard suggested for a similar battery issue).

What did work was simply rebooting the device by holding the power button and picking shut down. After rebooting Mediaserver no longer appears to use much of my battery in the usage chart and my charge lasts like it always did. So if you get the same issue, just reboot.

4
  • 1
    Funny -- that was exactly what I just wanted to recommend. It's the only way to get rid of "sticking wakelocks" I know of (those cases happen when apps request a wakelock and forget to release it lateron).
    – Izzy
    Dec 10, 2012 at 16:37
  • @Izzy that must have been what happened. I'm not sure technically what happened, but wanted to share the solution in case it's a common problem on 4.2.1 or something.
    – Ben Brocka
    Dec 10, 2012 at 16:44
  • That's something common to most/all Android versions (not especially with mediaserver, but with many services). Also, badly designed apps add to this. For details, you might look into the question How to deal with (orphaned) WakeLocks? and its answers.
    – Izzy
    Dec 10, 2012 at 17:22
  • Reboot, reboot, reboot. Is there a less annoying way to solve this? I hate rebooting. Can't I just kill that mediaserver?
    – neverMind9
    Jul 23, 2019 at 12:41
7

The Mediaserver process scans your device for media files to add to your library. However, the 2012/12/12 (perhaps some more) gapps version is broken and gets stuck in an infinite loop on unfamiliar files on your phone. This directly translates to battery drain and is bad for the lifetime of your battery and other phone components. When running your phone for the first time or when starting media applications, the Mediaserver is invoked and will commence the horror.

How to fix:

  • Reboot phone and do not start a media application.
  • Put a .nomedia file on your SD card root to prevent library search, thus preventing Mediaserver from getting stuck. This means no media library!
  • Wait for the glorious Google to fix this anomaly.
  • Downgrade your Android firmware + gapps to a version which lacks this bug.
  • Use an iPhone/Windows Phone
  • Modify the gapps (Mediaserver.apk) to support all kinds of files normally. (advanced + time consuming)
2
  • 2
    Downvote because of recommending iPhone/Windows Phone. Btw, that's not a fix, the bug will still be there. Aug 4, 2013 at 10:55
  • .nomedia file in root folder does not work. On a Nexus 7 with Android 4.3. There is no physical SD card but I put the .nomedia file in the SDCard folder root, and it has not stopped mediascanner from running. I am assuming it is supposed to be applied recursively and does not need to be placed in every subfolder? Should I place one even higher than SDCard, like in system root perhaps?
    – The111
    Aug 5, 2013 at 17:08
2

I think I may have figured out the cause and a makeshift solution for this bug, at least one that (finally) works for me, and that I have not seen mentioned often elsewhere.

On my tablet (Nexus 7 2nd gen), I had seen the mediaserver bug very often and practically given up trying to solve it.

However, on my phone (I9505G aka SGS4 GPe), I hadn't seen the bug once. Both devices were running 100% stock Android 4.3. Then one day I noticed the bug rearing its ugly head on my phone too. I hadn't copied ANY new files to the device recently, so that threw any theories about "corrupt media files" out the window. I racked my brains and realized the only thing I'd done differently in the past 24 hours was played a game (Rayman Jungle Run) on the phone, which I usually only use for calls, emails, and e-books. On my tablet however, I play Rayman Jungle Run often.

So, I just ran this sequence of tests on both my phone and tablet, with the same results.

  • Full charge. Fresh boot. Run for several hours. RESULT: No mediaserver drain.
  • Launch Rayman, play for 1 minute. Return to home screen but do not force close the app. Wait a little while. RESULT: Mediaserver drain begins.
  • Force close the Rayman app (I used an Elixir shortcut to do this, but using the apps menu should work fine). Wait a couple hours. RESULT: Mediaserver drain has stopped!

I did a lot of searches on the web and only found one other reference to similar phenomenon, and that post referenced the Rayman game as well as another game called Super Hexagon or something. The apparent lesson here is that certain apps have the ability to trigger the mediaserver bug. In my case at least, it has nothing to do with what media files I have on the device, or what Google services I allow/prevent running (these are both things I see frequently quoted as supposed solutions).

I would also hypothesize that if you have an app which triggers the mediaserver drain, and this app autoruns at startup or any periodic time intervals, then the only surefire solution in that case would be to uninstall the app, unfortunately. This could explain why some people do not find that rebooting helps... if the offending app runs at startup, of course the drain will begin right away also.

2
  • This very thing happened me last night. Rayman Fiesta Run, exited out with home button, lost 40% battery overnight to media server. Thanks for this!
    – RossC
    Dec 4, 2013 at 9:24
  • @RossC Awesome, glad it helped you. I just installed Fiesta Run too and was disappointed to see that they still haven't fixed this bug (not sure whether the OS or app is at fault, but I know the app could fix it by forcing itself to close or at least including an option). I keep forgetting to kill the app after playing a session and remembering hours later when I see how low my battery is getting.
    – The111
    Dec 4, 2013 at 17:30
2

Just kill the media server process. I created a shortcut which runs a command line and kills it

kill pidof /system/bin/mediaserver

or on other devices,

kill mediaserver 
1

I had the very same problem with Android 4.1.2. tablet. Tried everything found on several forums, and the result was - nothing worked. Mediaserver kept draining my battery. Intuitively, I tried two things: 1. Unmounted SD card where I keep all sorts of media files. 2. Deleted downloaded PICTURES from "download" folder.

Result = problem SOLVED.

Then remounted the SD card - battery life still normal!

Conclusion: bloody mediaserver keeps scanning the downloaded pictures and drains the battery.

Simplicity is always the answer!

0

For me, rebooting the Nexus 4 several times didn't help. The first time I started using the mobile phone, I logged in without the Google account. So, I did factory reset and made sure I logged-in with the Google account. This seems to have fixed the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .