Multiple permission prompting for getUserMedia() on iOS 14.3 Beta and Beta 3

With recent improvements in iOS 14.3 Beta 2 and Beta 3 there is another annoying issue with getUserMedia() emerging.
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 here: https://bugs.webkit.org/show_bug.cgi?id=208667#c68 -> attachment 415730
I use webView in Swift 5 as follows:
Code Block
class ViewController: UIViewController, WKNavigationDelegate, UIScrollViewDelegate, WKUIDelegate {
var webView: WKWebView!
override func loadView() {
super.loadView()
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
webView = WKWebView(frame: .zero , configuration: config)
webView.navigationDelegate = self
webView.uiDelegate = self
webView.scrollView.delegate = self
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).

Is it really necessary to work around this problem like we have to with geolocation?!?

I also posted a comment here https://bugs.webkit.org/show_bug.cgi?id=208667#c68 since it is not clear where the problem cause is coming from.
Yes please!
Looks like the webkit team is aware of this issue:
https://bugs.webkit.org/show_bug.cgi?id=220416
Multiple permission prompting for getUserMedia() on iOS 14.3 Beta and Beta 3
 
 
Q