Bug 203407

Summary: enumerateDevices() doesn't return correct list of devices after device was changed by user in a system preferences
Product: WebKit Reporter: olsviate <olsviate>
Component: WebRTCAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric.carlson, ews-watchlist, glenn, hta, jer.noble, philipj, sergio, tommyw, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: Macintosh   
OS: macOS 10.15   
Attachments:
Description Flags
Patch
none
Patch for landing. none

Description olsviate 2019-10-25 05:16:20 PDT
Steps to reproduce:

1. Have two or more available microphones
2. Call getUserMedia and then enumerateDevices: 
browser will return a list of devices, where first one is default
2. Change microphone is system preference
3. Call enumerateDevices again:
first one in the list is a previous default device


Js fiddler to show the issue: https://jsfiddle.net/h38bn7zq/15/


Note: if device is unplugged then enumerateDevices returns correct info, it works correct also when device was plugged in after.
Comment 1 Radar WebKit Bug Importer 2019-10-26 13:12:22 PDT
<rdar://problem/56648063>
Comment 2 youenn fablet 2019-10-26 13:17:57 PDT
I can repro the bug.
On page reload, the default device is the correct one.
There is apparently no device change event being fired, which means we either do not receive the notification or we do not detect any change in the device setup while we should.
Comment 3 Eric Carlson 2019-11-04 07:53:34 PST
Created attachment 382738 [details]
Patch
Comment 4 youenn fablet 2019-11-04 07:58:49 PST
Comment on attachment 382738 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=382738&action=review

> Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:131
> +                callOnMainThread([] {

We probably do not need callOnMainThread since we ask the listener to be called on dispatch_get_main_queue.
Comment 5 Eric Carlson 2019-11-04 08:10:29 PST
Created attachment 382740 [details]
Patch for landing.
Comment 6 WebKit Commit Bot 2019-11-04 08:42:38 PST
Comment on attachment 382740 [details]
Patch for landing.

Clearing flags on attachment: 382740

Committed r251992: <https://trac.webkit.org/changeset/251992>
Comment 7 WebKit Commit Bot 2019-11-04 08:42:40 PST
All reviewed patches have been landed.  Closing bug.