Thread 1: EXC_BAD_ACCESS (code=1, address=0x20) When subView

假装没事ソ 提交于 2019-12-11 08:07:41

问题


I got a strange error. Thread 1: EXC_BAD_ACCESS (code=1, address=0x20) When a View subView on another view.

Both view object not nil.

How do I solve this issue.

Edit: I am implementing a video chat code with VOIP.

When an incoming call comes and after accept the call. I need to display a screen. This screen is showing fine and other UIElements button etc.. (including button functionalities) everything is working as expected for audio calls.

But, in video call after receive the remote user video I am trying to subView to a view . I could view the remote user screen for a second. suddenly get crashed (Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)).

func session(_ session: QBRTCBaseSession, receivedRemoteVideoTrack videoTrack: QBRTCVideoTrack, fromUser userID: NSNumber) {

  if (session as! QBRTCSession).id == self.session?.id {

      let remoteView :QBRTCRemoteVideoView = QBRTCRemoteVideoView()
      remoteView.videoGravity = AVLayerVideoGravity.resizeAspect.rawValue
      remoteView.clipsToBounds = true
      remoteView.setVideoTrack(videoTrack)
      remoteView.tag = userID.intValue

      var frame = self.mainVideoView.bounds
      frame.origin.y = 0
      remoteView.frame = frame

      self.view.addSubview(remoteView)
     }
}

Where receivedRemoteVideoTrack function is a delegate method for the remote video.


回答1:


Keep in mind that Metal only available with A7 processors or higher. I can suggest you force OpenGLES drawings instead of Metal, for now, just do this:

QBRTCRemoteVideoView.preferMetal = NO


来源:https://stackoverflow.com/questions/50665149/thread-1-exc-bad-access-code-1-address-0x20-when-subview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!