I made a very simple app using google webrtc using cocoapod (version 1.1.31999). The signaling and the tracks are fine. I'm testing on iPhone 11 and the remote video just randomly freezes for 5-10 seconds then unfreezes. Looks like some threading issue. Not quite sure how to debug this type of bugs.
I tried logging
func renderFrame(_ frame: RTCVideoFrame?) {
}
and when the video is frozen the method is not called at all. Then it starts firing again and video unfreezes. Could it be that multiple calls of currentVideoTrack?.remove()/add() causes issues somehow? Any thoughts are appreciated.
class RTCVideoView: UIView {
private var currentVideoTrack: RTCVideoTrack?
var rtcVideoView: RTCMTLVideoView = {
let rtcVideoView = RTCMTLVideoView()
rtcVideoView.translatesAutoresizingMaskIntoConstraints = false
return rtcVideoView
}()
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(rtcVideoView)
// Add constraints for the rtcVideoView
}
...
func update(with videoTrack: RTCVideoTrack?) {
currentVideoTrack?.remove(rtcVideoView)
currentVideoTrack = videoTrack
rtcVideoView.contentMode = .scaleAspectFit
videoTrack?.add(rtcVideoView)
}
}