w3c / mediacapture-image

Mediastream Image Capture
https://w3c.github.io/mediacapture-image/
Other
74 stars 40 forks source link

Enforcing user gesture for getUserMedia in case of PTZ request #254

Open youennf opened 4 years ago

youennf commented 4 years ago

Following on https://github.com/w3c/mediacapture-main/issues/639, calling getUserMedia would ideally be gated by a user gesture. This is difficult to enforce it for regular getUserMedia calls due to existing usage of getUserMedia. But it might be possible to enforce it in case getUserMedia is requesting PTZ privilege, since this is a new feature.

beaufortfrancois commented 4 years ago

LGTM

@jan-ivar @alvestrand any objections?

beaufortfrancois commented 4 years ago

(gentle ping)

@jan-ivar @alvestrand @guidou for thoughts

jan-ivar commented 3 years ago

@youennf is this something you think we need to address before wide review?

youennf commented 3 years ago

Given there is consensus there, what is missing is the editorial work.. I think it would be good to do so before wide review.

I guess this could be added directly to medicapture-image, in pan, tilt and zoom sections that talk about permission requests.

eehakkin commented 3 years ago

So how should this gating work? Should the descriptions of pan, tilt and zoom photo capabilities and constrainable properties be amended with text like

"The user agent MUST ignore any persisted granted permissions unless the document's Window object has transient activation."

The idea here is to align with the main spec which might get similar gating if https://github.com/w3c/mediacapture-extensions/issues/11 is resolved as @youennf suggested (https://github.com/w3c/mediacapture-extensions/issues/11#issuecomment-593307645) based on @alvestrand's and @jan-ivar 's comments.

In that is it would actually be that the persisted granted permissions (and not the getUserMedia calls per se) would be gated by a user gesture which is apparently called transient activation nowadays.

youennf commented 3 years ago

Given this is a new feature and that applications should opt-in, I do not think we have compat breakage by requiring transient activation. We could probably do like for getDisplayMedia: reject the promise if getUserMedia is called with any pan/tilt/zoom constraint and document does not have transient activation.