Bug 235713 - [macOS] Acquiring stream from one microphone breaks all previous streams from another microphones
Summary: [macOS] Acquiring stream from one microphone breaks all previous streams from...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 15
Hardware: Mac (Intel) macOS 12
: P2 Critical
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-27 06:54 PST by ivan.zahrodskyi
Modified: 2022-12-03 13:43 PST (History)
3 users (show)

See Also:


Attachments
Example to reproduce this problem (2.04 KB, text/html)
2022-12-03 13:43 PST, ivan.zahrodskyi
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ivan.zahrodskyi 2022-01-27 06:54:21 PST
I want to get several audio MediaStreams from different mics, but getting new stream breaks previous.
To reproduce this we need machine with 2 microphones connected.



Steps:
1) get stream from first microphone (str1)
2) attach this stream to some audio node (or put to peer connection)
3) get another stream from second microphone (str2)

actual result:
observe that str1 now starts playing audio from second microphone


some code example to try this

//******************************//
//get all available microphones 
let devices = await navigator.mediaDevices.enumerateDevices();
let microphones = devices.filter(d => d.kind === 'audioinput');

//get audio from first microphone
let str1 = await navigator.mediaDevices.getUserMedia({audio: {deviceId: microphones[0].deviceId}});

//play first stream
let audio = new Audio();
audio.srcObject = str1;
audio.play();

//get audio from second microphone
let str2 = await navigator.mediaDevices.getUserMedia({audio: {deviceId: microphones[1].deviceId}});

//observe that audio now starts playing audio from second microphone (not from str1)

//******************************//
Comment 1 Radar WebKit Bug Importer 2022-02-03 06:55:17 PST
<rdar://problem/88433154>
Comment 2 youenn fablet 2022-02-07 11:22:29 PST
Can you clarify which platform/application is the target for this request? Is it MacOS? iOS? Safari?
Comment 3 olena.bezkrovna 2022-03-16 08:36:24 PDT
(In reply to youenn fablet from comment #2)
> Can you clarify which platform/application is the target for this request?
> Is it MacOS? iOS? Safari?

The issue was updated (problem was observed on macOS 12, 11 on Safari 15)
Comment 4 ivan.zahrodskyi 2022-12-03 13:43:01 PST
Created attachment 463876 [details]
Example to reproduce this problem

Issue is still reproducible

I tested on MacBook Pro 16 (2019) MacOS 13.1 Beta (22C5059b) Safari Version 16.2 (18614.3.7.1.3)

I created small example.
- press GET FIRST
- make sure you can hear audio from first microphone
- select another microphone in second select
- press GET_SECOND

after getting second microphone - first is lost

you can open console and see that stream1 is not active and audio track has readyState === 'ended'

this is in 90% tries..but sometimes first track is still active but audio source is wrong (audio plays from second microphone)


In our application there is a case when we have 2 different audio from different microphones which we send via webrtc to remote participants. But because of this issue it doesnt work in safari.