Daniels Blog
3Feb/130

Hoher Akkuverbrauch bei Android: surfaceflinger und mediaserver verursachen eine hohe CPU-Last

Auf meinem ewigen Quest die Akkulaufzeit meiner Androidgeräte möglichst gut zu optimieren, bin ich seit einer Zeit immer wieder über zwei Systemprozesse gestolpert, die ohne ersichtlichen Grund an meiner Batterielaufzeit genagt haben: surfaceflinger und mediaserver.

Screenshot_2013-02-03-14-14-29

1. surfaceflinger

surfaceflinger managed den Android-Framebuffer. Dieser wird im Endeffekt benötig um Ausgaben auf dem Bildschirm auszugeben. Leider scheint surfaceflinger seit einigen Androidversionen im Zusammenspiel mit bestimmten Roms fehlerhaft zu sein.

Ein wenig Recherche im Internet brachte mich auf eine funktionierende Lösung: Wenn man Einstellungen -> Display -> "Display automatisch drehen" deaktiviert, verhält sich surfaceflinger sofort wieder normal. Da ich ein Smartphone mit ausschiebbarer Tastatur habe, benötige ich die automatische Drehung nicht wirklich. Ich kann den Screen manuell durch das Öffnen der Tastatur drehen. Androidnutzer ohne Tastatur müssen wohl zur Zeit auf ein Widget zum Drehen des Bildschirmes zurückgreifen oder mit der Energieverschwendung leben.

2. mediaserver

mediaserver war bei mir Stromfresser Nummer 2. Der Prozess kümmert sich um das Bereitstellen von Medien für verschiedene Applikationen und um den Mediascan der SD-Karte. Dieser ist bei mir nach jedem Reboot aber auch unnachvollziehbar im laufenden Betrieb angesprungen. Er frisst sehr viel Batterie, verlangsamt das Telefon stark und ist in meinem Fall unnütz, da er lediglich Bilder und Musikdateien für die internen Android-Applikationen bereitstellt (Galerie, Mediaplayer). Ich nutze als Bildbetrachter "Quickpic" und als Musikplayer "Poweramp". Beide bringen ihre eigenen Sacnroutinen mit, deshalb konnte ich die Scanfunktion des Mediaservers ohne Probleme abschalten.

su
pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver

Danach werden interne Androidapps nicht mehr über neue Medien informiert und der Scanner läuft gar nicht mehr.
Um ihn wieder zu aktivieren führt man ein

su
pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver

im lokalen Android Terminal aus (zum Beispiel mit der App ConnectBot)

Fazit:
Durch das Bändigen der beiden Prozesse im Zusammenspiel mit den Verändeurngen aus dem oben verlinkten älteren Blogartikel von mir komme ich wieder auf angenehme 1,5% - 2,0% Akkuverbrauch pro Stunde.

25Nov/090

My Ubuntu 9.10 Karmic Koala annoyances and how i fixed them

Patching the Koala

Lets face the truth. Desktop Linux has made an incredible progress in the last few years. It still gives you all the freedom, happiness and elegance it inherited from it's UNIX-foundation - and it tries hard to compete with the Windows Plug-And-Play mentality.

The standard user shouldn't need to do complicated things on the console. Basic things should just work. Especially Ubuntu did great, they really improved many GUI aspects of the GNOME-desktop. Most modern machines run and work just "out of the box" with a fresh Ubuntu install. BUT there are still these little annoyances and things that don't work as expected. I will collect my personal annoyances with Ubuntu 9.10 "Karmic Koala" in this post and add solutions, if I find them.

Annoyance #1
Logs are spammed with messages about CPU temperature

This one is an ugly one. It started for me with Karmic. /var/log/kern.log and /var/log/syslog got spammed with millions of messages from the kernel stating things like:

CPU0: Temperature above threshold, cpu clock throttled (total events = 208[ 8973.550089] CPU0: Temperature/speed normal

CPU0: Temperat cpu clock throttled (total events = 2080190)
This was a real problem, because about 100 messages per second were written to the logs, making them hard to read for other purposes. Syslog archiving them pushed my CPU to 100% and they filled up my root partition very quickly. This behaviour seems to originate from a kernel bug that should be fixed anytime soon. There is an Ubuntu Bug-Report on the problem already: https://bugs.launchpad.net/ubuntu/+source/rsyslog/+bug/453444. There is no real fix for it, as this is a kernel bug, but there is a workaround that fixed the odd behaviour of my system. I just disabled the logging of lines, that contain the bogus information:

  • Create a file /etc/rsyslog.d/10-temperature.conf
  • Paste the following code into it::msg,contains,"Temperature/speed normal" ~
    :msg,contains,"Temperature above threshold" ~
  • Save it
  • Do an sudo restart rsyslog to make the new rule active.

Annoyance #2
CPU Frequency Scaling Monitor didn't remember my password

There is a very useful little applet for the Gnome panel, that allows you to change the speed of your CPU while working. As I am using a notebook most of the time, this thingy came in quiet handy for me. Because changing of the CPU policy requires root-privileges, you had to enter your password once with old Ubuntu versions. After that you were able to check a checkbox and Ubuntu remembered your policy. Things changed in Karmic. With the new policykit2 environment, there was no possibility anymore to remember the password. I had to reenter it every time i wanted to change my CPU policy. I found out, that I could set the permisson right in the config files for policykit2:

  • Create a file  /var/lib/polkit-1/localauthority/50-local.d/gnome-cpufreq.pkla
  • Paste the following code into it (be sure to replace YOURUSERNAME with your username):[Allow users to set the CPU frequency]
    Identity=unix-group:YOURUSERNAME
    Action=org.gnome.cpufreqselector
    ResultAny=no
    ResultInactive=no
    ResultActive=yes
  • Save it
  • There is no password needed anymore for changing CPU policies

Annoyance #3
Streamtuner couldn't load the Shoutcast streamlist anymore

This started with Intrepid or so. Shoutcast changed the hostname of it's streamlist-servers. The old hostname seems to be hardcoded into Streamtuner, so it couldn't get the streamlist anymore. This was  unconvenient  for me, because i got used to tune into my favourite internet radio stations (like Lemixx Paris France) with Streamtuner. There seems to be no effort to fix this in the Ubuntu package, as the bug is now several months old already. I fixed it by adding the right IP to /etc/hosts.

  • Open up /etc/hosts with a text editor
  • Add the following line to it:205.188.234.120 www.shoutcast.com
  • Save it
  • Streamtuner can access Shoutcast streams again

Annoyance #4
USB Startup Disk Creator is unable to create an USB Startup Disk

Ubuntu brings it's own tool to clone itself onto an USB flashdrive. You basicly get a fully working Ubuntu Installation on your flashdrive. A very useful thingy to carry around if you want to connect to the internet from untrusted machines or if you want to fix a brokeen down computer. So far so good, it didn't work. When you start the USB Startup Disk Creator from Ubuntus menu, the tool starts but is unable to format or write to partitions on your flashdrive. The solution is surprisingly simple: It needs to be run as root to make it work:

  • Open up a terminal
  • Enter the following command:
    sudo usb-creator-gtk
  • Create and enjoy your flashdrive

Annoyance #5
Couldn't click on any web link in Pokerstars with wine

Poker is one of my hobbies and the guys from Pokerstars did a great job on making it a good experience on Linux with wine too. There are a few downgrades though. When clicking on links in the Pokerstars software, no webbrowser opened up in Gnome. You need to edit the registry to fix that.

  • Run wine regedit to open the registry editor
  • Navigate to  HKEY_CLASSES_ROOT\http\shell\open\command
  • Add a "%1" after -nohome in that registry key
  • Links work now in Pokerstars

Annoyance #6
Couldn't make Pokerstars tables fullscreen with wine

Another Pokerstars problem. Scaling tables didn't work well. There was no way to make a table fullscreen. There is a way to fix that, implemented espcially for wine users by Pokerstars.

  • Open up the file user.ini in your Pokerstars directory ($HOME/.wine/Program....)
  • Add a line with  f5redrawtable=1 to the file
  • Save it
  • Tables are redrawn now after resizing them when you press F5

Annoyance #7
Skype didn't show video on my Logitech Qucikcam Chat

Skype detected my cam as /dev/video0 but was unable to grab pictures from it. The video window just stayed in plain old black

I started Skype with -> LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype  to fix it.

To be continued...