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

1

1

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.

enter image description here

enter image description here

Physiography answered 3/6, 2018 at 9:56 Comment(10)
Something is nil; You need to edit your question to show the relevant code.Edict
@Paulw11: I have edited the question.Physiography
Is this a valid forced cast: (session as! QBRTCSession)?Gladis
@staticVoidMan: session type is 'QBRTCSession'. Also this condition is succeeded and View the video for a second.Physiography
Which lines does the crash occur on? Set an exception breakpointEdict
if I comment 'self.view.addSubview(remoteView)' not crashing. But, I could view the remote video for a second (ie, first frame is loaded.).Physiography
@Paulw11: same errorPhysiography
Turn on Zombies?Crawley
I think enable Zombies from Edit scheme right? After enalble, How do I get the error reasonPhysiography
Still the proble exists.Physiography
M
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
Minimus answered 4/6, 2018 at 5:8 Comment(2)
Thanks for the help. Working fine. :)Physiography
There is a strange behaviour, some times this line crashes, QBRTCRemoteVideoView.preferMetal = NO. Woking fine without this. (same device)Physiography

© 2022 - 2024 — McMap. All rights reserved.