Bug 270436 - www/firefox: 111.0⋯: no sound after upgrade
Summary: www/firefox: 111.0⋯: no sound after upgrade
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-gecko (Nobody)
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2023-03-24 19:07 UTC by James B. Byrne
Modified: 2023-05-26 06:59 UTC (History)
19 users (show)

See Also:
bugzilla: maintainer-feedback? (gecko)
grahamperrin: maintainer-feedback? (kde)


Attachments
Experimental patch to firefox-112.0.1/modules/libpref/Preferences.cpp (1.02 KB, patch)
2023-04-18 08:44 UTC, Tatsuki Makino
no flags Details | Diff
Experimental patch to modules/libpref/Preferences.cpp (524 bytes, patch)
2023-04-20 03:35 UTC, Tatsuki Makino
no flags Details | Diff
Experimental patch to modules/libpref/Preferences.cpp for 113.0 (527 bytes, patch)
2023-05-13 04:59 UTC, Tatsuki Makino
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James B. Byrne 2023-03-24 19:07:00 UTC
Firefox 111.0.1 (64-bit) on FreeBSD-12.3p12

Following upgrade firefox no longer plays audio.  video works.

MPlayer plays audio/video clips correctly.
Comment 1 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2023-03-24 21:35:52 UTC
Works for me. Any exotic (i.e. non-pulse) audio backend?
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2023-03-25 18:55:20 UTC
Works for me. 

% pkg iinfo firefox
firefox-111.0_2,2
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #35 main-n261613-2b4b3789f877: Sun Mar 19 04:09:06 GMT 2023     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400083 1400083
% 


Incidentally, 12.3p12 is very close to end of life: 

<https://www.freebsd.org/security/#sup>
Comment 3 Nikolaj Thygesen 2023-03-25 23:15:21 UTC
I get exactly the same issue - video works - no audio. Everything was working before update to v111. All other apps like mpv, audacious and audacity still work.

media.cubeb.backend = oss

no pulseaudio installed

% pkg info firefox
firefox-111.0.1_2,2

% uname -aKU
FreeBSD XXX.dk 13.1-RELEASE FreeBSD 13.1-RELEASE fc952ac22 DIAMOND amd64 1301000 1301000
Comment 4 Nikolaj Thygesen 2023-03-26 09:12:59 UTC
... and btw, I get this when opening firefox:

console.error: ({})
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.

... and this every time I open e.g. a new youtube file:

[Child 1616, MediaDecoderStateMachine #1] WARNING: 83458ddc0 OpenCubeb() failed to init cubeb: file /construction/xports/www/firefox/work/firefox-111.0.1/dom/media/AudioStream.cpp:281
[Child 1616, MediaDecoderStateMachine #1] WARNING: Decoder=829a3d700 [OnMediaSinkAudioError]: file /construction/xports/www/firefox/work/firefox-111.0.1/dom/media/MediaDecoderStateMachine.cpp:4550
JavaScript warning: https://www.google.com/js/th/-i4BvPHlj92BuV6XzAqUG3CoaRx1Xg20dibDBHkkejI.js line 2 > eval line 6592 > eval line 1 > eval line 1 > eval, line 1: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2023-03-26 18:53:46 UTC
same here, no sound.
Comment 6 James B. Byrne 2023-03-27 14:37:45 UTC
FreeBSD-12.3p12
FreeBSD xx 12.3-RELEASE-p11 FreeBSD 12.3-RELEASE-p11 GENERIC  amd64

Updaated firefox this AM to 111.0.1_2,2 and no change in behaviour.  No audio.

$ pkg info firefox
firefox-111.0.1_2,2
Name           : firefox
Version        : 111.0.1_2,2
Installed on   : Mon Mar 27 10:27:44 2023 EDT
Origin         : www/firefox
Architecture   : FreeBSD:12:amd64
Prefix         : /usr/local
Categories     : www wayland
Licenses       : 
Maintainer     : gecko@FreeBSD.org
WWW            : https://www.mozilla.com/firefox
Comment        : Web browser based on the browser portion of Mozilla
Options        :
	ALSA           : off
	CANBERRA       : off
	DBUS           : on
	DEBUG          : off
	FFMPEG         : on
	JACK           : on
	LIBPROXY       : off
	LTO            : off
	OPTIMIZED_CFLAGS: on
	PROFILE        : on
	PULSEAUDIO     : on
	SNDIO          : on
	TEST           : off
Shared Libs required:
	libxcb.so.1
	libxcb-shm.so.0
	libwebpdemux.so.2
	libwebp.so.7
	libvpx.so.7
	libssl3.so
	libsmime3.so
	libpng16.so.16
	libplc4.so
	libpixman-1.so.0
	libpango-1.0.so.0
	libnssutil3.so
	libnss3.so
	libnspr4.so
	libicuuc.so.72
	libicui18n.so.72
	libharfbuzz.so.0
	libgtk-3.so.0
	libgobject-2.0.so.0
	libglib-2.0.so.0
	libgio-2.0.so.0
	libgdk_pixbuf-2.0.so.0
	libgdk-3.so.0
	libfreetype.so.6
	libfontconfig.so.1
	libffi.so.8
	libevent-2.1.so.7
	libdbus-glib-1.so.2
	libdbus-1.so.3
	libdav1d.so.6
	libcairo.so.2
	libcairo-gobject.so.2
	libatk-1.0.so.0
	libaom.so.3
	libXrandr.so.2
	libXfixes.so.3
	libXext.so.6
	libXdamage.so.1
	libXcomposite.so.1
	libX11.so.6
	libX11-xcb.so.1
Annotations    :
	FreeBSD_version: 1203000
	cpe            : cpe:2.3:a:mozilla:firefox:111.0.1:::::freebsd12:x64:2
	no_provide_shlib: yes
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 256MiB
Description    :
Mozilla Firefox is a free and open source web browser descended from the
Mozilla Application Suite. It is small, fast and easy to use, and offers
many advanced features:

 o Popup Blocking
 o Tabbed Browsing
 o Live Bookmarks (ie. RSS)
 o Extensions
 o Themes
 o FastFind
 o Improved Security

WWW: https://www.mozilla.com/firefox
[byrnejb_hll@vhost01 ~ (master)]$ firefox
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
console.error: (new UnknownError("IndexedDB: main/url-classifier-skip-urls getLastModified() IndexedDB:   The operation failed for reasons unrelated to the database itself and not covered by any other error code.", "resource://services-settings/IDBHelpers.jsm", 18))
console.error: ({})
console.error: (new TypeError("Cc[aContract] is undefined", "resource://gre/modules/XPCOMUtils.sys.mjs", 150))
JavaScript error: resource://gre/modules/XPCOMUtils.sys.mjs, line 150: TypeError: Cc[aContract] is undefined
JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
JavaScript error: resource://gre/modules/crypto-SDR.js, line 198: NS_ERROR_ABORT: User canceled primary password entry
console.error: "LoginManagerAuthPrompter: Epic fail in promptAuth: [Exception... \"User canceled primary password entry\"  nsresult: \"0x80004004 (NS_ERROR_ABORT)\"  location: \"JS frame :: resource://gre/modules/crypto-SDR.js :: decrypt :: line 198\"  data: no]\n"
console.warn: "nsPrompter: isThirdPartyURI failed: [Exception... \"Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrincipal.isThirdPartyURI]\"  nsresult: \"0x80070057 (NS_ERROR_ILLEGAL_VALUE)\"  location: \"JS frame :: resource://gre/modules/Prompter.sys.mjs :: openPrompt :: line 1131\"  data: no]"
console.warn: "nsPrompter: isThirdPartyURI failed: [Exception... \"Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrincipal.isThirdPartyURI]\"  nsresult: \"0x80070057 (NS_ERROR_ILLEGAL_VALUE)\"  location: \"JS frame :: resource://gre/modules/Prompter.sys.mjs :: openPrompt :: line 1131\"  data: no]"
console.warn: "nsPrompter: isThirdPartyURI failed: [Exception... \"Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrincipal.isThirdPartyURI]\"  nsresult: \"0x80070057 (NS_ERROR_ILLEGAL_VALUE)\"  location: \"JS frame :: resource://gre/modules/Prompter.sys.mjs :: openPrompt :: line 1131\"  data: no]"
JavaScript error: resource://gre/modules/TelemetrySession.sys.mjs, line 747: NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsITelemetry.msSinceProcessStartExcludingSuspend]
JavaScript warning: https://www.google.com/js/th/zSRPe1x9Qzj8HrqOv9VzSTVp8VQLU5DvkSPeJaRtFaU.js line 2 > eval line 2685 > eval line 1 > eval line 1 > eval, line 1: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
JavaScript warning: https://www.google.com/js/th/zSRPe1x9Qzj8HrqOv9VzSTVp8VQLU5DvkSPeJaRtFaU.js line 2 > eval line 2685 > eval line 1 > eval line 1 > eval, line 1: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
Comment 7 Mikael Urankar freebsd_committer freebsd_triage 2023-03-27 16:11:48 UTC
Got it working, in my case it's a wrong setting with the sound mixer in plasma5/kde
Comment 8 James B. Byrne 2023-03-27 17:14:23 UTC
I switched to firefox-esr and sound now works.  As no other changes were made the issue lies with Firefox.  I can switch back and forth between esr and current and current never has sound and esr always has sound.
Comment 9 Graham Perrin freebsd_committer freebsd_triage 2023-03-31 02:11:52 UTC
See also: <https://old.reddit.com/r/freebsd/comments/11yxd7x/-/jd9yh2d/?context=2> from a user of 13.1-release-p6.


(In reply to Mikael Urankar from comment #7)

> Got it working, in my case it's a wrong setting with the 
> sound mixer in plasma5/kde

Can you describe the wrongness? Thanks. 

<https://www.freshports.org/audio/plasma5-plasma-pa/>



(In reply to James B. Byrne from comment #6)

> FreeBSD-12.3p12 …

End of life is today; <https://www.freebsd.org/security/#sup>.
Comment 10 Mikael Urankar freebsd_committer freebsd_triage 2023-03-31 07:09:12 UTC
(In reply to Graham Perrin from comment #9)
If you click on the volume control there is a tab called "Applications" with a list of all applications that use the sound mixer. You can control where to send the sound for a particular application (with the 3 horizontal bar / hamburger button)
Comment 11 Tatsuki Makino 2023-04-03 00:11:31 UTC
I have experimented on 12.4-STABLE amd64 about firefox-111.0.1_2,2.
I could get sound normally.
However, the sound seems to be via PulseAudio and firefox appears in the pacmd list-sink-inputs results.
Is there something else wrong?
Comment 12 Tatsuki Makino 2023-04-03 01:11:59 UTC
It was a huge problem :)

I had to switch to oss following the "pkg info -D firefox" instructions.
If that is ok, restart firefox and when about:support is shown, Audio Backend is switched to oss.
If you still get sound with this setting, firefox is connected to "PulseAudio".
If so, you will lose sound when you run pactl exit.
The same behavior seems to occur when set to jack.
Comment 13 Tatsuki Makino 2023-04-03 04:35:42 UTC
(In reply to Tatsuki Makino from comment #12)

About this behavior.

cubeb_init in ${WRKSRC}/media/libcubeb/src/cubeb.c has an array of function pointers called default_init.
The about:config media.cubeb.backend seems to be the setting for setting init_oneshot here.

After this, it seems to run default_init all in sequence...
init_oneshot (== oss, jack, sndio) will fail.
init_oneshot (== pulse-rust) will success.
pulse_rust_init will success.

If it works that way, then that is why only PulseAudio can get sound.
Comment 14 Tatsuki Makino 2023-04-03 07:56:11 UTC
(In reply to Tatsuki Makino from comment #13)

This guess is also slightly off, as the backend_name received by cubeb_init is NULL.
sCubebBackendName in ${WRKSRC}/dom/media/CubebUtils.cpp is missing the value of media.cubeb.backend.

I don't know why it is failing to pick up, but that is why init_oneshot is also not executed with NULL, and pulse_rust_init, which is the first one to execute successfully, is used.
Comment 15 Tatsuki Makino 2023-04-04 04:34:52 UTC
Further additions.

firefox-111.0.1_2,2:
PULSEAUDIO in OPTIONS does not seem to have any effect on the code?

firefox-112.0,2:
For some reason, those built with the default options do not seem to be able to output sound via PulseAudio. (Is it just my environment?)
media.cubeb.backend has no effect on the actual sound output destination. Be careful about misunderstanding because it affects the content of about:support.
Since PulseAudio fails, it is assumed that the sound is output to JACK if JACK is running and to sndio otherwise.
Comment 16 Mathias.Picker 2023-04-04 09:36:19 UTC
pkg-message states "To force a specific backend open `about:config` page and create`media.cubeb.backend` preference." and this did work since a few weeks ago.

Now I also have pulseaudio started and sound via pulseaudio, and I have to manually switch pulseaudio to a working audio device before I hear any sound.

Annoying, but I don't have any time to look into this.
Comment 17 Tatsuki Makino 2023-04-05 06:10:09 UTC
Further additions.

firefox-112.0,2:
If sndio is selected for audio output, it seems necessary that sndiod be running.
It is one of the conditions for no sound output.

# derailment
In the case of chromium-111.0.5563.147, it seems to output sound via sndio when sndiod is running and directly to oss when not running.
Comment 18 Marco Beishuizen 2023-04-05 10:24:57 UTC
Had the same problem using sndio, but after restarting sndiod it works.
Comment 19 Tatsuki Makino 2023-04-06 07:31:52 UTC
Further additions.

firefox-112.0,2:
If it is built with all AUDIO options (ALSA, JACK, PULSEAUDIO and SNDIO) turned off, it will fall down to OSS and this will get sound fine.

I embedded some lines in the source code similar to the following ones and built it.

MOZ_LOG(gCubebLog, LogLevel::Error, ("%s %d %s: %s", __FILE__, __LINE__, __func__, "..."));
LOG("%s %d: default_init[%d] = %p", __FILE__, __LINE__, i, default_init[i]);

Then I started firerox with the following options

firefox -P exp-release --no-remote "--MOZ_LOG=cubeb:5" --private-window

This profile has media.cubeb.backend set to oss in about:config.

The following logs were obtained thereby. Just the important parts,

[Parent 44314: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Parent 44314: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 216 GetPrefAndSetString: value.IsEmpty
  ︙
[Child 44354: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 44354: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 222 GetPrefAndSetString: aStorage(oss)
  ︙
[Child 44391: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 44391: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 222 GetPrefAndSetString: aStorage(oss)
  ︙
[Child 44427: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 44427: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 216 GetPrefAndSetString: value.IsEmpty
  ︙
[Child 44428: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 44428: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 216 GetPrefAndSetString: value.IsEmpty
  ︙
[Child 44429: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 44429: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 216 GetPrefAndSetString: value.IsEmpty
  ︙
[Child 47086: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 213 GetPrefAndSetString: Preferences::GetCString(media.cubeb.backend)
[Child 47086: Main Thread]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 216 GetPrefAndSetString: value.IsEmpty
  ︙
[Child 44427: MediaSupervisor #3]: E/cubeb /usr/ports/www/firefox/work/firefox-112.0/dom/media/CubebUtils.cpp 598 GetCubebContextUnlocked: cubeb_init((null))
[Child 44427: MediaSupervisor #3]: E/cubeb cubeb.c:276:/usr/ports/www/firefox/work/firefox-112.0/media/libcubeb/src/cubeb.c 276: default_init[0] = 0x0
[Child 44427: MediaSupervisor #3]: E/cubeb cubeb.c:276:/usr/ports/www/firefox/work/firefox-112.0/media/libcubeb/src/cubeb.c 276: default_init[1] = 0x809770b50

For some reason, sometimes the preference reads correctly for this, and sometimes it is empty.
When I played YouTube, the preference is not readable, so the backend override is not working. (default_init[0] = 0x0)
Comment 20 rkoberman 2023-04-09 17:37:02 UTC
t  Adding more confusion to the whole thing, I updated to 112.0_1,2 yesterday and now many youtube videos lack audio, but not all. 112.0,2 seemed to work fine. I have media.cubeb.backend set to OSS on a recent build of FreeBSD 14 (head). firefox was build from source with SNDIO, ALSA enabled. Of course, OSS is always present. All ports are current as of about 10:15 UTS today (Arp-9).

If I play some new video, silence, but playing an older video, I get sound.
https://www.youtube.com/watch?v=cwLRQn61oUY has audio. 7 years old.
https://www.youtube.com/watch?v=M3QKXViWwZQ no audio. 8 days old.

I downloaded the files and both were webm with OPUS audio streams. muediainfo shows identical audio characteristics. If I play the audio files, both played.

I'll admit that this is a rather small sample and I am not a heavy YouTube user, so additional testing is needed and I will try to do some today.

I am suspicious that some dependency of Firefox was updated and that is the actual trigger, but I can't see what.
Comment 21 Tatsuki Makino 2023-04-10 07:36:15 UTC
It seems that firefox-112.0_1,2 built with default options is back to the same behavior as firefox-111.0.1_2,2.

media.cubeb.backend has no effect on the actual sound output.
First, try to output with pulse-rust. It can stop by echo autospawn = no >> ~/.config/pulse/client.conf
If jackd* is running, the next step is to try to output using JACK.
If JACK was not available, then sndio is next. When using sndio, it doesn't seem to mean that the output failed even if sndiod is not running. If sndiod was not running, there is no sound because there is no route to the final oss.
This should be followed by alsa and oss, but we won't get there.

In other words, it would be better not to have SNDIO enabled by default, at least to reduce the possibility of no sound.
Comment 22 Newton Terry 2023-04-10 12:13:54 UTC
Upgrade www/firefox package to 112.0,2 broke sound, with sndio audio backend, on amd64 13.2-RELEASE.

Sound works with local media file when set audio backend to oss, but not web media streams.

On my system audio/sndio is installed as a dependency to another application. It comes with a "sndiod" rc.d script. After enabling and running the service, sound is there again (obviously with sndio as audio backend).
Comment 23 rkoberman 2023-04-11 21:21:33 UTC
Looks like a clear case of backend selection. I built firefox with all audio backends disabled. That leaves only OSS. All all files I have played are now playing audio.
Comment 24 Tatsuki Makino 2023-04-12 02:01:13 UTC
This is the case with firefox-112.0_1,2 with the optional ALSA turned on, SNDIO turned off.

If the ALSA settings are left at default and nothing is done, we will get sound output.
If we intentionally fail to set up ALSA (e.g. echo foobar >> ~/.asoundrc), we will not be able to get sound output.

There is no falldown to OSS.
This will also be one of the conditions under which sound output cannot be get.
Comment 25 James B. Byrne 2023-04-13 18:06:59 UTC
The recent update to firefox-esr 102.10.0,1  now exhibits the same problem.  No sound.
Comment 26 Dave Cottlehuber freebsd_committer freebsd_triage 2023-04-15 01:57:21 UTC
- default pkgs ungoogled-chromium pulls in sndio
- firefox 112.0_1,2 no sound for youtube, webrtc
- playing a file:/// mp3 works fine though
- old tricks of setting media.cubeb.backend=oss is not sufficient
- sndio is present but not enabled

- cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <USB audio> at ? kld snd_uaudio (1p:2v/0r:0v) default
        snddev flags=0x200002e3<SIMPLEX,AUTOVCHAN,BUSY,MPSAFE,REGISTERED,VPC,PRIO_WR>
        [pcm0:play:dsp0.p0]: spd 48000, fmt 0x00200010/0x00201000, flags 0x00002108, 0x00000006
        interrupts 365110, underruns 0, feed 365109, ready 0 [b:6144/3072/2|bs:4096/2048/2]
        channel flags=0x2108<TRIGGERED,BUSY,HAS_VCHAN>
        {userland} -> feeder_mixer(0x00200010) -> feeder_format(0x00200010 -> 0x00201000) -> {hardware}
        pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp0]: spd 44100/48000, fmt 0x00201000/0x00200010, flags 0x1000110c, 0x0000002b, pid 72933 (firefox)
        interrupts 0, underruns 0, feed 2960429, ready 16400 [b:0/0/0|bs:131072/65536/2]
        channel flags=0x1000110c<RUNNING,TRIGGERED,BUSY,HAS_SIZE,VIRTUAL>
        {userland} -> feeder_root(0x00201000) -> feeder_format(0x00201000 -> 0x00200010) -> feeder_volume(0x00200010) -> feeder_rate(0x00200010 q:1 44100 -> 48000) -> {hardware}
        pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp1]: spd 48000, fmt 0x00200010, flags 0x10000000, 0x00000021
        interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:8192/1024/8]
        channel flags=0x10000000<VIRTUAL>
        {userland} -> feeder_root(0x00200010) -> feeder_volume(0x00200010) -> {hardware}
No devices installed from userspace.

I'll try running sndio and see if things work as expected.
Comment 27 Dave Cottlehuber freebsd_committer freebsd_triage 2023-04-15 13:45:11 UTC
quick update - using sndiod may be a workaround for people impacted by this.

- running `sndiod -s default -ddd` in a terminal
- change media.cubeb.backend = sndio in firefox
- restart

I have working audio both from local mp3 and from youtube/invidious but
can't test webrtc yet, maybe somebody with a webcam can try out
 https://janus.conf.meetecho.com/echotest.html

ungoogled-chromium has a hard dependency on libsndio even though it doesn't
appear to use it at runtime by default.

my about:support audio section:

Audio Backend	sndio
Max Channels	8
Preferred Sample Rate	48000
Roundtrip latency (standard deviation)	NaNms (NaN)
Codec Support Information	H264 SW
VP8 SW
VP9 SW
AV1 SW
Theora SW
AAC SW
FLAC SW
MP3 SW
Opus SW
Vorbis SW
Wave SW
Output Devices
Name 	Group 	Vendor 	State 	Preferred 	Format 	Channels 	Rate 	Latency
default	default		Enabled	All	default: S16LE, support: S16LE	8	default: 48000, support: 4000 - 192000	480 - 9600
Input Devices
Name 	Group 	Vendor 	State 	Preferred 	Format 	Channels 	Rate 	Latency
default
Comment 28 Jan Beich freebsd_committer freebsd_triage 2023-04-17 12:54:31 UTC
To emulate media.cubeb.backend=oss in binary packages one can neutralize dlopen(3) usage in cubeb consumers via libmap.conf(5) e.g.,

$ cat /usr/local/etc/libmap.d/no-pulse.conf
[firefox thunderbird rpcs3 yuzu yuzu-cmd citra citra-qt]
libpulse.so.0 /dev/null
libpulse.so /dev/null

$ cat /usr/local/etc/libmap.d/no-jack.conf
[firefox thunderbird rpcs3 yuzu yuzu-cmd citra citra-qt]
libjack.so.0 /dev/null
libjack.so /dev/null

$ cat /usr/local/etc/libmap.d/no-sndio.conf
[firefox thunderbird rpcs3 yuzu yuzu-cmd citra citra-qt]
libsndio.so.7.2 /dev/null
libsndio.so /dev/null

$ cat /usr/local/etc/libmap.d/no-alsa.conf
[firefox thunderbird rpcs3 yuzu yuzu-cmd citra citra-qt]
libasound.so.2 /dev/null
libasound.so /dev/null
Comment 29 Tatsuki Makino 2023-04-18 03:58:52 UTC
${WRKSRC}/modules/libpref/Preferences.cpp have variables sDynamicPrefOverrideList and sRestrictFromWebContentProcesses.

I don't know what these variables mean.
Could someone please build firefox with media.cubeb.backend added to either or both of these variables?

It may or may not make sense.
Again, I don't know what they mean :)
Comment 30 Tatsuki Makino 2023-04-18 04:31:00 UTC
(In reply to Tatsuki Makino from comment #29)

These variables are like this...

static const PrefListEntry sRestrictFromWebContentProcesses[] = {
static const PrefListEntry sDynamicPrefOverrideList[]{

What does it mean that the sDynamicPrefOverrideList is not as follows?

static const PrefListEntry sDynamicPrefOverrideList[] = {

Maybe this code isn't used?
Comment 31 Tatsuki Makino 2023-04-18 08:44:55 UTC
Created attachment 241556 [details]
Experimental patch to firefox-112.0.1/modules/libpref/Preferences.cpp

The profile used for the experiment has media.cubeb.backend set to oss.
If firefox-112.0.1_1,2 is built with the default option set, PulseAudio will be used as usual, but with this patch, it seems to use dsp directly.
This patch needs to be checked by someone familiar with Firefox to see if it is a fix for media.cubeb.backend to work properly :)
Comment 32 Tatsuki Makino 2023-04-18 09:15:08 UTC
By the way, does Firefox-112.0.1_1,2 not be able to use sndio? :)
Comment 33 David 2023-04-18 09:18:26 UTC
fwiw I have tested firefox-esr:
- 102.8.0
- 102.9.0
- 102.10.0

and firefox:
- 112.0.1_1,2

I have the 'media.cubeb.backend=oss' set on each of these profiles.

all on 14.0-CURRENT , with none of these working via laptop speakers. However, they ALL work via earphones.

so I'm beginning to think this isn't necessarily a problem with firefox and oss, but something else.
Comment 34 Tatsuki Makino 2023-04-19 04:00:44 UTC
My comment #32 is a failure of my make config.

To use the attachment 241556 [details], use it as follows.
patch -d ${WRKDIR} < attachment-241556
patch -d ${WRKSRC} -p 1 < attachment-241556

I tried firefox-112.0.1_1,2 built by the following method.
The options is default.
make -C /usr/ports/www/firefox rmconfig
make -C /usr/ports/www/firefox clean patch
patch -d ${WRKDIR} < attachment-241556
make -C /usr/ports/www/firefox build deinstall install

Result.
media.cubeb.backend works.
The following falldown works fine.
selected by media.cubeb.backend -> pulse-rust -> jack -> sndio (-> alsa) -> oss
sndio and alsa cannot detect sound output failures. So, in order to fall down to OSS, it is essential that the SNDIO and ALSA options are off.

I'm not sure why attachment 241556 [details] fixes it, so someone take it upstream :)
Comment 35 Jan Beich freebsd_committer freebsd_triage 2023-04-20 00:22:39 UTC
(In reply to Tatsuki Makino from comment #30)
> What does it mean that the sDynamicPrefOverrideList is not as follows?
> 
> static const PrefListEntry sDynamicPrefOverrideList[] = {

Initialization without copy. See https://en.cppreference.com/w/cpp/language/list_initialization
Comment 36 Tatsuki Makino 2023-04-20 03:35:40 UTC
Created attachment 241608 [details]
Experimental patch to modules/libpref/Preferences.cpp

(In reply to Jan Beich from comment #35)
Thank you, I understood.
For that reason, the patch was reworked by make makepatch.
It seems that this file can be used by placing it in www/firefox/files/ .
It doesn't seem to cause any difference in behavior due to the difference in that part.

When media.cubeb.backend is set to jack, JACK is used when JACK is working normally, and PulseAudio is used when JACK is stopped.
Comment 37 Graham Perrin freebsd_committer freebsd_triage 2023-04-22 14:23:01 UTC
(In reply to David from comment #33)

> … all on 14.0-CURRENT , with none of these working via laptop speakers. 
> However, they ALL work via earphones.

With a USB headset, I heard nothing until after the (reportedly) running sndiod was restarted. 

Sound in Thunderbird and Tor Browser was OK without the restart. 

% pkg iinfo firefox thunderbird tor-browser
firefox-112.0.1_1,2
thunderbird-102.10.0_2
tor-browser-12.0.2_6
% cat /dev/sndstat
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play)
pcm1: <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <IDT 92HD81B1X (Analog)> (play/rec)
pcm3: <USB audio> (rec)
pcm4: <USB audio> (play/rec) default
No devices installed from userspace.
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #38 main-n262032-5e2e3615d91f: Fri Apr  7 18:54:28 BST 2023     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400085 1400085
% service sndiod status
sndiod is running as pid 2358.
%
Comment 38 James B. Byrne 2023-05-05 13:14:49 UTC
Problem persists in FF-112

Media
Audio Backend	oss
Max Channels	8
Preferred Sample Rate	48000
Roundtrip latency (standard deviation)	NaNms (NaN)
Codec Support Information	
Output Devices
Name 	Group 	Vendor 	State 	Preferred 	Format 	Channels 	Rate 	Latency
/dev/dsp0: NVIDIA (0x0051) (HDMI/DP 8ch)	/dev/dsp0		Enabled	None	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
/dev/dsp1: NVIDIA (0x0051) (HDMI/DP 8ch)	/dev/dsp1		Enabled	None	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
/dev/dsp2: Realtek ALC892 (Rear Analog 5.1/2.0)	/dev/dsp2		Enabled	All	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
/dev/dsp3: Realtek ALC892 (Front Analog)	/dev/dsp3		Enabled	None	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
/dev/dsp4: Realtek ALC892 (Rear Digital)	/dev/dsp4		Enabled	None	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
Input Devices
Name 	Group 	Vendor 	State 	Preferred 	Format 	Channels 	Rate 	Latency
/dev/dsp2: Realtek ALC892 (Rear Analog 5.1/2.0)	/dev/dsp2		Enabled	All	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
/dev/dsp3: Realtek ALC892 (Front Analog)	/dev/dsp3		Enabled	None	default: S16LE, support: S16LE	2	default: 48000, support: 48000 - 48000	0 - 0
Comment 39 Tatsuki Makino 2023-05-10 23:15:04 UTC
It looks like firefox-113.0_1,2 has made some changes to ${WRKSRC}/modules/libpref/Preferences.cpp, but they do not seem to fix this problem.
Turning off SNDIO and ALSA option, or building with patch-modules_libpref_Preferences.cpp from attachment 241608 [details] in www/firefox/files directory, is still a valid way to get oss to choose.
Comment 40 Tatsuki Makino 2023-05-13 04:59:01 UTC
Created attachment 242137 [details]
Experimental patch to modules/libpref/Preferences.cpp for 113.0

There seems to be no difference between firefox-113.0_1,2 and firefox-113.0.1,2 regarding this.
There is fuzz in the patch so it will be new.
Comment 41 commit-hook freebsd_committer freebsd_triage 2023-05-26 03:50:18 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ea1e7e4df533eadce4c3ee65e99cda8a662220c1

commit ea1e7e4df533eadce4c3ee65e99cda8a662220c1
Author:     Tatsuki Makino <tatsuki_makino@hotmail.com>
AuthorDate: 2023-04-18 08:44:55 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-05-26 03:48:41 +0000

    www/firefox: respect media.cubeb.backend

    PR:             270436

 www/firefox/Makefile                     |  1 +
 www/firefox/files/patch-bug1427152 (new) | 10 ++++++++++
 2 files changed, 11 insertions(+)
Comment 42 commit-hook freebsd_committer freebsd_triage 2023-05-26 03:50:22 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3deaf6913605e4e234d9c7542140f8982b54facd

commit 3deaf6913605e4e234d9c7542140f8982b54facd
Author:     Tatsuki Makino <tatsuki_makino@hotmail.com>
AuthorDate: 2023-04-18 08:44:55 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-05-26 03:49:38 +0000

    www/firefox: respect media.cubeb.backend

    PR:             270436
    (cherry picked from commit ea1e7e4df533eadce4c3ee65e99cda8a662220c1)

 www/firefox/Makefile                     |  1 +
 www/firefox/files/patch-bug1427152 (new) | 10 ++++++++++
 2 files changed, 11 insertions(+)
Comment 43 Jan Beich freebsd_committer freebsd_triage 2023-05-26 03:58:08 UTC
Thanks. Landed. I've renamed the patch file to reference a similar bug upstream.
Comment 44 Hans Petter Selasky freebsd_committer freebsd_triage 2023-05-26 06:59:07 UTC
Thanks for fixing this!

Last time I looked at this, I noticed the variable was loaded too late, after cubeb was initialized, and there is no possibility to change the cubeb backend runtime currently.

--HPS