Tech Entice

How to fix Mediaserver Battery drain and Over-heating problem in Android?

Mediaserver battery drain issue can mainly be seen on Android custom ROMs. Even on some official ROMs (mainly on lower-mid range devices with octa-core or quad-core processors clocked at higher frequencies) we have seen this issue. Though in some cases vendors patched it by rolling out updates but still on some official ROMs the issue is there. Here we intentionally have created the issue on a CyanogenMod 11 powered device and fixed it with some easy steps

What is Mediaserver?

Mediaserver scans all the available media files (photos, videos, songs etc) and index them, so that instead of performing full scanning again and again all applications can access the files faster while required. So basically Mediserver is designed to reduce disk I/O for providing faster response (or output). But the Mediaserver battery drain issue is a real pain as this bug drains all of your battery juice and your fully charged smartphone could die even in less than 2 hours and your phone will be overheated badly. So if you are facing overheating, battery drainage issue go and check the “Battery Usage” (Settings->Battery) and if you observe Mediaserver is consuming most of the battery juice, then probably the media scanner tends to be buggy. You may follow the steps below to resolve the issue.

Test Case

For this test we used a lower-mid range (with good CPU specs) device YU Yureka which comes with CyanogenMod 11 out of the box. This device has 64 bit Qualcomm Snapdragon 615 Octa Core processor clocked at 1.5 GHz and a 2500 mAh battery. Simultaneous utilization of all 8 cores in maximum frequency can easily drain the 2500 mAh battery in 1.5-2 hours. We tested the device for 2 days and did not observe any battery or overheating issue. Now we inserted an used Micro SDHC-I class 10 32 GB card (which was taken out from a Sony Xperia Z3 and we did not format it). As we did not format the SD card it was full of folders and files created by the applications which were installed on Xperia Z3. Besides we copied a folder of 12 GB, which contains thousands of text files, documents, .xls, .pdf, .html files with small images/icons/logos (.jpg, .ico, .png, .gif etc of few bytes each) before inserting the SD card to CyanogenMod 11 powered Yu Yureka. Out of 32 Gb the SD card was about 20 GB full. After inserting the SD card, suddenly after few seconds we observed the unusual behaviors of this phone.

How to fix Mediaserver Battery drain and Over-heating problem in Android?

The part of the phone where the processor is placed started to get very hot. It was very much uncomfortable to hold the phone against the head. After checking “Battery Usage” we observed Mediaserver is now taking more than 50% of total battery usage (we cleared previous battery data) and the battery level reached to 57% from 83% in one hour, though most of the time the phone was not used (only background processes were running). We took out the SD card and inserted another 32 GB SD card (same specs) which also had about 20 GB of data. It contained about 20 HD videos, about 500 songs and some pics. This time this SD card did not have large counts of small images/ico/loge file and folders and files created by the applications installed on another device. When we inserted the second SD card we did not observe any issue though this SD card also had same amount of data, but the difference was in number of files (thousands of unorganized files compare to few hundred well organized files).

Mediaserver taking less CPU

Because of absence of any optimized resource plan this CyanogenMod 11 powered device went aggressive (approximately utilized 80 to 85% of MAX frequency of all CPU cores) in scanning and indexing those large number of files, which resulted in overheating of the phone and average of about 24% battery drainage in every hour.

We have also inserted that same used SD card, without formatting it to a Galaxy Note 4. But we did not observed this issue. As the ROM running on Note 4 is well optimized by Samsung, so instead of aggressive utilization of all processor cores to scan and index media, Note 4 uses some optimized algorithm to index these media, without overheating or draining excessive battery.

Steps to avoid/fix Mediaserver battery drain issue

1. The first thing you need to do is deleting unnecessary files from your storage. If your SD card contains plenty of small (in bytes or in few KBs) files (images or icons), that can be the reason of excessive media scanning. When you save a webpage as .html all small images and icons get downloaded and it increases count of media files. You can download or store html files with out downloading images/icons or may use applications like Pocket or any other offline reading apps to avoid it.

2. If you are still facing the issue. You need ADB and Root access to your device to perform below steps.
You may Download Android Studio.
Once ADB gets installed. Open Shell and get Superuser permissions:
adb shell
su

Now check if Mediaserver is among the top activities or not.
top | grep mediaserver
You will get output like below:
# top | grep mediaserver
2318 0 21% S 7 27180K 9283K bg media /system/bin/mediaserver

So it can be seen that mediaserver background process is eating up 21% of CPU, which need to be fixed.

Now, run the below command. If you see that the media scanning service is halted at a file or directory for a long time, then probably that file/folder is damaged and you may need to remove/delete those to solve media scanning issue. It will definitely improve mediaserver process.
lsof | grep media_rw
# lsof | grep media_rw
sdcard 3245 media_rw exe ??? ??? ??? ??? /system/bin/sdcard
sdcard 3245 media_rw 0 ??? ??? ??? ??? /dev/null
sdcard 3245 media_rw 1 ??? ??? ??? ??? /dev/null
sdcard 3245 media_rw 2 ??? ??? ??? ??? /dev/fuse
sdcard 3245 media_rw 3 ??? ??? ??? ??? /mnt/media_rw/sdcard1
sdcard 3245 media_rw 4 ??? ??? ??? ??? /mnt/media_rw/sdcard1/anik

3. If even after following above two steps, the Mediaserver process is still using most of your battery juice, you may try another SD card with less storage capacity.

4. There is a good app in Google Play store,
Mediaserver Killer. You may use this app to instantly kill the Mediaserver process or can set intervals to kill this process after every n minutes. But if you kill this process repeatedly all media files will not appear properly in your Gallery, Music or Video library.

How to fix Mediaserver Battery drain and Over-heating problem in Android? - Last modify: February 12th, 2015, Author: Anik
Report an issue

About 

Anik is a Software Engineer by profession. He loves to spend a lot of time testing and reviewing the latest gadgets and software. He likes all things tech and his passion for smartphones is only matched by his passion for Sci-Fi TV Series.

 
Comments
  • Pingback: Yu Yureka- powered by CyanogenMod - What's our take on this?()

  • Micky Premchand

    This article regarding Android phone battery drain and over heating problem makes me understand how to overcome these problems. This article can be read and understand by anyone who knows the basic knowledge of English. I have gone through many sites regarding this matter. But your site article is helpful.

    • Micky Premchand

      Thank you very much.

  • Hello anik can we remove cynogenmod 11 and use another custom rom in this phone which is fully optimised like samsung roms or any other, please ans fast as I am looking ahead to buy this phone. sahuabhishek1993@gmail.com
    thanx a lot for this post.

    • Anik Chakraborty

      Hi Abhishek, It’s not possible to install Samsung ROMs in this device, though there is a way to install stock Android ROM in this device. For this you need to root and unlock bootloader of this device.

      • Rakesh Oberoi

        Hi Anik , I have only purchased redme2 prime on 2nd Oct and on 4th oct giving problem of over heating and media saver using 56% battery. No sd card and only facebook and what;sup installed.Already formated phone on factory setting twice but same issue.

        • If you are facing this issue even without a micro SD card, and as you are saying you have already reset your device twice, I would recommend you to go for a replacement. There are many issues that can cause this problem.

          a. Too many numbers of small files (causes mediaserver process to run for longer time to index all those files)
          b. Bad external storage segments, bad SD cards (poor disk I/O causes mediaserver process to run for longer time)
          c. Bad Internal storage segments (same as above)

          If your phone’s internal storage has bad segments, that may result in poor disk I/O. In that case you don’t have much to do. You may try to defragment phone’s internal storage. Or try to exhaust your phone’s internal memory with movies, camera recording etc, make sure no space remains free. Once done format (hard format) the phone again. Then check if the issue is fixed or not. If not go for replacement.

          • Nipansha Khandelwal

            Hey Anik. I face the same problem as Mr.Rakesh. Soon after I purchased redmi2prime the problem, the one stated above, started.
            However the replacement period has already got over and it is not an option for me anymore.
            Should I show the phone to the service centre? Would that be any help?

          • Hi Nipansha, if any of point a and b (mentioned above) is not true for you, you don’t have any other choice but sending the device to service centre.

  • Sahil

    My Phone Continuously Restart ,And Its Endless Any Help ?? what to do

  • anonymous

    I am getting problem because of android system it is consuming 55% of my battery

  • Neferpitou Royal Guard

    These help me better to understand what mediaserver is. A very helpful article that provides necessary knowledge on why mediaserver is draining battery’s life faster. This is great, thank you!

  • Vinoth

    Hi Anik pl help my lenovo a 6000 plus heating and battery drain problem, I tried above points still facing same problem

  • AC

    Having this mediaserver issue on my Samsung Galaxy S7 Edge. Phone felt warm and battery draining much faster than normal. Checked over 3 days and the service using up battery is mediaserver. Don’t have an SD card. Going to try emptying cache and restart. Will contact Samsung about this too.

    • Marko Somtoja

      Is it exploding? Not yet? Bad luck! This has been common issue since S4, my S6 is also affected, but Samsung does not mind at all… but make it explode, it may help now…;)

  • AC

    I have a Samsung Galaxy S7 Edge and mediaserver was using hours of CPU time and draining my battery. I used Smart Manager (Samsung feature within Settings) and cleared RAM and within Storage I deleted Unnecessary Data. I then turned off my phone, waited a couple minutes and started it up. Since then I’ve been keeping a eye on the Mediaserver service and noticed it’s using about 1 second of CPU time every minute or so, that’s what I’d consider is normal. I don’t have an SD card, listen to music much and infrequently go through pics/vids stored on my phone. The only app that regularly uses media (download/upload) is WhatsApp.

    Let me know if this helps anyone.

    • Marko Somtoja

      So what is the storage in the phone for, when it has to be kept clean to make crippled system proces work properly? And what are you paying your money for, a flagship, or a flagshit?