Solved Firefox audio high CPU usage

Seems the time for "peripheral" problems for me. Firefox-40.0_3,1 uses over 100% of one CPU, reaches up to 200% when I am playing videos (HTML5 not Flash, normal mode, not zoomed).

www/firefox and www/libxul compiled with standard options except OPTIMIZED_CFLAGS disabled (caused problems in the past). Audio option is ALSA also compiled with standard options.

Have not changed anything audio related in about:config.

Hardware acceleration set ON or OFF changed nothing.
 
Last edited:
There is clearly a performance issue with Firefox 40 on FreeBSD (Linux ?).
I made a test :
I am running emulators/virtualbox-ose on my desktop computer with Windows XP SP3 in a VM.
I ran Firefox 40 for Windows in it and watched a video on Youtube.
I ran top(1) in a console on the host. Here is the result :
Code:
last pid:  6101;  load averages:  0.87,  0.88,  0.58  up 0+00:37:47  15:29:55 58 processes:  1 running, 57 sleeping
CPU:  6.1% user,  0.0% nice, 30.2% system,  0.0% interrupt, 63.7% idle
Mem: 568M Active, 511M Inact, 2325M Wired, 31M Buf, 534M Free
ARC: 1568M Total, 673M MFU, 878M MRU, 32K Anon, 4718K Header, 12M Other
Swap: 4096M Total, 4096M Free

  PID USERNAME  THR PRI NICE  SIZE  RES STATE  C  TIME  WCPU COMMAND
4748 xxxxxx  22  20  0  927M  565M select  1  5:09  42.43% VirtualBox
  813 root  1  20  0  3254M 71256K select  1  1:43  2.39% Xorg

Now here is the result for top(1) when playing the same Youtube video into Firefox 40 on the host :
Code:
last pid:  6719;  load averages:  1.41,  1.04,  0.71  up 0+00:42:06  15:34:14 52 processes:  1 running, 51 sleeping
CPU: 25.7% user,  0.0% nice, 43.1% system,  0.4% interrupt, 30.8% idle
Mem: 499M Active, 497M Inact, 1936M Wired, 192K Cache, 31M Buf, 1006M Free
ARC: 1612M Total, 685M MFU, 909M MRU, 739K Anon, 4879K Header, 13M Other
Swap: 4096M Total, 4096M Free

  PID USERNAME  THR PRI NICE  SIZE  RES STATE  C  TIME  WCPU COMMAND
1058 xxxxxx  61  20  0  881M  493M uwait  0  4:43 118.31% firefox
  813 root  1  31  0  3241M 59700K select  0  2:11  17.19% Xorg
 
It's nearly never with videos under 120% (with approx. other 12 tabs), most time 145-150%.
Code:
24102 user  94  27  0  1447M  1003M uwait  0  23:36 119.19% firefox
.

Same video with vlc (stream)
Code:
CPU:  3.7% user,  0.0% nice,  1.2% system,  0.3% interrupt, 94.8% idle
Mem: 814M Active, 2256M Inact, 1066M Wired, 4644K Cache, 825M Buf, 3781M Free
Swap:

  PID USERNAME  THR PRI NICE  SIZE  RES STATE  C  TIME  WCPU COMMAND
67637 user  14  30  0  709M  102M uwait  3  0:05  8.50% vlc
 
Last edited:
Same problem. Firefox reached 152%, this is insane. Any workaround yet?

Is it possible to compile Firefox without Gstreamer or with another multimedia backend?
 
I compiled firefox-41.0b2. It plays the videos with normal CPU usage.
Had also a problem with this version playing videos - freezes firefox and segfaulted. In the example .mozconfig was --enable-optimized and some other optimizing flags. This causes the segfault (alsa segfaulted with jemalloc). After removed this it works. I attached a neede .mozconfig file, cause to prevent the example files in the net and on the mozilla site.
But this could not be the reason for the CPU usage of the current version of firefox. OPTIMIZED_FLAGS are OFF and the patch-memory-jemalloc-Makefile.in turned other optimations off.

I don't like pulseaudio, but may a try worth? (Only for the recent version ?). I not tested it yet. It seems it's definite not gstreamer causes this.

Explanation here:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Mercurial
(I compiled it with gcc5 without further problems).
Edit: A little correction for the attached .mozconfig file: should bie --enable-default-toolkit="cairo-gtk2" - don't accepted only gtk2.
 

Attachments

  • .mozconfig.txt
    891 bytes · Views: 396
I compiled firefox-41.0b2. It plays the videos with normal CPU usage.
Very good.
I think I will wait for the next release in the port tree.
I have tested gstreamer alone and it run well with hardware acceleration (vaapi + vdpau).
 
It is interesting firefox 40 - high CPU, verion 41 - normal and version 42 - high CPU (ok 42 is not ready yet). I hope they it fix till release.
 
I have tested it only with a few videos in the moment. But it seems I found it. I commented out in the Makefile under BUILD_DEPENDS
Code:
libvpx>=1.3.0:${PORTSDIR}/multimedia/libvpx
and compile firefox (normal version 40) new.
Seems now normal CPU usage. Please, test it also, and tell me, if I am right.
(Only one video has higher usage, but after reload it was normal).
Maybe, it will be good to make an option for libvpx in the Makefile.
 
Last edited:
I have tested it only with a few videos in the moment. But it seems I found it. I commented out in the Makefile under BUILD_DEPENDS
Code:
libvpx>=1.3.0:${PORTSDIR}/multimedia/libvpx
and compile firefox (normal version 40) new.
Seems now normal CPU usage. Please, test it also, and tell me, if I am right.
(Only one video has higher usage, but after reload it was normal).
Maybe, it will be good to make an option for libvpx in the Makefile.


Just did it and sorry, didn't help much. The CPU usage dropped from ~150%+ to ~120%. It is something, but not enough.

Thanks for the tip anyway.
 
Nice, It works also for me !
Code:
last pid: 35384;  load averages:  0.35,  0.38,  0.37  up 0+13:04:45  20:48:06
50 processes:  1 running, 49 sleeping
CPU: 13.0% user,  0.0% nice,  7.4% system,  0.2% interrupt, 79.4% idle
Mem: 326M Active, 479M Inact, 2914M Wired, 3328K Cache, 109M Buf, 215M Free
ARC: 2358M Total, 592M MFU, 1319M MRU, 32K Anon, 24M Header, 423M Other
Swap: 4096M Total, 4096M Free

  PID USERNAME  THR PRI NICE  SIZE  RES STATE  C  TIME  WCPU COMMAND
33469 xxxxxx  60  20  0  912M  465M uwait  1  3:56  15.09% firefox
  814 root  1  26  0  3240M 53824K select  0  25:42  10.16% Xorg
But I always have some glitches on video and when I move my mouse cursor over the Youtube page, video is stalling for short time. Video acceleration problem ?
That's why I usually download videos before playing them with MPlayer.
 
But I always have some glitches on video and when I move my mouse cursor over the Youtube page, video is stalling for short time. Video acceleration problem ?
Cannot reproduce this.
 
Cannot reproduce this.

My video adapter is a Nvidia GT 520 and I am using nvidia-driver-346.47 (x11/nvidia-driver).
I get that in about:support page of Firefox :
Code:
Graphics
Adapter Description   NVIDIA Corporation -- GeForce GT 520/PCIe/SSE2
Asynchronous Pan/Zoom   none
Device ID   GeForce GT 520/PCIe/SSE2
Driver Version   4.5.0 NVIDIA 346.47
GPU Accelerated Windows   0/1 Basic
Supports Hardware H264 Decoding   false
Vendor ID   NVIDIA Corporation
WebGL Renderer   NVIDIA Corporation -- GeForce GT 520/PCIe/SSE2
windowLayerManagerRemote   false
AzureCanvasBackend   cairo
AzureContentBackend   cairo
AzureFallbackCanvasBackend   none
AzureSkiaAccelerated   0
 
Says not much, I have an other card and an other driver, but the rest is the same output.
You may attach a file with the output of portsopt -r in the www/firefox port. (If you have not installed it is
ports-mgmt/portsopt). Maybe I see something in the options of the dependencies.
 
To correct the above with libvpx: The maintainer writes me: comment out libvpx in the Makefile has no effect. If I want to to this I had to touch Makefile.local and put in USE_MOZILLA+= -vpx to disable this.
 
I have the same. But about:config said media.gmp-gmpopenh264.enabled;true. It is puzzling.
I haven't got this option in Firefox 40 under FreeBSD but I get media.gmp-gmpopenh264.version;1.4 in Firefox 40 for Windows under Virtualbox.
Don't have media.gmp-gmpopenh264.enabled option on any Firefox browser.
 
They are slightly different in FreeBSD, Linux/Iceweasel (I have lubuntu 15.04) and seems also in Windows. I have abandoned Windows with XP and think never in my life I will install a Windows-system.
 
It's the video codec plugin from Cisco but it's not installed on Firefox for FreeBSD.
 
about plugins: (on my -FreeBSD - system - it is installed)
Code:
OpenH264 Video Codec provided by Cisco Systems, Inc.
File: 1.4.0
Path: /home/ngorx/.mozilla/firefox/g15ah0zi.default/gmp-gmpopenh264/1.4.0
Version: 1.4.0
State: Enabled

There is a format error: if I write colon and p the tongue-smiley appears (see about:plugins).
 
They are slightly different in FreeBSD, Linux (I have lubuntu 15.04) and seems also in Windows. I have abandoned windows with xp and think never in my life I will install a windows-system.
I am using Windows XP under VirtualBox as a trash system or for some specific software, but FreeBSD is my favorite OS since 1999.
 
Back
Top