RESOLVED FIXED 270779
Navigator.mediaDevices.getSupportedConstraints mistakenly reports torch as false.
https://bugs.webkit.org/show_bug.cgi?id=270779
Summary Navigator.mediaDevices.getSupportedConstraints mistakenly reports torch as fa...
Shawn Lee
Reported 2024-03-10 21:57:11 PDT
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
Karl Dubost
Comment 1 2024-03-10 23:35:54 PDT
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
Comment 2 2024-03-10 23:36:02 PDT
Karl Dubost
Comment 3 2024-03-11 00:01:50 PDT
I may have a quick patch for this.
Karl Dubost
Comment 4 2024-03-11 05:18:59 PDT
After chatting with Youenn, there's some part that could be better optimized. With probably removing `RealtimeMediaSourceCenter::supportedConstraints`
Karl Dubost
Comment 5 2024-03-11 05:24:10 PDT
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
Comment 6 2024-03-11 17:11:49 PDT
EWS
Comment 7 2024-03-11 18:49:38 PDT
Committed 275945@main (8153861f277e): <https://commits.webkit.org/275945@main> Reviewed commits have been landed. Closing PR #25712 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.