Firefox/Iceweasel high CPU usage when idle

Firefox is called Iceweasel in the Debian SO because of trademark issues. I’ll use the name Iceweasel since that’s what I tested but everything here’s applicable to Firefox.

This came to my attention thanks to user SynrG in the #debian IRC channel. When Iceweasel is just idling in some sites it will eat an unreasonable amount of CPU time even when nothing is being updated on the screen. This was tested browsing Facebook but it’s not specific to this site. The high CPU usage went away just switching to another tab with an unaffected site open. It’s more noticeable on old hardware, like my netbook, with a fake dual-core Intel Atom CPU, it was around 100% all the time and made the computer lag. More powerful multi-core CPUs will see an inferior usage and maybe no lag but still some CPU time is wasted by Iceweasel when idle. Disabling Javascript will do nothing so it isn’t some Javascript running in the background.

The problem lies in CSS3 animations. There’s a bug in Iceweasel that makes it refresh the page even when nothing is changing whenever there’s a animation property set to an element even when the element is hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=962594.

The easy fix is disabling animations but since this can’t be done with any preference setting we need to use user styles as a workaround. This can be useful to solve the problem until this bug gets a proper fix.

You just need to put a userContent.css file in a chrome folder inside your profile folder. If you want to disable the animation property for all sites you can use these lines:

* {
  -moz-animation: none !important;
  animation: none !important;
 }

In case you don’t want to disable animations for all sites but just a few look at the following example for Facebook:

@-moz-document domain(facebook.com) {
* {
  -moz-animation: none !important;
  animation: none !important;
 }
}

More information about matching options in the MDN.

Advertisements