Bug 270642 - www/firefox: 112.0: no sound with sndio backend
Summary: www/firefox: 112.0: no sound with sndio backend
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-gecko (Nobody)
URL: https://www.freshports.org/audio/sndio/
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2023-04-04 16:54 UTC by Piotr Smyrak
Modified: 2023-06-29 05:00 UTC (History)
6 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Smyrak 2023-04-04 16:54:02 UTC
Upgrading Firefox to 112 with sndio backend breaks audio playback. Immediate downgrade to the previous version restores the playback.

Port options for www/firefox on the repro system:
OPTIONS_FILE_SET+=CANBERRA
OPTIONS_FILE_UNSET+=DBUS
OPTIONS_FILE_UNSET+=DEBUG
OPTIONS_FILE_UNSET+=FFMPEG
OPTIONS_FILE_UNSET+=LIBPROXY
OPTIONS_FILE_UNSET+=LTO
OPTIONS_FILE_SET+=OPTIMIZED_CFLAGS
OPTIONS_FILE_SET+=PROFILE
OPTIONS_FILE_UNSET+=TEST
OPTIONS_FILE_UNSET+=ALSA
OPTIONS_FILE_UNSET+=JACK
OPTIONS_FILE_UNSET+=PULSEAUDIO
OPTIONS_FILE_SET+=SNDIO

The following messages are present in the console, when the browser attempts to play a media:

[Child 38822, MediaDecoderStateMachine #1] WARNING: 82f78b140 OpenCubeb() failed to init cubeb: file /usr/ports/www/firefox/work/firefox-112.0/dom/media/AudioStream.cpp:281
[Child 38822, MediaDecoderStateMachine #1] WARNING: Decoder=82b368400 [OnMediaSinkAudioError]: file /usr/ports/www/firefox/work/firefox-112.0/dom/media/MediaDecoderStateMachine.cpp:4564

Sites used for audio output testing:
* http://hpr.dogphilosophy.net/test/
* https://tools.woolyss.com/html5-audio-video-tester/?u=woolyss.com/f/caminandes-1-llama-drama-av1-opus.webm
* youtube.com
Comment 1 Tatsuki Makino 2023-04-05 05:03:36 UTC
Similar report is in bug 270436.

If that downgrade is 111.x, is PulseAudio used for playback?

(I happened to do a little research over the past few days and it seems that there is something wrong with the way the output destination is selected...)
Comment 2 Piotr Smyrak 2023-04-05 13:12:20 UTC
(In reply to Tatsuki Makino from comment #1)
I have searched for duplicates and did not found the bug #270436. Perhaps because I searched specifically for reports concerning version 112.

In my case both Firefox versions the downgraded firefox-111.0.1_2,2, and the current 112.0,2 are compiled with the same set of options and based on sndio. I do not have PulseAudio installed at all.
Comment 3 Newton Terry 2023-04-10 12:11:18 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 4 Denis Shaposhnikov 2023-04-11 20:25:44 UTC
Same problem here. If sndiod isn't running, firefox plays youtube without sound and any value of "media.cubeb.backend" doesn't change it. I tried to set it to "oss" or "sndio" with no luck. Only `service sndiod start` helps.
Comment 5 Jan Beich freebsd_committer freebsd_triage 2023-04-12 02:37:51 UTC
Likely regressed by https://bugzilla.mozilla.org/show_bug.cgi?id=1814359, so I've filed https://github.com/mozilla/cubeb/issues/746.
Note, using libsndio without sndiod (daemon) was always buggy e.g., see bug 218188.
Comment 6 Piotr Smyrak 2023-04-12 07:07:04 UTC
(In reply to Jan Beich from comment #5)
I do have the sndiod daemon running:

$ sysrc sndiod_enable
sndiod_enable: YES

Although as Tatsuki suggested, I need to restart it to make 112 play sound.
Comment 7 Tatsuki Makino 2023-04-12 09:50:10 UTC
Restarting sndiod has the effect of resetting the volume of each app, such as that displayed in sndioctl.
Comment 8 Jan Beich freebsd_committer freebsd_triage 2023-04-12 10:12:10 UTC
(In reply to Piotr Smyrak from comment #6)
> $ sysrc sndiod_enable
> sndiod_enable: YES

This checks the value in rc.conf(5) but not whether rc.d(8) script is running. For example, enabling a rc.d script via sysrc won't start it automatically:

$ sysrc sndiod_enable=YES
sndiod_enable:  -> YES
$ service sndiod status
sndiod is not running.

(In reply to Tatsuki Makino from comment #7)
> Restarting sndiod has the effect of resetting the volume of each app, such as that displayed in sndioctl.

Firefox shouldn't be able to change sndio's own volume after https://bugzilla.mozilla.org/show_bug.cgi?id=1467882
Comment 9 Piotr Smyrak 2023-04-12 10:33:09 UTC
(In reply to Jan Beich from comment #8)

> This checks the value in rc.conf(5) but not whether rc.d(8) script is running. > For example, enabling a rc.d script via sysrc won't start it automatically:

Ah, yes, I am aware of this. I made sure to check whether the daemon was running, just in my case with a plain old ps. And that it was functional, as I was able to get a sound output from another app. Perhaps I should have mentioned in the original report, that the issue manifests only in Firefox.
Comment 10 Jan Beich freebsd_committer freebsd_triage 2023-04-13 01:22:37 UTC
FWIW, OpenBSD has sndiod (daemon) enabled by default after https://github.com/openbsd/src/commit/4b02bc8359b3
Comment 11 Newton Terry 2023-04-14 06:36:19 UTC
Apparently sound in 112 (112.0,2) works with the sndio backend without problems when audio/sndio isn't installed. When installed the sndiod daemon must run to get sound.

See forums https://forums.freebsd.org/threads/upgraded-firefox-and-now-no-audio.88717/post-606766

I can confirm the finding of the user. After stopping the sndiod service and deleting audio/sndio audio works as expected.
Comment 12 rkoberman 2023-04-14 17:47:06 UTC
(In reply to Newton Terry from comment #11)
If audio/sndio  is not installed, I don't see how Firefox can use it. I think it's just falling through to use OSS which is always the audio of last resort. In my experience, unless you need some added feature from studio, pulse, or alsa, oss is the best and most reliable choice.

I build Firefox from ports with all audio options disabled and it works fine.
Comment 13 Piotr Smyrak 2023-04-15 08:52:24 UTC
I cannot reproduce anymore after upgrading Firefox to version 112.0.1.
Comment 14 Graham Perrin freebsd_committer freebsd_triage 2023-06-28 19:43:57 UTC
I have been bugged for months, still am. 

<https://www.youtube.com/watch?v=ANPEWk_-jdw>

> Need sound on your FreeBSD Desktop? Here's how! - YouTube

Cheers, Gary, but I can't hear you. 

Then: 


root@mowa219-gjp4-8570p-freebsd:~ # service sndiod status
sndiod is running as pid 2912.
root@mowa219-gjp4-8570p-freebsd:~ # service sndiod restart
Stopping sndiod.
Waiting for PIDS: 2912.
Starting sndiod.
root@mowa219-gjp4-8570p-freebsd:~ # 


Then back to Firefox and Control-R, finally Gary is audible. 

media.cubeb.backend is not set. 

% pkg iinfo firefox
firefox-114.0.2,2
% pkg -vv | grep -e url -e enabled -e priority
    url             : "pkg+http://pkg0.fra.freebsd.org/FreeBSD:14:amd64/latest",
    enabled         : yes,
    priority        : 4,
    url             : "https://alpha.pkgbase.live/current/FreeBSD:14:amd64/latest",
    enabled         : no,
    priority        : 0,
    url             : "file:///usr/local/poudriere/data/packages/1049-default",
    enabled         : no,
    priority        : 2
    url             : "file:///usr/local/poudriere/data/packages/main-default",
    enabled         : yes,
    priority        : 3
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n263799-f81be7a8318b-dirty: Mon Jun 26 22:09:58 BST 2023     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1400092 1400090
%
Comment 15 Tatsuki Makino 2023-06-28 21:38:49 UTC
115.0,2 works fine formedia.cubeb.backend settings.
However, I have not yet investigated whether 115.0 is working properly on its own or if it is the effect of the patch adopted in bug270436 :)

(In reply to Graham Perrin from comment #14)

In order for Firefox-115.0,2 built with default options to reliably output sound, media.cubeb.backend=oss setting is required.
Since 114, the about:support page has gone 💩, so use the method written in bug 261898 comment 8 to identify the backend actually used.

If media.cubeb.backend is not set, pulseaudio is used.
If pulseaudio fails to start, it will try to use jack.
If the connection to jack fails, it tries to use sndio.
If sndiod is not started and sndio cannot be used, it will not fall down to the next destination.
If SNDIO is disabled, it can reach oss, but it is not, so it needs to be prioritized by the configuration.
Comment 16 Graham Perrin freebsd_committer freebsd_triage 2023-06-29 04:58:06 UTC
(In reply to Tatsuki Makino from comment #15)

> … In order for Firefox-115.0,2 built with default options to 
> reliably output sound, media.cubeb.backend=oss setting is required. …

Thank you! 

This workaround is equally effective for me with inferior firefox-114.0.2,2. 

I had overlooked the significance of media.cubeb.backend-specific <https://github.com/freebsd/freebsd-ports/commit/ea1e7e4df533eadce4c3ee65e99cda8a662220c1> because at <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270436#c2> I was unaffected by the bug.
Comment 17 Graham Perrin freebsd_committer freebsd_triage 2023-06-29 05:00:39 UTC
(In reply to Tatsuki Makino from comment #15)

> … If sndiod is not started and sndio cannot be used, it will …

For clarity: 

* sndiod _is_ started (and so, I guess that Firefox treats it as usable)

* sound is not audible.