Oli Warner About Contact Oli on Twitter Subscribe

How to fix the 100% CPU issue in XBMC

Wednesday, 28 March 2012 boxee linux nvidia ubuntu xbmc

Long time users of XBMC and Boxee on Linux will probably be aware of a very annoying bug that essentially uses an entire CPU when just sitting at menus.

The problem is the UI is constantly refreshing regardless of anything happening on the screen. It’s wasting energy constantly redrawing the screen. That uses more electricity, generates more heat, requires the fan to spin up. The sum of all that is a noisy, inefficient computer that costs more than it should.

Here’s the official explanation:

XBMC was originally written for the XBox game console, which is a single-threaded system (not a multi-tasking OS like Windows). As such, it was written in a game loop, rather than being event-driven. This means that the screen refreshes as fast as possible in order to “feel” responsive to the user. What this boils down to is that while sitting on the idle screen, XBMC is still repainting the screen at 60-90 frames per second (as can be seen by the FPS number if debug mode is enabled). This takes up a lot of processor power, because the “game” is still running, even though you may not be doing anything with it.

There have been purported fixes that include setting the screensaver to “blank”, messing around with the vsync settings and even telling XBMC to quit if it’s idle. I’ve tried all of these over the years but the closest I’ve got is about 50% CPU. Obviously turning it off helps but that’s not really practical for me.

But with the recent release of XBMC Eden there’s a new solution in town that does work. Two new options have been added: <algorithmdirtyregions /> and <nofliptimeout /> work together to intelligently manage how portions of the screen are repainted, essentially allowing only the bits that change to be redrawn.

And using them is really very simple. Obviously you’ll need to upgrade to Eden if you’re not already using it. If you’re using Ubuntu, that’s as simple as:

sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get upgrade

Then just edit ~/.xbmc/userdata/advancedsettings.xml and make it look like the following:

<advancedsettings>
<gui>
<algorithmdirtyregions>1</algorithmdirtyregions>
<nofliptimeout>0</nofliptimeout>
</gui>
</advancedsettings>

You’ll need to restart XBMC after changing this.

If you get screen tearing or artefacts you might want to tweak those values. Have a look at the Wiki page on dirty regions for more details.

If you already have settings in <advancedsettings /> you’ll have to merge them together. It’s not hard but if you’re struggling with the XML syntax, just leave a comment and I’ll try to help.

The result is clear. 50-100% CPU down to 5-10% and it’s almost silent now. As it should be.

htop

But what about Boxee?

If you’re still using Boxee, you’re out of luck. Boxee is based on XMBC but this is quite a recent change and Boxee have essentially said they’re killing off their builds for Windows, OSX and Linux. Version 1.5 was the last official build we’ll ever get.

While you might love Boxee (I certainly used to), they don’t love you. Take this prompt to give XBMC a proper try. I used to dislike how it did some things differently but Eden is a really solid player with some beautiful skins and it’s grown beyond Boxee in many places.

Another option that seems to be on the horizon is Plex. XBMC-based, again and while the Linux client isn’t quite there yet, it looks interesting. They’ve separated out the scanning and library functions into a dedicated server which should allow lighter clients sharing a common library.