Bug 198577 - mediaDevices.enumerateDevices() doesn't list the system default audio devices with deviceId as "default"
Summary: mediaDevices.enumerateDevices() doesn't list the system default audio devices...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 12
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-06-05 13:26 PDT by Jaya A
Modified: 2019-06-07 15:39 PDT (History)
4 users (show)

See Also:


Attachments
Output of mediaDevices.enumerateDevices() on Safari (147.58 KB, image/png)
2019-06-05 13:26 PDT, Jaya A
no flags Details
Output of mediaDevices.enumerateDevices() on Chrome (284.19 KB, image/png)
2019-06-05 13:26 PDT, Jaya A
no flags Details
Patch (9.22 KB, patch)
2019-06-07 10:39 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (9.26 KB, patch)
2019-06-07 12:12 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaya A 2019-06-05 13:26:24 PDT
Created attachment 371432 [details]
Output of mediaDevices.enumerateDevices() on Safari

mediaDevices.enumerateDevices() on Safari 12.1 and Safari TP does not list the system default audio devices with deviceId as "default". 
Chrome enumerates the system default audio devices twice, once with the deviceId as "default" so that the WebRTC applications can identify them as such. Without this mechanism, the WebRTC application cannot identify the default mics and can run into issues with echo since microphones (like thunderbolt display and Logitech cameras) other than the built-in mics would still need AEC.
Comment 1 Jaya A 2019-06-05 13:26:55 PDT
Created attachment 371433 [details]
Output of mediaDevices.enumerateDevices() on Chrome
Comment 2 Radar WebKit Bug Importer 2019-06-05 13:38:33 PDT
<rdar://problem/51454067>
Comment 3 youenn fablet 2019-06-05 13:43:15 PDT
Thanks for the report.
One option is to go like Chrome is doing but it duplicates the default entry which is not great.
Another option might be to use the order of the MediaDeviceInfo sequence.
The first microphone and first camera could always be the default devices.
Comment 4 youenn fablet 2019-06-05 14:04:32 PDT
> default mics and can run into issues with echo since microphones (like
> thunderbolt display and Logitech cameras) other than the built-in mics would
> still need AEC.

I just tried with a Logitech Camera and did not experience the echo cancellation issue.
I tried to test with a Thunderbolt Display and ended up with some issues.
In that case, the microphone was the built-in one and the output was the display.
Comment 5 youenn fablet 2019-06-07 10:39:15 PDT
Created attachment 371596 [details]
Patch
Comment 6 youenn fablet 2019-06-07 12:12:33 PDT
Created attachment 371602 [details]
Patch
Comment 7 youenn fablet 2019-06-07 14:43:24 PDT
@Jaya, the patch will make sure that the first mic device is system default when calling enumerateDevices.
Similarly, if calling getUserMedia without any constraint, the system mic will be used.
Comment 8 WebKit Commit Bot 2019-06-07 15:12:31 PDT
Comment on attachment 371602 [details]
Patch

Clearing flags on attachment: 371602

Committed r246215: <https://trac.webkit.org/changeset/246215>
Comment 9 WebKit Commit Bot 2019-06-07 15:12:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Jaya A 2019-06-07 15:39:27 PDT
Thank you Youenn for the quick fix. This will fix all our device selection and AEC issues with Safari.