[Webkit-unassigned] [Bug 210104] New: getUserMedia don't remember permissions when asked from inside iframe
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Apr 7 04:45:12 PDT 2020
https://bugs.webkit.org/show_bug.cgi?id=210104
Bug ID: 210104
Summary: getUserMedia don't remember permissions when asked
from inside iframe
Product: WebKit
Version: Safari 12
Hardware: iPhone / iPad
OS: iOS 12
Status: NEW
Severity: Normal
Priority: P2
Component: Media
Assignee: webkit-unassigned at lists.webkit.org
Reporter: szmydadam at gmail.com
It looks like for some weird reason Safari on iOS 12 is not remembering granted permissions when it's invoked from inside iframe (even on the same domain, not cross domain).
Steps (for video but its the same for audio):
1. Put an iframe with code to get user media and add it `allow="camera"` attribute
2. Run `navigator.mediaDevices.getUserMedia({video: true})` from inside an iFrame
3. You'll see system permission prompt for granting access to camera - that's ok as it's the first time you ask for permission. Grant access
4. Run `getUserMedia` again
5. You'll see another system prompt even tough you just granted the permission (and captured stream is even still in memory. Removing it before next attempts do not change anything so im not describing that part)
It behaves differently when you're asking from outside iframe (being on page that hosts the iframe):
1. Run `getUserMedia`
2. You'll see system permission prompt. Grant permission
3. Run `getUserMedia` again
4. There is no additional prompt, media stream is just captured for you. Even if you "clear" the earlier captured stream (by invoking `getTracks().forEach(track => track.stop())`) it's still working as expected and remember the state of permission you just granted.
There is a workaround that seems to work:
1. Run `getUserMedia` from host page (outside of iframe). Grant permission
2. Run `getUserMedia` from inside iframe
3. You'll only see one system permission prompt (the host page one) and every next attempts simply works.
There is one additional issue with above workaround: `enumerateDevies`. It looks like that if you ask for permission from outside iframe and then from inside, enumerateDevices call called from inside of iframe acts like if it wouldn't have permission (device labels are empty).
So the final workaround (with having enumerateDevices working) is to either ask for permission twice (first from inside iframe, then from outside) or ask once (outside iframe) and send list of devices from outside to inside (i.e. via postMessage for cross domain cases). Both workarounds are quite ugly.
I created simple page to reproduce the problem: https://aszmyd.github.io/sandbox/safari-permission-bug - Simply do the steps i descibed above on that page and you'll see what the issue is about.
I saw this problem on:
* Safari 12 on iOS 12.4.3
* Safari 12 on iOS 12.4.5
* Safari 12 on iOS 12.4.6
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200407/5610299e/attachment.htm>
More information about the webkit-unassigned
mailing list