Bug 270779
Summary: | Navigator.mediaDevices.getSupportedConstraints mistakenly reports torch as false. | ||
---|---|---|---|
Product: | WebKit | Reporter: | Shawn Lee <shawnlee> |
Component: | WebRTC | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | karlcow, webkit-bug-importer, youennf |
Priority: | P2 | Keywords: | BrowserCompat, InRadar |
Version: | Safari 17 | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=169871 |
Shawn Lee
demo : https://sy74yv.csb.app/
It will show the result of getSupportedConstraints.
{"aspectRatio":true
"deviceId":true
"displaySurface":true
"echoCancellation":true
"facingMode":true
"frameRate":true
"groupId":false
"height":true
"sampleRate":false
"sampleSize":false
"torch":false
"volume":true
"whiteBalanceMode":true
"width":true
"zoom":true}{"aspectRatio":true
"deviceId":true
"displaySurface":true
"echoCancellation":true
"facingMode":true
"frameRate":true
"groupId":false
"height":true
"sampleRate":false
"sampleSize":false
"torch":false
"volume":true
"whiteBalanceMode":true
"width":true
"zoom":true}
Tested on iphone 13 pro, 16.4
According to https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getSupportedConstraints, only constraints supported by the user agent are included in the list, each of these Boolean properties has the value true.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Karl Dubost
Thanks Shawn!
Let's head to the spec, instead of MDN.
https://w3c.github.io/mediacapture-main/#dom-mediadevices-getsupportedconstraints
getSupportedConstraints
Returns a dictionary whose members are the constrainable properties known to the User Agent.
* A supported constrainable property MUST be represented
* AND any constrainable properties not supported by the User Agent MUST NOT be present in the returned dictionary.
* The values returned represent what the User Agent implements and will not change during a browsing session.
Safari on desktop reports WRONGFULLY:
"groupId":false
"sampleRate":false
"sampleSize":false
"torch":false
So indeed there is a bug here. That looks like an easy fix
https://searchfox.org/wubkat/rev/c67bb750f2c1083399f0dbe7d08b416cd45eee34/Source/WebCore/Modules/mediastream/MediaDevices.cpp#363-383
Where the value is added to result only if the value is true.
In more details:
On STP 190
{"aspectRatio":true
"deviceId":true
"displaySurface":true
"echoCancellation":true
"facingMode":true
"frameRate":true
"groupId":false
"height":true
"sampleRate":false
"sampleSize":false
"torch":false
"volume":true
"whiteBalanceMode":true
"width":true
"zoom":true}
On Firefox Nightly 125.0a1 (2024-03-10) (64-bit)
{"autoGainControl":true
"browserWindow":true
"channelCount":true
"deviceId":true
"echoCancellation":true
"facingMode":true
"frameRate":true
"groupId":true
"height":true
"mediaSource":true
"noiseSuppression":true
"scrollWithPage":true
"viewportHeight":true
"viewportOffsetX":true
"viewportOffsetY":true
"viewportWidth":true
"width":true}
On Chrome Canary Version 124.0.6350.0
{"aspectRatio":true
"autoGainControl":true
"brightness":true
"channelCount":true
"colorTemperature":true
"contrast":true
"deviceId":true
"displaySurface":true
"echoCancellation":true
"exposureCompensation":true
"exposureMode":true
"exposureTime":true
"facingMode":true
"focusDistance":true
"focusMode":true
"frameRate":true
"groupId":true
"height":true
"iso":true
"latency":true
"noiseSuppression":true
"pan":true
"pointsOfInterest":true
"resizeMode":true
"sampleRate":true
"sampleSize":true
"saturation":true
"sharpness":true
"suppressLocalAudioPlayback":true
"tilt":true
"torch":true
"voiceIsolation":true
"whiteBalanceMode":true
"width":true
"zoom":true}
Radar WebKit Bug Importer
<rdar://problem/124372654>
Karl Dubost
I may have a quick patch for this.
Karl Dubost
After chatting with Youenn, there's some part that could be better optimized.
With probably removing `RealtimeMediaSourceCenter::supportedConstraints`
Karl Dubost
The WebIDL in the spec is defined as
partial interface MediaDevices {
MediaTrackSupportedConstraints getSupportedConstraints();
Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints = {});
};
Also
https://searchfox.org/wubkat/source/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl
and bug 169871
Karl Dubost
The PR is in https://github.com/WebKit/WebKit/pull/25712
EWS
Committed 275945@main (8153861f277e): <https://commits.webkit.org/275945@main>
Reviewed commits have been landed. Closing PR #25712 and removing active labels.