Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconnect microphone on pulseaudio crash #13030

Open
marc1uk opened this issue Dec 3, 2020 · 14 comments
Open

reconnect microphone on pulseaudio crash #13030

marc1uk opened this issue Dec 3, 2020 · 14 comments

Comments

@marc1uk
Copy link

marc1uk commented Dec 3, 2020

Description

Very often when I try to connect to conference calls brave is unable to find any microphones on my device. On initial startup (at least, for now...) it's detecting everything ok, but nearly always by the time a meeting comes around all websites report no audio devices found (https://test.webrtc.org/, https://www.onlinemictest.com/, MS teams, google hangouts, discord, slack... ).
My best guess (i'd appreciate some suggestions on debugging) is that pulseaudio is crashing, and brave is failing to reconnect afterwards - I get the same behaviour after issuing pulseaudio -k, which kills and restarts the pulseaudio deamon.

The issue here is that as far as i'm aware there ought to be automatic reconnection once the service is restarted - indeed, playback of audio works just fine, it's only recording audio that doesn't.

Steps to Reproduce

Potentially a bit artificial (as i'm speculating on the cause) but run brave, do pulseaudio -k, and then check audio detection on https://test.webrtc.org/ or any of the others listed above.

Actual result:

No audio devices found.

Expected result:

Audio devices are re-detected as necessary.

Reproduces how often:

Always.

Brave version (info found on brave://version)

Brave | 1.16.76 Chromium: 86.0.4240.198 (Official Build) (64-bit)
-- | --
Revision | d8a506935fc2273cfbac5e5b629d74917d9119c7-refs/branch-heads/4240@{#1431}
OS | Linux

Version/Channel Information:

Seen this on all brave versions as long as I can remember....

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields?
    No.
  • Does the issue resolve itself when disabling Brave Rewards?
    No.
  • Is the issue reproducible on the latest version of Chrome?
    Probably.

Other

This definitely seems possible, as within firefox I'm able to kill and re-connect microphone usage.... albeit in a very bizarre way. Initially after killing pulseaudio onlinemictest.com shows the same error: unable to find microphone. But re-freshing https://test.webrtc.org/ seems to force a re-detection of audio input devices. After doing this, onlinemictest.com works again (as do all other sites using audio devices). This workaround works in firefox, but not brave. Bizarre, possibly not useful information, but it shows it can be done.

@guest271314
Copy link

Are you certain microphones are connected to the machine?

indeed, playback of audio works just fine, it's only recording audio that doesn't.

Are you trying to record the default microphone input,or do you attempt to select a different device to record?

@marc1uk
Copy link
Author

marc1uk commented Dec 7, 2020

Hi. Yep, there are definitely microphones connected - internal microphones on a laptop, aux-in microphone on laptop and desktop, and a usb microphone on a desktop, none show up. All are working fine outside the browser.
I'm trying to record any microphone. There are no devices to select from. No microphones even show up in the brave settings menu.

Working:
working
Now working:
not_working

Both of these are taken on the same machine, one before, one after pulseaudio crash.

@marc1uk
Copy link
Author

marc1uk commented Dec 7, 2020

When i run brave from the terminal and kill pulseaudio, thereafter attemps to access my audio devices emit errors along the lines of pa_operation is nullptr.

@guest271314
Copy link

I will try to install Brave to reproduce the issue. On Chromium or Chrome the closest that I have experienced to that issue is trying to capture a monitor device, which throws a DOMException error, see https://bugs.chromium.org/p/chromium/issues/detail?id=1155954.

What does .catch(e => console.error(e)) log chained to navigator.mediaDevices.getUserMedia({audio: true})?

Try something like this

navigator.mediaDevices.getUserMedia({audio: true})
.then(stream => {
  return stream
})
.catch(e => {
  console.error(e);
  return navigator.mediaDevices.enumerateDevices();
})
.then(stream_or_devices => {
  console.log(stream_or_devices);
});

what is logged at console?

@guest271314
Copy link

@marc1uk Re

what is logged at console?

printing the devices and labels here is not necessary. I do not need to know your device specifics. If devices are the fulfilled Promise are the devices of kind "audioinput" and are the objects InputDeviceInfo or MediaDeviceInfo.

@guest271314
Copy link

Cannot reproduce at 1.17.75 Chromium: 87.0.4280.88 (Official Build) (64-bit) Revision | 89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}.

When i run brave from the terminal

Are you trying to access the same microphone and camera at two separate instances of Brave?

@marc1uk
Copy link
Author

marc1uk commented Dec 28, 2020

No, just one instance of Brave. I'm afraid I'm not familiar with development / debugging of chrome or brave, so i'd need some more explicit instructions to try to check the kind of objects fulfilling the promise. If i'm reading it right, this is now moot, but would the code in your previous comment have been pasted into the Developer Tools -> Console? On the specific website when audio devices are not found?
Thanks for looking into this.

@guest271314
Copy link

but would the code in your previous comment have been pasted into the Developer Tools -> Console?

Yes.

@marc1uk
Copy link
Author

marc1uk commented Dec 28, 2020

When audio devices are working i get:

Promise {<pending>}
__proto__: Promise
catch: ƒ catch()
constructor: ƒ Promise()
finally: ƒ finally()
then: ƒ then()
Symbol(Symbol.toStringTag): "Promise"
__proto__: Object
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: undefined

MediaStream {id: "LsaVMEbH49dRkJV1XXXwKlhEOuBPXHwMC7mB", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}
active: true
id: "LsaVMEbH49dRkJV1XXXwKlhEOuBPXHwMC7mB"
onactive: null
onaddtrack: null
oninactive: null
onremovetrack: null
__proto__: MediaStream

but after pulseaudio crash i get:

Promise {<pending>}__proto__: Promise[[PromiseState]]: "fulfilled"[[PromiseResult]]: undefined
VM556:6 DOMException: Requested device not found
(anonymous) @ VM556:6
Promise.catch (async)
(anonymous) @ VM556:5
VM556:10 []

seems like an endless option to expand members here so let me know if there's something specific to look for

@guest271314
Copy link

I do not why pulseaudio is crashing. Are you sure to call MediaStreamTrack.stop() before trying to access microphone again? Does pavucontrol list the microphone?

@marc1uk
Copy link
Author

marc1uk commented Dec 28, 2020

I believe pulseaudio is crashing for other reasons (related to LADSPA plugins, although in this case I'm manually "replicating" it by running pulseaudio -k).
I understand this may be a bit of a false issue as the underlying problem is elsewhere (pulseaudio shouldn't crash), but pulseaudio immediately restarts on crash and other applications seem able to recover afterwards, whereas brave does not.

@paco3346
Copy link

paco3346 commented May 20, 2021

I experience a very similar issue. I'm running pipewire with pipewire-pulse on Arch and I too have times where Brave will no longer properly use input devices but playback works perfectly. This happens any time pulse goes away (in my case, pipewire-pulse).

This happens on all of the following which leads me to believe it's an upstream issue.

Brave: 1.23.73 Chromium: 90.0.4430.85 (Official Build) (64-bit)
Chrome: 90.0.4430.85 (Official Build) (64-bit)
Chromium: 90.0.4430.85 (Official Build) Arch Linux (64-bit)

I also get the same ERROR:pulse_util.cc(343)] pa_operation is nullptr. message in all 3 browsers.

For all 3 the only fix is to restart the browser.

@paco3346
Copy link

A bit more googling and I have an answer:

This is a known issue with chromium (and chromium based browsers).

https://bugs.chromium.org/p/chromium/issues/detail?id=1085744#c3

The only current workaround without restarting is to restart the browser audio service.

Press Shift + Esc. In the Task Manager window that opens find Utility: Audio Service (it's usually the very bottom for me) and click End Process. Refresh your page and voila.

I think this can be closed as an upstream issue.

@marc1uk
Copy link
Author

marc1uk commented May 24, 2021

Interesting! Thanks for posting the workaround, that's far preferable to a complete restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Info
Development

No branches or pull requests

4 participants