Bug 203407 - enumerateDevices() doesn't return correct list of devices after device was changed by user in a system preferences
Summary: enumerateDevices() doesn't return correct list of devices after device was ch...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 13
Hardware: Macintosh macOS 10.15
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-25 05:16 PDT by olsviate
Modified: 2019-11-04 08:42 PST (History)
11 users (show)

See Also:


Attachments
Patch (3.54 KB, patch)
2019-11-04 07:53 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch for landing. (3.35 KB, patch)
2019-11-04 08:10 PST, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.