Bug 209417 - MediaDevices::refreshDevices should take device type into account
Summary: MediaDevices::refreshDevices should take device type into account
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
: 209580 209708 209739 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-03-23 03:44 PDT by youenn fablet
Modified: 2020-04-01 09:59 PDT (History)
13 users (show)

See Also:


Attachments
Patch (4.86 KB, patch)
2020-03-23 03:46 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 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. ***