<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>270779</bug_id>
          
          <creation_ts>2024-03-10 21:57:11 -0700</creation_ts>
          <short_desc>Navigator.mediaDevices.getSupportedConstraints mistakenly reports torch as false.</short_desc>
          <delta_ts>2024-03-11 18:49:40 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=169871</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Shawn Lee">shawnlee</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>karlcow</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2020014</commentid>
    <comment_count>0</comment_count>
    <who name="Shawn Lee">shawnlee</who>
    <bug_when>2024-03-10 21:57:11 -0700</bug_when>
    <thetext>demo : https://sy74yv.csb.app/
It will show the result of getSupportedConstraints.
{&quot;aspectRatio&quot;:true
&quot;deviceId&quot;:true
&quot;displaySurface&quot;:true
&quot;echoCancellation&quot;:true
&quot;facingMode&quot;:true
&quot;frameRate&quot;:true
&quot;groupId&quot;:false
&quot;height&quot;:true
&quot;sampleRate&quot;:false
&quot;sampleSize&quot;:false
&quot;torch&quot;:false
&quot;volume&quot;:true
&quot;whiteBalanceMode&quot;:true
&quot;width&quot;:true
&quot;zoom&quot;:true}{&quot;aspectRatio&quot;:true
&quot;deviceId&quot;:true
&quot;displaySurface&quot;:true
&quot;echoCancellation&quot;:true
&quot;facingMode&quot;:true
&quot;frameRate&quot;:true
&quot;groupId&quot;:false
&quot;height&quot;:true
&quot;sampleRate&quot;:false
&quot;sampleSize&quot;:false
&quot;torch&quot;:false
&quot;volume&quot;:true
&quot;whiteBalanceMode&quot;:true
&quot;width&quot;:true
&quot;zoom&quot;: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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020019</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-10 23:35:54 -0700</bug_when>
    <thetext>Thanks Shawn!

Let&apos;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:
 
&quot;groupId&quot;:false
&quot;sampleRate&quot;:false
&quot;sampleSize&quot;:false
&quot;torch&quot;: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

{&quot;aspectRatio&quot;:true
&quot;deviceId&quot;:true
&quot;displaySurface&quot;:true
&quot;echoCancellation&quot;:true
&quot;facingMode&quot;:true
&quot;frameRate&quot;:true
&quot;groupId&quot;:false
&quot;height&quot;:true
&quot;sampleRate&quot;:false
&quot;sampleSize&quot;:false
&quot;torch&quot;:false
&quot;volume&quot;:true
&quot;whiteBalanceMode&quot;:true
&quot;width&quot;:true
&quot;zoom&quot;:true} 


On Firefox Nightly 125.0a1 (2024-03-10) (64-bit)

 {&quot;autoGainControl&quot;:true
&quot;browserWindow&quot;:true
&quot;channelCount&quot;:true
&quot;deviceId&quot;:true
&quot;echoCancellation&quot;:true
&quot;facingMode&quot;:true
&quot;frameRate&quot;:true
&quot;groupId&quot;:true
&quot;height&quot;:true
&quot;mediaSource&quot;:true
&quot;noiseSuppression&quot;:true
&quot;scrollWithPage&quot;:true
&quot;viewportHeight&quot;:true
&quot;viewportOffsetX&quot;:true
&quot;viewportOffsetY&quot;:true
&quot;viewportWidth&quot;:true
&quot;width&quot;:true} 


On Chrome Canary Version 124.0.6350.0 

{&quot;aspectRatio&quot;:true
&quot;autoGainControl&quot;:true
&quot;brightness&quot;:true
&quot;channelCount&quot;:true
&quot;colorTemperature&quot;:true
&quot;contrast&quot;:true
&quot;deviceId&quot;:true
&quot;displaySurface&quot;:true
&quot;echoCancellation&quot;:true
&quot;exposureCompensation&quot;:true
&quot;exposureMode&quot;:true
&quot;exposureTime&quot;:true
&quot;facingMode&quot;:true
&quot;focusDistance&quot;:true
&quot;focusMode&quot;:true
&quot;frameRate&quot;:true
&quot;groupId&quot;:true
&quot;height&quot;:true
&quot;iso&quot;:true
&quot;latency&quot;:true
&quot;noiseSuppression&quot;:true
&quot;pan&quot;:true
&quot;pointsOfInterest&quot;:true
&quot;resizeMode&quot;:true
&quot;sampleRate&quot;:true
&quot;sampleSize&quot;:true
&quot;saturation&quot;:true
&quot;sharpness&quot;:true
&quot;suppressLocalAudioPlayback&quot;:true
&quot;tilt&quot;:true
&quot;torch&quot;:true
&quot;voiceIsolation&quot;:true
&quot;whiteBalanceMode&quot;:true
&quot;width&quot;:true
&quot;zoom&quot;:true}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020020</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-03-10 23:36:02 -0700</bug_when>
    <thetext>&lt;rdar://problem/124372654&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020021</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-11 00:01:50 -0700</bug_when>
    <thetext>I may have a quick patch for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020057</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-11 05:18:59 -0700</bug_when>
    <thetext>After chatting with Youenn, there&apos;s some part that could be better optimized.
With probably removing `RealtimeMediaSourceCenter::supportedConstraints`</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020062</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-11 05:24:10 -0700</bug_when>
    <thetext>The WebIDL in the spec is defined as

partial interface MediaDevices {
  MediaTrackSupportedConstraints getSupportedConstraints();
  Promise&lt;MediaStream&gt; getUserMedia(optional MediaStreamConstraints constraints = {});
};


Also 
https://searchfox.org/wubkat/source/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl
and bug 169871</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020287</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-11 17:11:49 -0700</bug_when>
    <thetext>The PR is in https://github.com/WebKit/WebKit/pull/25712</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020330</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-03-11 18:49:38 -0700</bug_when>
    <thetext>Committed 275945@main (8153861f277e): &lt;https://commits.webkit.org/275945@main&gt;

Reviewed commits have been landed. Closing PR #25712 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>