Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should getCapabilities() return an empty array or undefined for facingMode? #969

Open
youennf opened this issue Sep 14, 2023 · 6 comments
Open

Comments

@youennf
Copy link
Contributor

youennf commented Sep 14, 2023

As pointed by Eric, on macOS, Chrome and Safari capabilities for a camera track differ for facingMode.
Safari does not include facingMode, Chrome sets it to [].
The spec does not seem to provide guidance for facingMode.
It would be good to be consistent and either use undefined or [].

@jan-ivar
Copy link
Member

I think the spec guidance is there: "For each constrainable property, there is a capability that describes whether it is supported by the source and if so, the range of supported values".

Chrome sets it to [].

I can repro with https://jsfiddle.net/jib1/3gpy9ndz/ — The constraints concept being a triad, my takeaway is one of the intended invariants is that any value exposed in either getSettings or getCapabilities also appears in the other.

It seems a bug to surface a value in only one of getSettings and getCapabilities.

@guidou
Copy link
Contributor

guidou commented Sep 29, 2023

It seems a bug to surface a value in only one of getSettings and getCapabilities.

I agree with this. I filed a bug to track a fix so that the capability is not exposed as an empty array if the setting is not exposed.

Not sure if we need to amend the spec in any way.

@jan-ivar
Copy link
Member

A note would probably be nice.

@jan-ivar jan-ivar added this to the Future Version milestone Feb 14, 2024
@alvestrand
Copy link
Contributor

The likely reason for the empty array is platform dependence - I think we support "user" and "environment" on Android, but in general on the PC platforms, we have no way of knowing which way the camera is facing. So we support the constraint in code (and thus generate an element for it in capabilities), but on the platform the test runs on, there are no applicable values.

Seems a bit weird. But if we drop empty arrays for this case, we should drop it for all cases.

@alvestrand
Copy link
Contributor

Note that there's a behavioral difference: if we make a mandatory (exact/min/max) on a constraint that is supported but has no applicable value, the request will be rejected as overconstrained. If we make a mandatory on a constraint that is not supported, the constraint is ignored.

So this may warrant a spec change for clarification.

@guidou
Copy link
Contributor

guidou commented Feb 15, 2024

The likely reason for the empty array is platform dependence - I think we support "user" and "environment" on Android, but in general on the PC platforms, we have no way of knowing which way the camera is facing. So we support the constraint in code (and thus generate an element for it in capabilities), but on the platform the test runs on, there are no applicable values.

This is correct, and I don't think there is anything in the spec that explicitly prohibits this behavior.
Also note that Chromium also supports facingMode values on Windows and ChromeOS, which have APIs to get this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants