Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Firefox high cpu usage on audio playback
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
bwqr
n00b
n00b


Joined: 26 Nov 2022
Posts: 2

PostPosted: Sat Nov 26, 2022 10:58 am    Post subject: [Solved] Firefox high cpu usage on audio playback Reply with quote

Hi everyone,

I have a problem starting from firefox 105 to latest build. Generally speaking, whenever any sound is played from the firefox such as listening music from soundcloud or watching videos from youtube, the cpu usage of firefox goes to 50 percent for one thread. When I mute the video or the sound, cpu usage goes down to 5 percent. And unmuting restores the issue. I could not reproduce this issue on other firefox binaries like firefox on flathub and official linux binary distributed by firefox from their website. Here is the link to the bug I have opened on mozilla, https://bugzilla.mozilla.org/show_bug.cgi?id=1796606 . You can find more information in the bug description.
I want to point out these things:
1. I am using pipewire as the sound server.
2. IIRC this issue started with llvm 15 release.

The output of emerge --info firefox

Code:

Portage 3.0.38.1 (python 3.10.8-final-0, default/linux/amd64/17.1, gcc-12, glibc-2.36-r5, 6.0.9-gentoo-bwqr-x86_64 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.0.9-gentoo-bwqr-x86_64-x86_64-AMD_Ryzen_5_5600X_6-Core_Processor-with-glibc2.36
KiB Mem:    32775504 total,  10746472 free
KiB Swap:   18874320 total,  18218732 free
Timestamp of repository gentoo: Fri, 25 Nov 2022 00:45:01 +0000
Head commit of repository gentoo: 0fb2c226b8688b3e2c70318b62d08d312abff3a2
sh bash 5.1_p16-r2
ld GNU ld (Gentoo 2.39 p5) 2.39.0
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           3.10.8_p3::gentoo, 3.11.0_p2::gentoo
dev-lang/rust:             1.65.0::gentoo
dev-util/cmake:            3.24.3::gentoo
dev-util/meson:            0.64.0::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/openrc:           0.45.2-r1::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.39-r4::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/clang:           14.0.6-r1::gentoo, 15.0.5::gentoo
sys-devel/gcc:             11.3.1_p20221007::gentoo, 12.2.1_p20221008::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/lld:             15.0.5::gentoo
sys-devel/llvm:            14.0.6-r2::gentoo, 15.0.5::gentoo
sys-devel/make:            4.4::gentoo
sys-kernel/linux-headers:  6.0::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts:
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

guru
    location: /var/lib/layman/guru
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/apache2-php8.1/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cgi-php8.1/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/php/cli-php8.1/ext-active/ /etc/php/fpm-php7.4/ext-active/ /etc/php/fpm-php8.1/ext-active/ /etc/php/phpdbg-php7.4/ext-active/ /etc/php/phpdbg-php8.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j12"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RUSTFLAGS="-C link-arg=-fuse-ld=lld"
SHELL="/bin/bash"
USE="acl amd64 bzip2 cli crypt dri elogind fortran gdbm iconv ipv6 libglvnd libtirpc lto multilib ncurses nls nptl openmp pam pcre pipewire readline screencast seccomp split-usr ssl test-rust unicode vaapi vulkan wayland xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby31" USERLAND="GNU" VIDEO_CARDS="radeon radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS

=================================================================
                        Package Settings
=================================================================

www-client/firefox-107.0::gentoo was built with the following:
USE="X clang dbus geckodriver gmp-autoupdate hwaccel lto openh264 screencast system-av1 system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-webp wayland -debug -eme-free -hardened -jack -libproxy -pgo -pulseaudio (-selinux) -sndio -system-png (-system-python-libs) -wifi" ABI_X86="(64)" L10N="-ach -af -an -ar -ast -az -be -bg -bn -br -bs -ca -ca-valencia -cak -cs -cy -da -de -dsb -el -en-CA -en-GB -eo -es-AR -es-CL -es-ES -es-MX -et -eu -fa -ff -fi -fr -fy -ga -gd -gl -gn -gu -he -hi -hr -hsb -hu -hy -ia -id -is -it -ja -ka -kab -kk -km -kn -ko -lij -lt -lv -mk -mr -ms -my -nb -ne -nl -nn -oc -pa -pl -pt-BR -pt-PT -rm -ro -ru -sco -si -sk -sl -son -sq -sr -sv -szl -ta -te -th -tl -tr -trs -uk -ur -uz -vi -xh -zh-CN -zh-TW"
CFLAGS="-march=native -pipe"
CXXFLAGS="-march=native -pipe"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--compress-debug-sections=zlib -Wl,-rpath=/usr/lib64/firefox,--enable-new-dtags"


If someone can help me to debug this issue, It will make me very happy.
Thanks.


Last edited by bwqr on Sun Nov 27, 2022 12:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
gorg86
Apprentice
Apprentice


Joined: 20 May 2011
Posts: 299

PostPosted: Sun Nov 27, 2022 7:04 am    Post subject: Reply with quote

YT and soundcloud are webrendering javascript garbage hell.
Could you try opening a plain sound file directly in the browser?

You compiled Firefox without pulseaudio... The Pipewire wiki states pulseaudio should be activated globally.
I don't know the technical reasons for that, but that should be the biggest difference between your and the official build (apart from the system-x flags).


Last edited by gorg86 on Sun Nov 27, 2022 4:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
bwqr
n00b
n00b


Joined: 26 Nov 2022
Posts: 2

PostPosted: Sun Nov 27, 2022 12:38 pm    Post subject: Reply with quote

Thanks gorg86 for your post. Opening a simple audio file does also produce the same issue. However, after compiling the firefox with pulseaudio USE flag as you have suggested, the issue is gone :) . I must have missed the pulseaudio part in the pipewire wiki or it is added recently. I think there is a bug in firefox alsa backend or pipewire-alsa plugin. Anyway, I will inform the people in the mozilla bugtracker and let them decide to investigate further or not.

Again, thanks for your suggestion.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum