Open Bug 1643640 Opened 6 years ago Updated 1 year ago

Impossible to create 2 streams with 2 different camera using getUserMedia({deviceId: {ideal: id}})

Categories

(Core :: WebRTC: Audio/Video, defect, P3)

77 Branch
defect

Tracking

()

People

(Reporter: frederic.luart, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.30 Safari/537.36

Steps to reproduce:

Firefox 77.0.1 on Mac OS 10.15.4

Try to create two video stream with getUserMedia and different deviceId

Here is a page to reproduce the issue :
https://jsfiddle.net/FredLuart/90v1Lnst/

Actual results:

Two video stream are created but with the first selected camera/deviceId

Expected results:

Two video stream with different camera

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → WebRTC: Audio/Video
Product: Firefox → Core

If you look at the console your code set both videoDeviceId* variables with the same device id. In my case:

videoDeviceId1 : lY5vbroQyGnZft0R0M3XFPo10quBYzbmzecJtKqWwb0=
videoDeviceId2 : lY5vbroQyGnZft0R0M3XFPo10quBYzbmzecJtKqWwb0=
Flags: needinfo?(frederic.luart)

I have just done the test again and it is working on my side :

Here is my console logs :

"videoDeviceId1 :", "zW3oZCnSf5297xR8gistPBytdRwKf6mAurHgWGihqic="
"videoDeviceId2 :", "FOzeywQ+h3dLDUJXf6/JykF/NOJUhTb36ylHIwx+l08="
"createStream with constraints :", {
audio: false,
video: {
deviceId: "zW3oZCnSf5297xR8gistPBytdRwKf6mAurHgWGihqic="
}
}
"createStream with constraints :", {
audio: false,
video: {
deviceId: "FOzeywQ+h3dLDUJXf6/JykF/NOJUhTb36ylHIwx+l08="
}
}

Result :
With Chrome : two different video stream with the two camera
On Firefox : two stream with same camera

Flags: needinfo?(frederic.luart)

Ok, thanks, I'll have a second look.

You need the exact in constrains to open the second device. Something like:

  var constraints = {
  	audio: false,
    video: {
      deviceId : { exact: deviceId }
    }
  };

I don't know why it does not work without it. Jib, does the spec say anything specific about it?

Flags: needinfo?(jib)

OK, thanks Alex. It is working with 'exact'.
I tested it with 'ideal' that is not working : usage of 'exact' is already a good workaround for me

(In reply to Alex Chronopoulos [:achronop] from comment #5)

You need the exact in constrains to open the second device. ... I don't know why it does not work without it. Jib, does the spec say anything specific about it?

The spec says on ideal constraints: "The decision of which track to choose from the finalSet is completely up to the User Agent and may be determined by asking the user." and "[It] MAY use the value of the computed "fitness distance" from the SelectSettings algorithm"

The choice in this case is between A) returning a camera you already have access to, or B) prompt. Ironically, Firefox chooses A for web compat with Chrome, due to a bad web-dev habit of using getUserMedia all over the place (probably large pieces of code with lots of different libraries) as a lazy-getter for the same source.

This may have made sense for other constraints, but it seems fairly clear it's the wrong answer for deviceId. We should consider fixing this. Thanks for filing this Fred!

Severity: -- → S4
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jib)
Priority: -- → P2
Summary: Impossible to create 2 streams with 2 different camera (getUserMedia / enumerateDevices) → Impossible to create 2 streams with 2 different camera using getUserMedia({deviceId: {ideal: id}})

Thanks for feedback. Do you know the first version that support 'exact' constraint ? is it version 55 ?

Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.