Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox no sound without PulseAudio #34596

Closed
notramo opened this issue Dec 17, 2021 · 18 comments
Closed

Firefox no sound without PulseAudio #34596

notramo opened this issue Dec 17, 2021 · 18 comments

Comments

@notramo
Copy link

notramo commented Dec 17, 2021

System

  • xuname:
    Void 5.15.5_1 x86_64-musl GenuineIntel uptodate rFF
    happens on also glibc
  • package:
    firefox

Expected behavior

Firefox can play audio even without PulseAudio.

Actual behavior

No web content can play any audio.

Steps to reproduce the behavior

  1. Install Firefox but not PulseAudio
  2. Open a webpage (or video/audio file) which plays sound
  3. No sound
@mvf
Copy link
Contributor

mvf commented Dec 18, 2021

Works for me on firefox-95.0.1_1 (glibc). You could try something like this:

$ strace -f -e open,openat firefox 2>&1 | grep /dev/snd

Might tell you what goes wrong when trying to open the ALSA device(s).

@biopsin
Copy link
Contributor

biopsin commented Dec 20, 2021

@notramo can you test with a /etc/asound.conf or ~/.asoundrc
$ aplay -l and insert your output card number into either file

defaults.pcm.card 1;
defaults.ctl.card 1;

then sudo alsactl store && sudo alsactl restore
Edit: typo

@ErinVoid
Copy link

Confirm Firefox, ESR and not, work well with Alsa only. Tweaking asound is required with some sound cards

@paper42
Copy link
Member

paper42 commented Jan 24, 2022

It seems like nobody is able to reproduce this issue and the issue author is not answering questions.

@paper42 paper42 closed this as completed Jan 24, 2022
@notramo
Copy link
Author

notramo commented Jul 15, 2022

@paper42 could you reopen? I looked into this.

@notramo
Copy link
Author

notramo commented Jul 15, 2022

Works for me on firefox-95.0.1_1 (glibc). You could try something like this:

$ strace -f -e open,openat firefox 2>&1 | grep /dev/snd

Might tell you what goes wrong when trying to open the ALSA device(s).

It doesn't print anything. No output in terminal.

@notramo
Copy link
Author

notramo commented Jul 15, 2022

@notramo can you test with a /etc/asound.conf or ~/.asoundrc $ aplay -l and insert your output card number into either file

defaults.pcm.card 1;
defaults.ctl.card 1;

then sudo alsactl store && sudo alsactl restore Edit: typo

I substituted 1 with 0, and put this snippet in /etc/asound.conf
Doesn't work.
Output of aplay -l:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CX20590 Analog [CX20590 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

@notramo
Copy link
Author

notramo commented Jul 15, 2022

Maybe it can help that Element Desktop doesn't have sound either.
But everything other works fine (QMplay2, VLC, Sox play, etc.). These work with no configuration (no /etc/asound.conf or .asoundrc).

@mvf
Copy link
Contributor

mvf commented Jul 15, 2022

$ strace -f -e open,openat firefox 2>&1 | grep /dev/snd

It doesn't print anything. No output in terminal.

Sorry, should have mentioned: You have to actually let Firefox try to play audio while running under strace.

@paper42 paper42 reopened this Jul 15, 2022
@Duncaen
Copy link
Member

Duncaen commented Jul 15, 2022

Its not supported upstream and generally works, I don't think we need to debug unsupported audio setups for you, this is most likely related to not using dmix and the alsa hardware device being locked to some random audio stream that opens the device first.

@notramo
Copy link
Author

notramo commented Jul 19, 2022

@Duncaen Could you link where upstream mentions that ALSA is not supported? I thought Cubeb was made for supporting multiple audio systems.

@notramo
Copy link
Author

notramo commented Jul 19, 2022

Sorry, should have mentioned: You have to actually let Firefox try to play audio while running under strace.

I tried to open sound files, but playback is stuck at 0:00.

@Duncaen
Copy link
Member

Duncaen commented Jul 19, 2022

https://bugzilla.mozilla.org/show_bug.cgi?id=1345661

Audio in firefox is a little more complicated than just the cubeb backend due to sandboxing and having separate content processes. Mozilla disabled alsa support a long time ago and basically said that they don't support it any further, there are still people who afterwards contributed patches to make it work and they landed upstream. But I fully understand why they don't support it, the alsa user experience and the api in general is simply not user friendly and doesn't work out of the box for most users.

I would suggest you to use a sound server, like pulse or pipewire, if you still want to use alsa for some reason, look up how to debug libcubeb and how to debug sandbox issues in firefox, both have their own environment variables for more verbose logging. (After you get your basic alsa setup working, I still think this is due to your setup neither supporting software nor hardware mixing and there is simply one random process/program locking the alsa device at a time.)

@Duncaen Duncaen closed this as completed Jul 19, 2022
@notramo
Copy link
Author

notramo commented Aug 21, 2022

In case someone runs into this, I have found a simpler solution.

  1. Install and start sndiod
  2. Firefox will automatically use it
  3. If the sndio ALSA plugin is not installed, then the other apps will still use ALSA.
  4. Only problem is that it can't play audio from multiple apps simultaneously if your card doesn't support mixing (but this is a problem with pure ALSA too). Also, if the sound card was used by another app at the time Firefox wants to play audio, you have to restart Firefox (closing the other app is not enough).

@Duncaen
Copy link
Member

Duncaen commented Aug 21, 2022

You shouldn't be using alsa-sndio regularly, I wrote it 5 years ago and it doesn't work well, especially not when you need audio/video synchornization and is basically unmaintained. It will never work correctly because the alsa plugin api does not provide functionality to actually get matching buffers negotiated between the alsa plugin and sndiod.

Its really not worth the trouble, just use a well supported sound server to avoid unnecessary headaches/troubles.

@notramo
Copy link
Author

notramo commented Aug 21, 2022

I mean if sndio is installed, but not alsa-sndio, then Firefox uses sndio, everything other uses ALSA.
As sndiod only opens the card when Firefox is playing audio, then it's nearly the same experience as using pure ALSA.
I left these notes for advanced users who want pure ALSA, not Poettering™ sound server suckage.

@Duncaen
Copy link
Member

Duncaen commented Aug 21, 2022

"Poettering™ sound server suckage" works out of the box for 99% of linux users and they don't have to try to solve their actually broken setup for nearly a year. Comments like this just show why its not worth it to support unsupported setups, you just want the trouble for some weird superiority points.

Again, you shouldn't be using alsa-sndio, its not a solution, either you use sndio by using software that supports it or you use sndio only in firefox and basically break everything else that still uses alsa with alsa-sndio. 100% more broken than pulse or pipewire could ever be.

@notramo
Copy link
Author

notramo commented Aug 21, 2022

I emphasize, I don't have alsa-sndio installed. It's not needed. Because the OpenBSD devs did it right: the sndiod daemon only opens the card when it plays audio, then it releases when audio playback is stopped. If you control the sound system through ALSA (e.g. volume control via amixer), then it's the same as if it were pure ALSA (except you have Firefox working too).
Basically what I did:

  1. installed sndio
  2. started sndiod
  3. it just works like before, plus Firefox works too

I don't say everyone have to follow this configuration. I left these here for users who want minimalist setup. It's worth trying if someone wants this setup, and if it doesn't work, they can move on to other sound systems. It works for me, so it's possible that it will work for others. I do not recommend it, but if someone likes it, they can try.
I don't say anything from these instructions should be included in the packages or any packages should be changed, so it's pointless to debate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants