Bug 174041 - Calling mediaDevices.enumerateDevices() changes enumerated device IDs in other open pages
Summary: Calling mediaDevices.enumerateDevices() changes enumerated device IDs in othe...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Safari Technology Preview
Hardware: Mac macOS 10.12.4
: P2 Normal
Assignee: Nobody
URL: https://s3.amazonaws.com/safari-devic...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-06-30 14:41 PDT by lepinski
Modified: 2017-08-30 11:40 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lepinski 2017-06-30 14:41:32 PDT
This appears to be a regression introduced in the most recent Safari Technology Preview (Release 34, 12604.1.27.0.1).

On load, call navigator.mediaDevices.enumerateDevices() and note the device IDs in the source list. Open a new page (leaving the first page open) that also makes an enumerateDevices call. Return to the first page and enumerate your devices again; their IDs will have changed. This appears to occur regardless of whether Page 1 and 2 are on the same or different domains.

The result of this bug is that when Page 1 attempts to then use an input device ID from its first enumeration as a getUserMedia constraint, the call will fail because the device ID is invalid. 

navigator.mediaDevices.ondevicechange also not called when these device IDs change as a result of this.
Comment 1 Radar WebKit Bug Importer 2017-07-01 00:05:18 PDT
<rdar://problem/33092067>
Comment 2 lepinski 2017-08-30 11:40:13 PDT
I've tested this issue in Release 38 and it's still happening. 

I've got an easy repro test page available here: https://s3.amazonaws.com/safari-devices-testing/index.html; to reproduce:

* open the above page, click "Enumerate devices"; note device IDs
* (optional: click "Enumerate devices" again; note that IDs haven't changed)
* open a second page to the same URL, click "Enumerate devices" there
* return to first page, click "Enumerate devices" again; you'll be prompted to re-authorize microphone access, and you'll be given a new set of device IDs