[Webkit-unassigned] [Bug 208667] getUserMedia does not work in WKWebView-based browsers like Chrome, Firefox.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 9 02:36:15 PST 2020


https://bugs.webkit.org/show_bug.cgi?id=208667

--- Comment #66 from support at buildagil.ch ---
Comment on attachment 415730
  --> https://bugs.webkit.org/attachment.cgi?id=415730
Sample files and images

I can confirm that getUserMedia() works with iOS 14 Beta 2 and Beta 3 using a WKWebView.
Unfortunately there is another annoying issue with "the emerging life" of getUserMedia().
When executing getUserMedia() two similar prompts for user permission appear for:
a) using the camera and (getUserMedia({ video: true }))
b) using the microphone (getUserMedia({ audio: true }))
Since this makes absolutely no sense for an enduser I consider this a bug.
I attached the HTML and screenshots that show the problem.
I use webView in Swift 5 as follows:
```
class ViewController: UIViewController, WKNavigationDelegate, UIScrollViewDelegate, WKUIDelegate {
    @IBOutlet var webView: WKWebView!

    override func loadView() {
        isLoading = true
        NotificationCenter.default.addObserver(self, selector: #selector(onOpenDeepLink(_:)), name: .openDeepLink, object: nil)

        super.loadView()
        let config = WKWebViewConfiguration()
        config.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
        config.allowsInlineMediaPlayback = true
        navigatorGeolocation.setUserContentController(webViewConfiguration: config)
        webView = WKWebView(frame: .zero , configuration: config)
        webView.navigationDelegate = self
        webView.uiDelegate = self
        webView.scrollView.delegate = self
        webView.backgroundColor = UIColor(red:0.855, green:0.855, blue:0.855, alpha:1)
        webView.scrollView.backgroundColor = UIColor(red:0.855, green:0.855, blue:0.855, alpha:1)
        navigatorGeolocation.setWebView(webView: webView)
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        url = URL(string: "https://app.buildagil.ch/assets/www/camera.html")!
    }

    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        guard #available(iOS 14.2, *) else {
            webView.evaluateJavaScript("delete navigator.__proto__.mediaDevices")
            return
        }
    }
}


``` 

Note: this behaviour is basically the same as we already know from the navigator.geolocation.getCurrentPosition() API. This problem can be solved by following the solution described here: https://stackoverflow.com/questions/39665367/how-to-prevent-wkwebview-to-repeatedly-ask-for-permission-to-access-location
There seems to be the same underlying problem causing this behavior with WKWebView. As it seems there is a problem with managing/mapping the permissions granted to the app (1st prompt) itself and the embedded webView (2nd prompt).

-- 
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/20201209/850ba002/attachment.htm>


More information about the webkit-unassigned mailing list