apulse icon indicating copy to clipboard operation
apulse copied to clipboard

Low framerate with Firefox 54

Open paradigm opened this issue 7 years ago • 5 comments

I'm using Arch Linux's latest firefox build, Arch Linux's pulseaudio, and both apulse and apulse-git from Arch Linux's AUR.

I'm using this video as a test reference point: https://www.youtube.com/watch?v=1La4QzGeaaQ

With apulse, I'm getting very low framerate. I'd guess maybe 5-10 fps.

With apulse-git, I'm getting very low framerate. I'd guess maybe 5-10 fps.

With pulseaudio, it looks like a smooth 60.

With either apulse nor pulseaudio, it looks like a smooth 60 but, naturally, no sound.

paradigm avatar Jun 20 '17 15:06 paradigm

I think Firefox relies on libpulse.so to provide synchronization events. On the other hand, apulse does not generate such events by itself. It asks ALSA to do it. But there is no guarantee that actual period sizes will be the same as requested. Most of the time they are larger. And that effectively decreases framerate.

To fix that, I need to reimplement the same feature in apulse. I'll need to think about implementation details.

i-rinat avatar Jul 15 '17 11:07 i-rinat

I don't know if this might be related, but when I start up KDE on my Slackware, the framerate is extremely low there as well. Reinstalling the PulseAudio package fixes the low framerate, while using this repository's apulse wrapper seems to cause KDE to be next to unusable due to slowness.

All the CPU usage seems to come from the kmix mixer modules.

cxd4 avatar Jul 17 '17 05:07 cxd4

I have some interesting info on this. While tinkering with my setup, I noticed that fps changes depending on .asoundrc contents!

  • My .asoundrc with very complex setup: 12-15fps.
  • .asoundrc with something simple like defaults.pcm.card 1: 39-45fps (for 60fps video).

(I measured it on YouTube with variety of videos, using layers.acceleration.draw-fps from about:config)

After some playing around with a bunch of values, it seems that period_size in pcm definition has this effect on performance. Explicitly setting it to default value boosts framerate to watchable levels.


Steps to (hopefully) improve framerate (note that all values are only examples):

  1. Backup your .asoundrc (and/or asound.conf if you have it):
mv .asoundrc .asoundrc.bak
  1. Play some audio:
ALSA_CARD=PCH mpg123 music.mp3
  1. (While playing audio) Follow this section of ArchWiki to get something along these lines:
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 16384

The period_size value is what you're looking for. 4. You can now bring back your .asoundrc. You need the pcm with dmix plugin that goes into your pcm.!default. Put information you got in 3 there:

pcm.sound {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:PCH,0"
        format S32_LE
        rate 48000
        period_size 1024
        buffer_size 16384
    }
}

I hope it will make videos watchable for anyone having this problem (if not then try with very minimal .asoundrc or using ALSA_CARD environment varible without .asoundrc).

Keep in mind that this is not a fix. It will improve the framerate, and 30fps are now okay, but max framerate is still 45fps, while framerate with pulseaudio is 60fps.

P.S. I also tried toggling almost everything connected to video or audio in about:config in hopes that some option cancels this strange fps drop, but sadly no result.

E100Beta avatar Sep 05 '17 16:09 E100Beta

Any progress on this issue?

crabctrl avatar Feb 09 '21 21:02 crabctrl

Any progress on this issue?

Sadly, no.

i-rinat avatar Feb 10 '21 17:02 i-rinat