Bug 227608

Summary: the method getDisplayMedia only can be called from a user gesture handler
Product: WebKit Reporter: walter <yafan>
Component: WebRTCAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Critical CC: webkit-bug-importer, yafan, youennf
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Unspecified   
OS: Unspecified   

Description walter 2021-07-01 22:32:09 PDT
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 "getDisplayMedia" method from a user gesture handler directly. The reason is  we need to get the presenter privilege first.
As a result, the calling of "getDisplayMedia" 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.
Comment 1 Radar WebKit Bug Importer 2021-07-08 22:33:15 PDT
<rdar://problem/80360292>