iOS 14.5 WKWebView's getUserMedia errors NotReadableError after CallKit takes over

Viewed 298

We use Ionic 5 with Capacitor 3, using the latest iOS version which supports getUserMedia for capacitor scheme.

getUserMedia does work for me, but once i've implemented the CallKit provider, i get:

NotReadableError: The I/O read operation failed

Whenever I answer the call. We've tried deactivating the AudioSession using

audioSession.setActive(false)

inside all these methods:

provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession)
provider(_ provider: CXProvider, perform action: CXAnswerCallAction)
pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void)

Both nothing helps. Is there a priority factor or do i need to do some interruptions?

2 Answers

I ran into the same problem and could not find a solution. If I understand correctly, getUserMedia and CallKit don't work together, probably because CallKit gives the app process exclusive access to the microphone, but WKWebView renderer runs in a separate process. If I call CallKit first, getUserMedia returns IO error. If I call getUserMedia first, then the stream is disconnected once I call CallKit.

Assuming this question relates to WebRTC connection in WKWebView, what worked for me is replacing media stream about 2 seconds after the connection is established.

MDN has the example of how to replace the media stream: https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpSender/replaceTrack

Usually this is used to flip the camera between front/back, but somehow it enables the microphone when using WKWebView with CallKit.

This doesn't help enabling microphone when the app is in background though...

Related