iOS with WKWebView randomly freezes live videostream (Ionic Capacitor)

Hi all,

I have a very weird problem. I searched all over the place but can’t find the cause or solution. Here’s a brief description;

On any device we can start a WebRTC video stream with ‘getUserMedia()’ this works fine. When we’re on the receiving end we assign the stream to a video tag and it shows the live broadcast. This works fine on Android and Web, but on iOS this stream freezes, sometimes in the first second, sometimes after 10 seconds, sometimes after a minute. We are using Capacitor together with Ionic and Angular.

<video #videoElement [srcObject]="myVideoStream" controls autoplay playsinline webkit-playsinline></video>

When, in Angular, logging events on the videoPlayer, we never receive ANY errors. We’ve tried manually and programmatically executing pause() and play() but then the frozen screen just disappears and we see an empty video player.
The MediaStream.GetVideoTracks() function still logs a correct stream, the websocket is still alive… nothing logs any errors. Even if I watch the same stream on any other device, I’m seeing that it’s actually still up & running.

After refreshing the Angular component, it works again, but freezes after some time. I’m starting to think that iOS itself decides to ‘disable’ the view? Because there’s no other indication of any errors in the MediaStream, the VideoTracks, the Websocket or the VideoPlayer.

Does anyone has some other possible solutions? And also… maybe a possible way to find the cause? Because without ‘noticing’ when it goes wrong, we can’t restart the stream. Right now a user has to click a manual ‘reconnect’ button every few moments.