Bug 246449 - www/chromium: enable PulseAudio by default.
Summary: www/chromium: enable PulseAudio by default.
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Robert Nagy
URL:
Keywords: feature, needs-qa
Depends on:
Blocks:
 
Reported: 2020-05-13 21:07 UTC by Tomasz "CeDeROM" CEDRO
Modified: 2024-05-07 14:42 UTC (History)
9 users (show)

See Also:
bugzilla: maintainer-feedback? (chromium)


Attachments
flavorize-chromium-on-audio-backends (3.14 KB, patch)
2024-05-05 17:07 UTC, Yuri Victorovich
no flags Details | Diff
patch adding slave ports (2.70 KB, patch)
2024-05-05 19:17 UTC, Yuri Victorovich
no flags Details | Diff
[PATCH] www/chromium: implement selectable audio backend support (20.02 KB, patch)
2024-05-06 11:05 UTC, Robert Nagy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz "CeDeROM" CEDRO 2020-05-13 21:07:22 UTC
Hello world :-) 

I was just about to report request to enable PulseAudio by default in Chrome just as it is in Firefox, but I found this thread that requests disabling the PulseAudio by default:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216327

PulseAudio distinguishes input and output devices and the sound streams so you can list them and adjust parameters such as volume per stream rather than per device. This is really important for WebRTC where you can easily and quickly switch between different devices for instance web camera microphone or internal laptop microphone or external microhpne.

In Firefox that uses PulseAudio I can see many input devices and I can select among them. In Chromium that uses only ALSA by default I can see only "default" microphone and this is not the one that works nor any other input device.

I did a compilation of Chromium with PulseAudio enabled but each pkg update tells me it wants to replace it with a binary that has defaults (no PulseAudio).

Is PulseAudio still not welcome in Chromium by default?

Best regards,
Tomek
Comment 1 Jonathan Vasquez 2022-04-28 16:25:14 UTC
I'm experiencing an issue as well but not sure if it's due to this or some other weirdness. But I've noticed that on my framework laptop on FreeBSD 14.0-CURRENT #0 main-n255077-490a0f77de7, Chromium ignores my mute requests (either via Fn key or KDE Plasma UI), but respects volume increase / decrease requests. Firefox however respects all three and will (un)mute immediately.
Comment 2 Peter TKATCHENKO 2023-01-22 19:34:15 UTC
I would like to see PulseAudio enabled by default in Chromium too. My microphone does not work in WebRTC using default Chromium, it works correctly in Chromium built with PulseAudio enabled. The only problem is that to build Chromium I need to use an external server, and it takes 12+ hours. It is impossible to build the port on a laptop (needs to much RAM).
Maybe, a good solution would be a slave port, something like 'chromium-pulseaudio'.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-04 02:06:28 UTC

*** This bug has been marked as a duplicate of bug 278521 ***
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-05-04 02:07:44 UTC
A commit in branch main references this bug:

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

commit 89e432ced730385869e5bf6df4b705facbd1c947
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-05-04 02:02:20 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-05-04 02:06:57 +0000

    www/chromium: Change default audio output to PULSEAUDIO to make chromium to play nice with desktop environments

    PR:             278521 246449
    Approved by:    chromium@FreeBSD.org (maintainer's timeout; 4 years on bug#246449)

 www/chromium/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 5 Robert Nagy freebsd_committer freebsd_triage 2024-05-05 08:43:38 UTC
Yes this is wrong. Please revert your commit. The proper way of doing this is to have chromium pick what audio backend to use by default, so if you have pulseaudio installed it will pick that and fall back to sndio by default.
I will implement this in the coming weeks.
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 08:53:42 UTC
(In reply to Robert Nagy from comment #5)

In addition to this chromium should also allow the user to choose what audio backend to use, regardless of what backends are installed.
Comment 7 Jonathan Vasquez 2024-05-05 10:39:44 UTC
I'm guessing chromium doesn't support OSS since I don't see it in the port's list of backends?
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-05-05 16:10:56 UTC
A commit in branch main references this bug:

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

commit 762aa0135a4e18d32bd27bba5266fe6edd769d82
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-05-05 15:51:10 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-05-05 16:09:08 +0000

    Revert "www/chromium: Change default audio output to PULSEAUDIO to make chromium to play nice with desktop environments"

    This reverts commit 89e432ced730385869e5bf6df4b705facbd1c947.

    Reason: Several people complained that the PulseAudio dependency is a lot heavier than Sndio.

    This is currently a controversial issue because:
    1. PulseAudio is indeed a heavier dependency compared to Sndio,
       so for people who prefer minimalistic setup Sndio should be a default.
    2. Currently desktop environments work best with PulseAudio, so
       it is better for average users to have PulseAudio as a default backend.

    It would be best if www/chromium would allow to change audio backend at-startup
    or on-the-fly without the need to change port options.

    This can be achieved by the following methods:
    1. Flavorizing www/chromium based on audio backends.
    2. Creating slave ports with different audio backends.
    3. Implementing on-the-fly or at-startup setting of the audio backend.

    In https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246449#c5 Robert Nagy <rnagy@FreeBSD.org>
    volunteered to implement audio backend dependency in a proper way.

    I've suggested that the item 3. above is a proper way for chromium.

    PR:     246449

 www/chromium/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Comment 9 Peter TKATCHENKO 2024-05-05 16:33:44 UTC
I perfectly understand the people who don't like Pulseaudio and don't wont to see Chromium installs it by default. But sorry, guys, sndio just does not work for many important web apps (like MS Teams for example) in case of multiple in/out channels!! If I install Chromium, having Firefox already installed as a default browser - it's just because some apps work only with Chromium, and Chromium with sndio does not work correctly. Chromium is an application that really heavy to build, I'm doing it since many months and I have many issues with upgrade of packages because of Chromium installed from port (just because of Pulseaudio option). 

If Pulseaudio active by default is not good for someone - please, find another solution to be able to install Chromium with Pulseaudio from package.
Comment 10 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 16:43:09 UTC
Additionally, I don't see how can this be implemented such that PulseAudio isn't a dependency, and that backends would be able to be switched at run-time or start-time. This two are obviously a conflicting requirements.

I think that the best solution in the meantime is to flavorize this port.
This is fairly easy to do, and this would satisfy needs of users of all kinds.

Would there be any objection to flavorization?
desktop@FreeBSD.org - do you have any objections?


Yuri
Comment 11 Peter TKATCHENKO 2024-05-05 17:05:25 UTC
Me too, I don't think that switching at run-time is possible (or, maybe, it would be possible if the port is built WITH Pulseaudio option).
I think the flavorization is the best option now.
Comment 12 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 17:07:52 UTC
Created attachment 250463 [details]
flavorize-chromium-on-audio-backends

I am proposing an easy solution to flavorize the port.
This should satisfy all categories of users.

Attaching the patch for desktop@FreeBSD.org approval.

I'll be testing its build in the meantime.

In case a better solution is found in the meantime or later - it would be very welcome.
Comment 13 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 17:08:36 UTC
(In reply to Yuri Victorovich from comment #12)

Correction:
* approval should be from chromium@FreeBSD.org
Comment 14 Tomoaki AOKI 2024-05-05 18:23:34 UTC
(In reply to Yuri Victorovich from comment #12)

Looking into FLAVORS section of poudriere manpage [1], anyone who have
  *installed www/chromium,
  *building home blew pkgs with poudriere with `poudriere -a`,
  *and have FLAVOR_DEFAULT_ALL set
would be severy bitten by forced builds of multiple www/chromium with your flavorization.

Slave ports (www/chromium-alsa and www/chromium-sndio, restoring pulseaudio by default for average desktop environment users) would be preferrable here.

Note that if www/chromium is light-weighted-to-build enough (for example, finishes building on slowest supported environments in 5 minutes or so), flavorizing should be preferrerd.

[1] https://man.freebsd.org/cgi/man.cgi?poudriere(8)
Comment 15 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 18:55:49 UTC
I'm working on adding slave ports.
Comment 16 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 19:17:56 UTC
Created attachment 250470 [details]
patch adding slave ports

I am attaching the slave ports patch.

Could anybody please review them and see if anything might be wrong or improved?

I would also appreciate if anybody with more computing resources could build all 3 of them and verify that they work. (It would take me days to do this.)


Thank you,
Yuri
Comment 17 Robert Nagy freebsd_committer freebsd_triage 2024-05-05 19:56:39 UTC
I don't see any reason for slave ports. The patch I am working on will do the right thing by default without adding any dependencies and allow you to specify which audio backend to use if you do not want the 'auto' mode.
Comment 18 Yuri Victorovich freebsd_committer freebsd_triage 2024-05-05 20:36:02 UTC
(In reply to Robert Nagy from comment #17)

+1
Comment 19 Jonathan Vasquez 2024-05-05 20:49:13 UTC
I'll be interested in taking a look at the solution when it's ready Robert. Thank you!
Comment 20 Tomoaki AOKI 2024-05-05 21:26:03 UTC
(In reply to Robert Nagy from comment #17)

Sounds great! Looking forward to see it.
FYI: www/chromium at commit 89e432ced730385869e5bf6df4b705facbd1c947
     required 10.5 hours on my ThinkPad P52 with 32GB of memory and 6C12T.
     If I missingly configured/started poudriere on it, it could become
     at least 3 times longer for 3 backends. This is because I hesitated
     flavorization way.
Comment 21 Oleh Hushchenkov 2024-05-06 05:00:12 UTC
(In reply to Robert Nagy from comment #17)

Thank you Robert.

Please don't forget about ALSA backend.
Comment 22 Robert Nagy freebsd_committer freebsd_triage 2024-05-06 11:05:13 UTC
Created attachment 250489 [details]
[PATCH] www/chromium: implement selectable audio backend support

with these changes, chromium now automatically selects which
audio backend to use in the following order:

pulse (if running) -> sndio (if running) -> alsa -> fake

an additional command line option has been also implemented so
that the user can force which backend to use:

--audio-backend={auto,sndio,pulse,alsa}
Comment 23 Jonathan Vasquez 2024-05-06 12:53:49 UTC
Thanks for that Robert. I took a brief look at the changes. Just to confirm, it seems the port doesn't have any audio system being pulled in (other than Pipewire which is primarily used on Linux from my understanding - I haven't been keeping much track of its state). My main question is with that mentioned, I'm guessing it's the responsibility of the user to install whatever backend they want beforehand so that when Chromium runs at runtime, it will detect and reuse the one on the system? If that's the case that sounds good since it does indeed avoid Chromium having to pull in unnecessary dependencies. This is also assuming that Chromium has the needed support to communicate with those backends without having to pull the main sound dependencies themselves (for linking purposes or what not).
Comment 24 Robert Nagy freebsd_committer freebsd_triage 2024-05-06 12:58:59 UTC
(In reply to Jonathan Vasquez from comment #23)

Well not really. Chromium depends on alsa-lib and sndio. Pulseaudio is dlopen'd so you do not have to have it installed.
Comment 25 Oleh Hushchenkov 2024-05-06 13:10:31 UTC
Is there a way to download binary package for testing?
Comment 26 Robert Nagy freebsd_committer freebsd_triage 2024-05-07 09:22:47 UTC
(In reply to Oleh Hushchenkov from comment #25)

I have a 13.3 amd64 package here: https://nerd.hu/chromium-124.0.6367.118_2.pkg
Comment 27 Oleh Hushchenkov 2024-05-07 09:43:13 UTC
(In reply to Robert Nagy from comment #26)

I installed it on 14-STABLE.
Audio works, microphone in online tester also works.
Can't try any video conferencing now.

How I can check which audio backend is active?
No pulseaudio installed, only sndio and alsa-libs.

Thanks.
Comment 28 Robert Nagy freebsd_committer freebsd_triage 2024-05-07 09:48:36 UTC
(In reply to Oleh Hushchenkov from comment #27)

Well I can add some debug info for that as well, but for now you can run with
--enable-logging=stderr and see if it falls back from Pulse -> Sndio -> Alsa -> Fake as it logs in case it falls back in auto mode.
Comment 29 Oleh Hushchenkov 2024-05-07 10:16:24 UTC
(In reply to Robert Nagy from comment #28)

With --enable-logging=stderr I can see how it falls back pulse -> sndio.

When I use --audio-backend={sndio,alsa} switch no logs, but audio works in the same way.

I have no running sndio server, but it's running in sndio server less mode, as I understand.

So alsa backend can be used only with --audio-backend=alsa switch? In auto mode it's unreachable?

Thanks.
Comment 30 Robert Nagy freebsd_committer freebsd_triage 2024-05-07 11:20:50 UTC
(In reply to Oleh Hushchenkov from comment #29)

Yes that seems to be correct, however I think that's fine because I don't find
ALSA quiet useful. If sndio does not work for you, you have other problems.
Comment 31 Oleh Hushchenkov 2024-05-07 14:42:07 UTC
(In reply to Robert Nagy from comment #30)

Probably you are right. At least skype echo test works with sndio.

I tested sndio and alsa backends with --audio-backend switch, but I can't test pulse. Maybe someone else will do it.

Thank you Robert.