Bug 209417

Summary: MediaDevices::refreshDevices should take device type into account
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, hta, jer.noble, milen.yordanov, M.Tjioe, philipj, sergio, tommyw, webkit-bug-importer, youennf, y.sugiura.0316
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description youenn fablet 2020-03-23 03:44:42 PDT
MediaDevices::refreshDevices should take device type into account
Comment 1 youenn fablet 2020-03-23 03:44:55 PDT
<rdar://problem/60521332>
Comment 2 youenn fablet 2020-03-23 03:46:44 PDT
Created attachment 394251 [details]
Patch
Comment 3 Eric Carlson 2020-03-23 06:58:41 PDT
Comment on attachment 394251 [details]
Patch

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

> Source/WebCore/Modules/mediastream/MediaDevices.cpp:186
> +        auto deviceKind = newDevice.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
> +        auto index = m_devices.findMatching([deviceKind, &newDevice](auto& oldDevice) {
> +            return oldDevice->deviceId() == newDevice.persistentId() && oldDevice->kind() == deviceKind;

How does this help the case where there is more than one device of a given type? Or is that not an issue because we have device IDs if `newDevices` has more than one device of any type?
Comment 4 youenn fablet 2020-03-23 07:21:34 PDT
(In reply to Eric Carlson from comment #3)
> Comment on attachment 394251 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394251&action=review
> 
> > Source/WebCore/Modules/mediastream/MediaDevices.cpp:186
> > +        auto deviceKind = newDevice.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
> > +        auto index = m_devices.findMatching([deviceKind, &newDevice](auto& oldDevice) {
> > +            return oldDevice->deviceId() == newDevice.persistentId() && oldDevice->kind() == deviceKind;
> 
> How does this help the case where there is more than one device of a given
> type? Or is that not an issue because we have device IDs if `newDevices` has
> more than one device of any type?

UIProcess is filtering if needed to only expose 1 device of each type.
The issue is that we will have two devices of two different type but with the same ID (the empty string).
In that case, when calling enumerateDevices again, we will confuse the audioinput device with the videoinput device, which will lead to expose two audio input devices instead of 1 audio input and 1 video input.
Comment 5 EWS 2020-03-23 07:24:24 PDT
Committed r258837: <https://trac.webkit.org/changeset/258837>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394251 [details].
Comment 6 youenn fablet 2020-03-26 00:13:34 PDT
*** Bug 209580 has been marked as a duplicate of this bug. ***
Comment 7 youenn fablet 2020-03-30 07:26:41 PDT
*** Bug 209739 has been marked as a duplicate of this bug. ***
Comment 8 youenn fablet 2020-04-01 09:59:44 PDT
*** Bug 209708 has been marked as a duplicate of this bug. ***