apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

"getUserMedia" broken in iOS 15 #1153

Closed idoodler closed 2 years ago

idoodler commented 2 years ago

Bug Report

Problem

On Devices running iOS 15 and iOS 15.1 getUserMedia({audio: true}) does resolve with a broken/ not audible MediaStream

What is expected to happen?

The MediaStream should have the users Microphone and the audio should be audible

What does actually happen?

No audio is audible, even the orange record indicator in the top right corner of the StatusBar is not visible.

Information

I also tried to recreate this issue using a plain xCode Project without Cordova, so just an empty iOS xCode Project (Swift) with a WKWebView showing https://idoodler.de/projects/getUserMedia/ => Issue can't be reproduced. Maybe it is because of the Cordova's Custom URLSchemeHandler? UPDATE I modified the xCode project to load the resources from the filesystem just like Cordova does BOOM, same issue!

I already submitted a Feedback about this issue to Apple and created a TSI, no response whatsoever from Apple.

Just for Reference: Feedback ID: FB9492341

Command or Code

Find the sample Application here: https://github.com/idoodler/iOS15-GetUserMedia

Environment, Platform, Device

All devices running iOS 15 and iOS 15.1

Version information

Cordova CLI: 10.0.0 Cordova iOS: ^6.2.0 xCode: 13 iOS: 15 and 15.1

Checklist

idoodler commented 2 years ago

Update

I modified the xCode project to load the resources from the filesystem just like Cordova does BOOM, same issue!

dpogue commented 2 years ago

Are you using file:/// URLs or setting scheme and hostname preferences in config.xml to use a custom scheme?

idoodler commented 2 years ago

@dpogue In the config.xml under platform iOS the following is defined.

<platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="scheme" value="app" />
        <preference name="hostname" value="localhost" />
        <access origin="cdvfile://*" />
       [REDACTED]
 </platform>

As I mention above I can reproduce the same behaviour in a plain Swift app loading the resources from the Filesystem (using file://, but not if I load them from a remote webserver).

I checked the WebViewEngine and the resources are loaded using the file:// scheme.

idoodler commented 2 years ago

I also checked the WKWebViews's microphoneCaptureState, it is correctly set to active, even though it is not correctly recording

idoodler commented 2 years ago

Workaround found

I modified the plugin cordova-plugin-local-webserver to work with the current version of Cordova. As this loads the resources from a Webserver everything works fine.

idoodler commented 2 years ago

I will close this issue as it is also reproducible without Cordova. As I mentioned I already filed a Feedback for Apple.

idoodler commented 2 years ago

Just to keep you guys updated, Apple finally responded to the FBA. They offer two workarounds:

  1. Load the Website from a HTTP(S)-Server -> I already found that workaround as mentioned above
  2. Load the Website via a custom scheme handler: ionic://index.html won't work on iOS 15.0, ionic://SCHEME/page.html works

I didn't verify their second workaround