<?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>227608</bug_id>
          
          <creation_ts>2021-07-01 22:32:09 -0700</creation_ts>
          <short_desc>the method getDisplayMedia only can be called from a user gesture handler</short_desc>
          <delta_ts>2021-07-08 22:33:15 -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 14</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="walter">yafan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
    
    <cc>yafan</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1774361</commentid>
    <comment_count>0</comment_count>
    <who name="walter">yafan</who>
    <bug_when>2021-07-01 22:32:09 -0700</bug_when>
    <thetext>When we share screen in Safari browser, we found there is a restriction - the method getDisplayMedia must be called from a user gesture handler

In our current meeting behaviour, we cannot call &quot;getDisplayMedia&quot; method from a user gesture handler directly. The reason is  we need to get the presenter privilege first.
As a result, the calling of &quot;getDisplayMedia&quot; is from a callback handler.  We got the following error from the callback handler:

```
getDisplayMedia error: InvalidAccessError InvalidAccessError: getDisplayMedia must be called from a user gesture handler.
```

At least, the calling should not fail. I think a prompt for surface picker or asking permission is acceptable.


Could Safari loosen the restriction just like Chrome browser?

I wrote a example: https://www.fanyamin.com/webrtc/examples/desktop_sharing.html

You can try it by Safari and Chrome, it is ok by Chrome but failed to start sharing by Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775923</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-07-08 22:33:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/80360292&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>