Bug 227608 - the method getDisplayMedia only can be called from a user gesture handler
Summary: the method getDisplayMedia only can be called from a user gesture handler
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Critical
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-01 22:32 PDT by walter
Modified: 2021-07-08 22:33 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>