Bug 257639 - www/firefox: broken mic in WebRTC in 91.0
Summary: www/firefox: broken mic in WebRTC in 91.0
Status: Closed FIXED
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:
Keywords:
: 259662 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-08-05 15:43 UTC by Vladimir Druzenko
Modified: 2021-11-12 20:17 UTC (History)
7 users (show)

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


Attachments
v1 (use "git am") (49.59 KB, patch)
2021-09-08 19:26 UTC, Ghost
2khramtsov: maintainer-approval?
Details | Diff
v2 (use "git am") (26.24 KB, patch)
2021-09-09 17:45 UTC, Ghost
2khramtsov: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Druzenko freebsd_committer freebsd_triage 2021-08-05 15:43:24 UTC
12.2-p9 amd64.

Work fine in versions 90 and prior, but totally broken in 91.
Tested in Discord, Jitsi, Nextcloud Talk.

My suggestion is to revert last update before it fixed.
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2021-08-05 18:07:50 UTC
        ALSA           : off
        CANBERRA       : off
        DBUS           : off
        DEBUG          : off
        FFMPEG         : on
        JACK           : off
        LIBPROXY       : on
        LTO            : off
        OPTIMIZED_CFLAGS: on
        PROFILE        : off
        PULSEAUDIO     : off
        SNDIO          : off
        TEST           : off

about:support show sound system oss.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2021-08-05 21:32:01 UTC
I don't have a microphone to confirm but rebuild with default options to try other audio backends as decribed in pkg-message. Of available backends on FreeBSD upstream only tests "pulse-rust" while the rest are up to their respective communities.

Sometimes running unit tests helps expose bugs e.g.,

$ pkg install cmake ninja git
$ git clone https://github.com/mozilla/cubeb
$ cmake -G Ninja -S cubeb -B cubeb_build
$ cmake --build cubeb_build
$ CUBEB_BACKEND=oss ctest --test-dir cubeb_build
Comment 3 Vladimir Druzenko freebsd_committer freebsd_triage 2021-08-05 22:02:58 UTC
Downgrade to 90.0.2 fixed issue.
So it's definitely is regression in 91.0.

With pulse my system doesn't work.
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2021-08-06 14:27:18 UTC
(In reply to Jan Beich from comment #2)
https://github.com/mozilla/cubeb/blob/master/INSTALL.md
    git clone --recursive https://github.com/kinetiknz/cubeb.git
    mkdir cubeb-build
    cd cubeb-build
    cmake ../cubeb
    cmake --build .
    ctest

========================================================================

$ ctest 
Test project /tmp/cubeb-build
      Start  1: sanity
 1/13 Test  #1: sanity ...........................   Passed   18.90 sec
      Start  2: tone
 2/13 Test  #2: tone .............................   Passed    5.04 sec
      Start  3: audio
 3/13 Test  #3: audio ............................   Passed   15.39 sec
      Start  4: record
 4/13 Test  #4: record ...........................   Passed    0.51 sec
      Start  5: devices
 5/13 Test  #5: devices ..........................   Passed    0.01 sec
      Start  6: callback_ret
 6/13 Test  #6: callback_ret .....................   Passed    0.97 sec
      Start  7: resampler
 7/13 Test  #7: resampler ........................   Passed    2.94 sec
      Start  8: duplex
 8/13 Test  #8: duplex ...........................***Failed    1.52 sec
      Start  9: latency
 9/13 Test  #9: latency ..........................   Passed    0.00 sec
      Start 10: ring_array
10/13 Test #10: ring_array .......................   Passed    0.00 sec
      Start 11: utils
11/13 Test #11: utils ............................   Passed    0.00 sec
      Start 12: ring_buffer
12/13 Test #12: ring_buffer ......................   Passed    1.43 sec
      Start 13: device_changed_callback
13/13 Test #13: device_changed_callback ..........   Passed    0.01 sec

92% tests passed, 1 tests failed out of 13

Total Test time (real) =  46.74 sec

The following tests FAILED:
          8 - duplex (Failed)
Errors while running CTest
Output from these tests are in: /tmp/cubeb-build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

========================================================================

$ ctest --rerun-failed --output-on-failure
Test project /tmp/cubeb-build
    Start 8: duplex
1/1 Test #8: duplex ...........................***Failed    1.56 sec
Running main() from gtest_main.cc
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from cubeb
[ RUN      ] cubeb.duplex
stream started
stream stopped
[       OK ] cubeb.duplex (524 ms)
[ RUN      ] cubeb.duplex_collection_change
/tmp/cubeb/test/test_duplex.cpp:156: Failure
Value of: CUBEB_OK
  Actual: 0
Expected: r
Which is: -4
Error initializing cubeb stream
[  FAILED  ] cubeb.duplex_collection_change (0 ms)
[ RUN      ] cubeb.one_duplex_one_input
stream started
stream started
stream stopped
stream stopped
[       OK ] cubeb.one_duplex_one_input (1029 ms)
[----------] 3 tests from cubeb (1553 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (1553 ms total)
[  PASSED  ] 2 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] cubeb.duplex_collection_change

 1 FAILED TEST


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   1.56 sec

The following tests FAILED:
          8 - duplex (Failed)
Errors while running CTest
Comment 5 Aleksandr Konkov 2021-08-13 10:17:36 UTC
I confirm the problem with microphone.

FreeBSD 13.0-STABLE #0 stable/13-n246228-47c5e288eee
Firefox buuild options:
        ALSA           : off
        CANBERRA       : off
        DBUS           : off
        DEBUG          : off
        FFMPEG         : on
        JACK           : off
        LIBPROXY       : off
        LTO            : off
        OPTIMIZED_CFLAGS: on
        PROFILE        : off
        PULSEAUDIO     : off
        SNDIO          : off
        TEST           : off

about:support show:
- sound system: oss
- input device: /dev/dsp0: Realtek ALC256 (Analog 2.0+HP/2.0) -> Enabled
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2021-08-24 21:46:28 UTC
91.0.2 still broken.
Comment 7 Thibault Payet 2021-09-02 17:29:22 UTC
The duplex test failed because cubeb oss backend does not implement:

register_device_collection_changed (which I guess is used when a new device is added during a webrtc call, like adding a new sound card I guess ?).
Comment 8 Ghost 2021-09-02 18:10:14 UTC
Can you bisect?

FIREFOX_BETA_91_BASE: https://hg.mozilla.org/mozilla-central/rev/5dee15cf3f2810ccc3bb9ec24c652f6f9d72b62d
FIREFOX_BETA_90_BASE: https://hg.mozilla.org/mozilla-central/rev/fafcc4a3b16a3b45f7abcc174e46bdc4a46888ca

Use "git am":
https://codeberg.org/ei/ports/commit/127e276.patch (revert)
https://codeberg.org/ei/ports/commit/c0cd4b4.patch (revert)
https://codeberg.org/ei/ports/commit/7c85f1a.patch (revert)
https://codeberg.org/ei/ports/commit/f02827e.patch (speed up build)
https://codeberg.org/ei/ports/commit/3b85790.patch (switch to tags)

Bisect by overriding DISTNAME with mozilla-central tags; do 'make makesum'
to update distinfo, and build tags until you find first good and bad tags.
You likely will not need to update patches in files/, and any updates are
likely to be minor (rebase due to line number change, etc). CCACHE can be
used, but I've never tried this and don't know if it works:
https://reviews.freebsd.org/D14154

Go down from FIREFOX_BETA_91_BASE to FIREFOX_BETA_90_BASE using binary search.
I don't remember hg good enough to paste commands to automate searching, and
I can't bisect this myself due to custom setup.
Comment 9 Ghost 2021-09-02 21:31:23 UTC
(In reply to Evgeniy Khramtsov from comment #8)

Forgot to revert to old rust: https://codeberg.org/ei/ports/commit/25e9c02.patch
and add "patch-bug1628567" when you get closer to 90: https://cgit.freebsd.org/ports/commit/?id=2d661b18
Comment 10 Ghost 2021-09-08 16:19:27 UTC
(In reply to Evgeniy Khramtsov from comment #8)

Issue reproduced. Soon (today to tomorrow) to be bisected; I found a few suspected changesets. Leaving this note here so nobody wastes CPU cycles.
Comment 11 Ghost 2021-09-08 19:26:34 UTC
Created attachment 227770 [details]
v1 (use "git am")

Regressed by upstream bug 1702646:
https://bugzilla.mozilla.org/show_bug.cgi?id=1702646

1702646 also broke Bluetooth speakers on Linux and related upstream bug is 1725810:
https://bugzilla.mozilla.org/show_bug.cgi?id=1725810

Upstream fixes proposed in 1725810 do not apply to Firefox 92; it is marked as "wontfix". Nightly channel now has fixes, but it is yet unknown if they can help until I build a tip of mozilla-central to confirm.

I opted to revert bug 1702646 wholly until this is fixed upstream. I didn't revert 1702646 partly because I am not sure if this will cause a regression.

Next I will (likely tomorrow) try to confirm if Nightly is also affected and report back here. I will also try to revert 1702646 partially to see if it helps / which part of 1702646 affects www/firefox.

I tested WebRTC microphone via https://codepen.io/rhamses/pen/BaNgxNz. The known to me sites do not work with IPv6-only kernel and network.

I don't know how to properly use and file PRs to Mozilla's Bugzilla. Can @gecko help me this time until I figure it out on my own later?

Can anyone else confirm that v1 helps? If is it not possible for you to build www/firefox due to OOM, etc, then ask, I will try to build a binary package later.
Comment 12 Ghost 2021-09-09 17:45:52 UTC
Created attachment 227789 [details]
v2 (use "git am")

Nightly (51552aef09e0712581a66a651ec7636bb3507afe) is not affected.

1f* is the first bad changeset, it cannot be reverted alone cleanly,
v2 instead reverts commits up to it but not to 81* (i.e. Use NativeInputTrack
remains):
https://github.com/mozilla/gecko-dev/compare/19785b8...0a9065018

Both v1 and v2 work here, but v2 reverts 1702646 partially and has less lines.
Comment 13 Ghost 2021-09-14 16:58:44 UTC
(In reply to Evgeniy Khramtsov from comment #12)

Can anyone test with a microphone? I also built binary packages against the main ports branch, if you prefer them:

https://codeberg.org/ei/misc/raw/branch/main/firefox/122-amd64-firefox-92.0_3,2.pkg
https://codeberg.org/ei/misc/src/branch/main/firefox/130-amd64-firefox-92.0_3,2.pkg
Comment 14 Ghost 2021-09-21 14:55:30 UTC
(In reply to Evgeniy Khramtsov from comment #13)

gecko@, have you decided to wait for Firefox 93 in October instead?
If no one else besides me can test, then I expect some feedback.
Comment 15 Thibault Payet 2021-09-27 22:14:29 UTC
The mic is still not working on 92.0.1,2 (not applying the patches)

The patches still apply for 92.0.1,2 and I can hear that the mic is working.
I only tested v1 though.
Comment 16 Vladimir Druzenko freebsd_committer freebsd_triage 2021-10-01 23:44:38 UTC
(In reply to Thibault Payet from comment #15)
93.0 work fine for me.
Test, plz, and I'll close this PR.
Comment 17 Thibault Payet 2021-10-02 06:49:17 UTC
(In reply to VVD from comment #16)
93.0 works fine too (oddly when I build it couples days ago, it was not working..)
Comment 18 Ghost 2021-10-02 09:28:09 UTC
(In reply to Thibault Payet from comment #15)

Thanks for testing.

> 93.0 works fine too (oddly when I build it couples days ago, it was not working..)

Maybe ports dcc587e70 helped?

(In reply to VVD from comment #16)

Upstream fixes [1] still did not land (as in "wontfix" on Bugzilla) for 91 [2].
ESR 78.15 in ports is the last within 78.* before 91.3 is released later this month [3].

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1725810
[2]: https://hg.mozilla.org/releases/mozilla-esr91/
[3]: https://wiki.mozilla.org/Release_Management/Calendar
Comment 19 Vladimir Druzenko freebsd_committer freebsd_triage 2021-10-02 12:37:07 UTC
(In reply to Evgeniy Khramtsov from comment #18)
> Maybe ports dcc587e70 helped?
> unbreak build with devel/llvm13
Don't think so.

> Upstream fixes [1] still did not land (as in "wontfix" on Bugzilla) for 91 [2].
ESR 78.15 in ports is the last within 78.* before 91.3 is released later this month [3].
Do you say about ESR 91 as replace of 78 in port www/firefox-esr? And last 91 still have this bug.
But not ESR version already fixed - port www/firefox for fine now.
Do you want to keep this PR open till www/firefox-esr moved to 91 and fixed?
Comment 20 Ghost 2021-10-02 13:51:41 UTC
(In reply to VVD from comment #19)

> Don't think so

Passing non-versioned OS target triple results in Clang targeting older FreeBSD for Rust crates, so questioning whether the omitted patch helped is relevant.

www/firefox is not reproducible (embeds build date), so the only way to check is to either
compare binaries with sysutils/py-diffoscope (tedious) or do a runtime test without ports dcc587e70 again.

Some notes about "quiet build failures":

1. bsd.gecko.mk starting with ports 912a7b12e4e passes "LDFLAGS+=-Wl,--as-needed", which is not the upstream default and remains disabled for e.g. Mozilla widget wrapper: https://github.com/mozilla/gecko-dev/blob/FIREFOX_ESR_91_0_X_RELBRANCH/widget/gtk/mozgtk/moz.build#L13

I use locally patched Firefox to build without X11, and the use of "-Wl,--as-needed" in ports exposed runtime linking issues with Mozilla wrapper for me:

https://github.com/mozilla/gecko-dev/blob/FIREFOX_ESR_91_0_X_RELBRANCH/widget/gtk/mozwayland/mozwayland.c#L17
LD_DEBUG=libs firefox
[...]
calling init function for /usr/local/lib/firefox/libxul.so at 0x1e1432bb82c0
dlopen_object name "<null>" fd -1 refobj "/usr/local/bin/firefox" lo_flags 0x2 mode 0x1
[...]

Vanilla Firefox in ports also has linking issues that are not immediately exposed via build failure: 

$ rg 'undefined symbol' firefox-93.0,2.log
28966:ld: warning: undefined symbol: environ
28975:ld: warning: undefined symbol: epoll_shim_write
28983:ld: warning: undefined symbol: eventfd
28987:ld: warning: undefined symbol: epoll_shim_read
28995:ld: warning: undefined symbol: epoll_shim_close

$SOMEONE yet to check if ports dcc587e70 is related to this issue.

> Do you want to keep this PR open till www/firefox-esr moved to 91 and fixed?

Yes, 91 including the next ESR 91 is still affected.
Comment 21 Fernando Apesteguía freebsd_committer freebsd_triage 2021-11-04 16:58:19 UTC
I'm using firefox 94.0_2,2 and the microphone does not work anymore. It does with chromium though.
Comment 22 Tomasz "CeDeROM" CEDRO 2021-11-04 17:20:34 UTC
here too mic stopped working after recent update of firefox with pkg. using 13 stable. rebuilt kernel today, updated psckages, mic is on the list, mixer ok, no mic sound.
Comment 23 Vladimir Druzenko freebsd_committer freebsd_triage 2021-11-04 23:00:26 UTC
(In reply to Fernando Apesteguía from comment #21)
But it work fine for me in 94.0 and in 94.0.1 too.
12.2 amd64.
Comment 24 Fernando Apesteguía freebsd_committer freebsd_triage 2021-11-05 06:59:16 UTC
It is possible that the problem is not in Firefox itself?

I changed media.cubeb.backend to oss (it was pulseaudio before), selected /dev/dsp3 (Front Analog jack) and I got the mic working with https://www.onlinemictest.com/

Can any of you try and change the cubeb backend and see it that helps?
Comment 25 Vladimir Druzenko freebsd_committer freebsd_triage 2021-11-05 10:58:23 UTC
I'm using cubeb backend oss.
Comment 26 Tomasz "CeDeROM" CEDRO 2021-11-05 14:45:14 UTC
I have changed in about:config media.cubeb.backend to oss and microphones works. Also in Chromium that uses sndio backend microphones work. There were some updates to PulseAudio recently, maybe PA is broken somehow?

I have reported this as separate PulseAudio bug:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259662
Comment 27 commit-hook freebsd_committer freebsd_triage 2021-11-07 23:27:21 UTC
A commit in branch main references this bug:

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

commit 2af447c8bac175a02de64aad1e36ad849df2f57f
Author:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
AuthorDate: 2021-11-07 23:22:06 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2021-11-07 23:22:06 +0000

    www/firefox: attempt to fix mic on pulseaudio

    careful testing revealed that the microphone worked "sometimes",
    with the "not working" state manifesting as follows: pulseaudio sees
    a signal from the microphone but firefox (and it's components) fails
    to show up on pulseaudio's source-outputs and firefox gets no audio
    signal.
    Applying the patch from upstream 1735905 seems to improve matters
    greatly.

    PR:             257639
    Reported by:    many
    Obtained from:  https://bugzilla.mozilla.org/show_bug.cgi?id=1735905

 www/firefox/Makefile                     |   1 +
 www/firefox/files/patch-bug1735905 (new) | 165 +++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
Comment 28 commit-hook freebsd_committer freebsd_triage 2021-11-07 23:29:23 UTC
A commit in branch 2021Q4 references this bug:

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

commit ad491a1d4f4447ac5884ceb3930d215a26becd88
Author:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
AuthorDate: 2021-11-07 23:22:06 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2021-11-07 23:28:12 +0000

    www/firefox: attempt to fix mic on pulseaudio

    careful testing revealed that the microphone worked "sometimes",
    with the "not working" state manifesting as follows: pulseaudio sees
    a signal from the microphone but firefox (and it's components) fails
    to show up on pulseaudio's source-outputs and firefox gets no audio
    signal.
    Applying the patch from upstream 1735905 seems to improve matters
    greatly.

    PR:             257639
    Reported by:    many
    Obtained from:  https://bugzilla.mozilla.org/show_bug.cgi?id=1735905

    (cherry picked from commit 2af447c8bac175a02de64aad1e36ad849df2f57f)

 www/firefox/Makefile                     |   1 +
 www/firefox/files/patch-bug1735905 (new) | 165 +++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
Comment 29 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2021-11-07 23:37:43 UTC
Half of the debugging here is moving the audio from where it's needed to the FreeBSD and back.
Anyway, this seems to work for me, or at least survive a few rounds of testing.

From the people now switching their audio backend to oss, I gather that OSS now works fine? (I used to use jack for the important stuff and pulseaudio on top for the desktoppy things - everything else, well; and currently I don't really have a microphone or similar over here).
Comment 30 Tomasz "CeDeROM" CEDRO 2021-11-08 03:08:32 UTC
Aaah cool, looks like I reported this also as pulseaudio problem, will close as duplicate.. from my testing pulseaudio seemed to work fine.. you can see the details at:

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

Thanks for the fix! :-)
Comment 31 Tomasz "CeDeROM" CEDRO 2021-11-08 03:10:14 UTC
*** Bug 259662 has been marked as a duplicate of this bug. ***
Comment 32 Tomasz "CeDeROM" CEDRO 2021-11-08 03:12:29 UTC
Quick note and quick fix if you need to use Firefox and you encounter PulseAudio problem until fix you can switch to OSS backend to get the microphone working :-)

about:config / media.cubeb.backend = oss
Comment 33 Fernando Apesteguía freebsd_committer freebsd_triage 2021-11-08 07:59:13 UTC
(In reply to Christoph Moench-Tegeder from comment #29)
Thanks Christoph!

I'll test this later today and provide some feedback.
Comment 34 Fernando Apesteguía freebsd_committer freebsd_triage 2021-11-08 17:24:31 UTC
(In reply to Fernando Apesteguía from comment #33)
I spoke too fast. This is going to take longer than expected. I have many other ports to rebuild.
Comment 35 Fernando Apesteguía freebsd_committer freebsd_triage 2021-11-12 06:44:37 UTC
It works for me again with 94.0.1_1,2

Thanks!
Comment 36 Tomasz "CeDeROM" CEDRO 2021-11-12 19:18:34 UTC
I just did an upgrade firefox: 94.0_2,2 -> 94.0.1_1,2
Microphone is back in Firefox using PulseAudio.
TANK U =)