twilio-video.js icon indicating copy to clipboard operation
twilio-video.js copied to clipboard

Safari 15 "A MediaStreamTrack ended due to a capture failure" when selecting audio input device

Open Talb2005 opened this issue 2 years ago • 12 comments

  • [X ] I have verified that the issue occurs with the latest twilio-video.js release and is not marked as a known issue in the CHANGELOG.md.
  • [X ] I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • [X ] I verified that the Quickstart application works in my environment.
  • [X ] I am not sharing any Personally Identifiable Information (PII) or sensitive account information (API keys, credentials, etc.) when reporting this issue.

The issue is reproducable on latest (0.6.1) twilio-video-app-react.

Expected behavior:

Changing to external audio input device should work without errors.

Actual behavior:

Changing audio input devices on Safari 15+ fails with error "A MediaStreamTrack ended due to a capture failure".

The workaround of detecting silence and retrying getUserMedia doesn't help, as it seems to be stuck in an infinate retry loop. Even though the silcence detection workaround failed 3 times, it restarts the 3 retries cycle again after the previous cycle failed.

The issue seems to occur when selecting Bluetooth (I tried with Sony WH-1000XM2) or USB devices (I tried with Logitech C922 Pro Stream Webcam), but not when selecting the built-in microphone or when selecting wired headphones with built-in microphone. Another strange finding, is that if the requested audio input device is set as system default, and therefore is already selected, it seems to work properly without errors.

Logs:

[Error] A MediaStreamTrack ended due to a capture failure (x3) [Warning] 2021-12-20T08:16:48.100Z – "warn" – "[LocalAudioTrack #1: 9ba2016c-05f3-410d-ba7d-effd3b8b35bc]" – "Got a silent audio MediaStreamTrack. Stopping all MediaStreamTracks and calling getUserMedia again. This is retry #1." (2.7f76f3a4.chunk.js, line 2) [Warning] 2021-12-20T08:16:50.434Z – "warn" – "[LocalAudioTrack #1: 9ba2016c-05f3-410d-ba7d-effd3b8b35bc]" – "Got a silent audio MediaStreamTrack. Stopping all MediaStreamTracks and calling getUserMedia again. This is retry #2." (2.7f76f3a4.chunk.js, line 2) [Warning] 2021-12-20T08:16:52.818Z – "warn" – "[LocalAudioTrack #1: 9ba2016c-05f3-410d-ba7d-effd3b8b35bc]" – "Got a silent audio MediaStreamTrack. Stopping all MediaStreamTracks and calling getUserMedia again. This is retry #3." (2.7f76f3a4.chunk.js, line 2) [Warning] 2021-12-20T08:16:55.119Z – "warn" – "[LocalAudioTrack #1: 9ba2016c-05f3-410d-ba7d-effd3b8b35bc]" – "Got a silent audio MediaStreamTrack. Normally we would try to get a new one, but we've run out of retries; returning it anyway." (2.7f76f3a4.chunk.js, line 2)

Software versions:

  • [X] Browser(s): Safari Version 15.2 (17612.3.6.1.6)
  • [X] Operating System: macOS Monterey Version 12.1 (21C52)
  • [X] twilio-video.js: Version 2.18.2
  • [X] Third-party libraries (e.g., Angular, React, etc.): React (using the twilio-video-app-react quickstart project)

Talb2005 avatar Dec 20 '21 09:12 Talb2005

Thanks for the report @Talb2005 . Do you know if this issue is happening on older versions of macOS or Safari?

charliesantos avatar Dec 28 '21 17:12 charliesantos

The issue also occurs on: Safari 15.1 (16612.2.9.1.30, 16612) macOs Big Sur 11.6.1 (20G224) It's reproducible in this project https://github.com/twilio/video-quickstart-js

OlexandrPopov avatar Dec 31 '21 14:12 OlexandrPopov

@charliesantos This issue didn't occur in Safari 14.8.

Talb2005 avatar Jan 03 '22 04:01 Talb2005

I'm able to reproduce the issue with the provided information. I'll submit an internal ticket to investigate further.

charliesantos avatar Jan 05 '22 18:01 charliesantos

@Talb2005 @OlexandrPopov the issue seems to happen if you connect an AnalyserNode to an AudioTrack, for measuring audio levels for example. If you comment out this line in our quickstart, you can see that the issue will go away. As a temporary workaround, please make sure your application doesn't do this, if possible. We will also continue to investigate on our side and see if there's a different way to measure audio levels, and file a safari bug if necessary.

charliesantos avatar Jan 05 '22 23:01 charliesantos

Unfortunately, disabling the measuring audio levels didn't solve the issue. It still occurs on macOs Big Sur 11.6.1 in Safari Version 15.1 (16612.2.9.1.30, 16612). I tried to comment out the line you mentioned in the comment above in the quickstart project and remove the measuring audio levels from my project completely and it didn't work.

safari

OlexandrPopov avatar Jan 06 '22 11:01 OlexandrPopov

@OlexandrPopov I created a simple test page that removes the audio level detection. Can you please try it out? https://charliesantos.github.io/pages/audio_input_nolevel.html

charliesantos avatar Jan 10 '22 17:01 charliesantos

Webkit bug https://bugs.webkit.org/show_bug.cgi?id=233473

charliesantos avatar Jan 10 '22 19:01 charliesantos

@charliesantos I tried the test page and got the same error. Here is a video https://www.dropbox.com/s/v55vknfka7n22mk/getUserMedia-safari.mov?dl=0

OlexandrPopov avatar Jan 11 '22 09:01 OlexandrPopov

Thanks @OlexandrPopov . This is reproducible outside of Twilio SDK, and even without using Web Audio API, just like your situation. This is Safari bug and is captured in this ticket https://bugs.webkit.org/show_bug.cgi?id=233473

charliesantos avatar Jan 11 '22 19:01 charliesantos

Thank you.

OlexandrPopov avatar Jan 12 '22 07:01 OlexandrPopov

@charliesantos That webkit bug shows as RESOLVED when I view it. Does this remain an open issue?

lhamoudi avatar Mar 31 '22 22:03 lhamoudi