Nixpkgs: Sound broken in Firefox 72 (ALSA)

Created on 6 Feb 2020  路  24Comments  路  Source: NixOS/nixpkgs

Describe the bug
After the upgrade to Firefox 72.0.1, sound no longer works in Firefox. (It continues to work in other programs.)

It used to work in 71.0, but after I got the upgrade to 72.0.1 (with the fix for CVE-2019-17026 -- thanks for that!), things got very quiet. The subsequent upgrade to 72.0.2 did not fix it.

I'm seeing the same on nixos-19.09 and nixos-unstable, on 3 different machines. All have sound.enable = true; and no pulseaudio.

Workaround

Use the firefox-esr package. (Firefox 68.4.2esr)

To Reproduce
Steps to reproduce the behavior:

  1. Install Firefox 72 (either the firefox package or firefox-bin)
  2. Go to some site that should play sound. Eg: https://www.youtube.com/watch?v=4fWyzwo1xg0
  3. Listen to the silence

Expected behavior

Sound should come out of the speakers.

Additional context
Add any other context about the problem here.

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.91, NixOS, 19.09.git.7e1f60dfbba (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.2`
 - channels(root): `"nixos-19.09.1662.8e4c9d15456"`
 - channels(aij): `"nixpkgs-19.03pre154584.c65da8b5111"`
 - nixpkgs: `/etc/nixos/aij/stable`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
 - firefox
 - firefox-bin
# a list of nixos modules affected by the problem
module:
bug regression

All 24 comments

I'll need to dig into this more later, but if I capture stdout, this appears when I click the play button

[Child 30774, MediaDecoderStateMachine #1] WARNING: 7f4098ccdfc0 OpenCubeb() failed to init cubeb: file /build/firefox-72.0.2/dom/media/AudioStream.cpp, line 317
[Child 30774, MediaDecoderStateMachine #1] WARNING: Decoder=7f4097f99800 [OnMediaSinkAudioError]: file /build/firefox-72.0.2/dom/media/MediaDecoderStateMachine.cpp, line 3689

Same applies to my setup; latest Firefox, Nix package manager on Debian Linux, ALSA only system.
On Firefox's about:support page, Audio Backend: (remote error).
It seems that it looks for pulseaudio, which is the default sound backend for Firefox now.
Any way to install/build latest Firefox on Nix (package manager and NixOS) using ALSA?

I found the build logs at https://hydra.nixos.org/build/111006171 and I saw it was configured with --enable-alsa --enable-pulseaudio. So, it should be enabled, though I wonder if building without pulseaudio support might make a difference...

@krackout Does sound work for you with the Debian package? What version is that on?

Yes, sound works with Debian Firefox. Yet Debian comes with Firefox ESR only, currently 68.5. That's why I'm using Nix's Firefox.
I used to have sound on my ALSA only system from Nix Firefox until v70 if I recall well.

I was suggested to try this:
create ~/.config/nixpkgs/overlays/firefox-alsa-overlay.nix

self: super: { firefox = self.wrapFirefox (super.firefox-unwrapped.override { pulseaudioSupport = false; alsaSupport = true; }); }
I removed Firefox, garbage collected to clear everything, reinstall but still no sound.

I'm currently looking into this. It seems to have been introduced with 8eb6c64404021e22e34d1c8c9f64ce0a9a7cca99. So I'll try looking at what happaned in mozilla-central with that release.

@rnhmjoj Did you check that? It's been a while, but I thought I had verified that it still worked in 71.0, IIRC I had tracked it down to 40018e5987766639bda5fb97fe22396028e4e2bd.

In any case, I also concluded it's an upstream issue. I suspect it was caused by the cubeb upgrade that happened in that release, but I didn't track it down further.

I ended up installing pulseaudio since I care more about sound working in Firefox than elsewhere, and I didn't have time to dig into this more.

In any case, I would be more than happy to test a real fix.

I'll also test it, should any fix comes. I'm still running alsa only and using Debian's Firefox ESR and Waterfox.

@rnhmjoj Did you check that?

Yes, I have just tried after yet another user reported this issue to me.

I spent the last two days trying to downgrade cubeb in firefox 71 but I couldn't getting it to build or producing any meaningful error. The firefox build system is just too much for any sane person. I guess I'll try the other way: debugging and figure why it's failing in 71.

Thanx for the effort rnhmjoj. Is there any way to help? I'm not a developer but have significant admin experience.

Uhm... I don't know, you could try opening an issue in firebug. However alsa is not supported anymore so we probably won't get much cooperation.

Oh, btw it's possibile to avoid installing pulseaudio by running firefox with apulse. Copying this from the Gentoo wiki

Alsa-only systems might work around this limitation by using media-sound/apulse. For this to work you'll need to modify Firefox sandbox settings by going to about:config and adding /dev/snd/ (note the trailing slash) to security.sandbox.content.write_path_whitelist option.

If you're storing ALSA settings in /home, also, be sure to add /home/<username>/.asoundrc to the security.sandbox.content.write_path_whitelist option. Whitelist path could be separated by comma.

Since around Firefox 58 there is additional modification needed to work around seccomp sandbox: security.sandbox.content.syscall_whitelist = 16

Now you can go ahead and create alias for running firefox through apulse:

$ alias firefox='apulse firefox-bin'

Yes, I've heard about apulse. Haven't tried it, I'm a bit skeptic about compromising firefox's sandbox.

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

The issue still persists on Firefox 81, no sound on ALSA only system. Tried it using firefox-alsa-overlay.nix also, same result.

In Firefox's about:support -> Media, Audio Backend (remote error)

Some googling around says that apparently Firefox has required Pulseaudio since release 52, see release notes.

That's evidently false, since it was working for people here with 68ESR and up to version 71, but if they haven't revised that decision, this might just be an upstream bug, which they might not intend to resolve.

It is indeed a deliberate change (not a bug to be resolved unfortunately) in Firefox, the hardcoded requirement for Pulse. Yet Mozilla has (had at least) left the the ability to compile using alsa support, albeit without some new sound features. Firefox from Nix packages still had sound support on alsa until v70 if I recall well. But now it doesn't, even with --enable-alsa.

Mozilla stopped supporting ALSA because no one wanted to maintain their backend but it's still working.
Other distros are still building Firefox and using it: for whatever reason is now broken, this is a problem in Nixpkgs.

I created a pull request which fixes the issue. I tested it on an ALSA only system and had sound.

ALSA is not actively maintained according to this cubeb/wiki/Backend-Support, so I am unsure how well it works though but it probably works well enough for those wanting it.

@S-NA is there any way to install it using your pull request now? I've just updated to firefox 82 but still no sound on alsa.

I don't think it's possible to apply the same fix without patching nixpkgs.
Since all the PR does is adding alsaLib to LD_LIBRARY_PATH, you could try to do that manually.
Try this, it seems to work for me:

LD_LIBRARY_PATH="$(nix-build '<nixpkgs>' -A alsaLib --no-out-link)/lib" firefox

@rnhmjoj I tried it, still no sound; I'm not much into Nix, could have messed Firefox installation with the overlays I've tried in the past in search for a solution. I'll remove everything and re-try. Thank you all for the effort.

@krackout: The PR has been merged and I backported the commit to NixOS 20.09 and 20.03.
It should be fixed in the next channel update.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

teto picture teto  路  3Comments

sid-kap picture sid-kap  路  3Comments

rzetterberg picture rzetterberg  路  3Comments

ayyess picture ayyess  路  3Comments

grahamc picture grahamc  路  3Comments