mediasoup-ios-client icon indicating copy to clipboard operation
mediasoup-ios-client copied to clipboard

iOS - Crash after trying sendTransport.close()

Open kgenrih17 opened this issue 3 years ago • 8 comments

There are no entries to logs. But before that, the transport changes the status "onConnectionStateChange to:" closed ""

info: There are two sending transports:

  • audio
  • video and Two receiving transports:
  • audio
  • video

Thread 1: EXC_BAD_ACCESS (code=1, address=0x146826de0)

class LocalClient: NSObject {

    private(set) var transports: [String: SendTransport] = [ : ]

    func close() {
        
        transports.values.forEach { (sendTransport) in
            
            guard !sendTransport.isClosed() else {
                return
            }
            
             sendTransport.close() 
        }
    }

}

What am I doing wrong when closing?

kgenrih17 avatar Dec 15 '20 10:12 kgenrih17

Found a solution to the problem. Are there any other ways to shut down transport, in any other case?

// SendTransportListener / RecvTransportListener
func onConnectionStateChange (_ transport: Transport !, connectionState: String!) {

guard let peerConnectionState = RTCPeerConnectionState (rawValue: connectionState) else {
return
}

switch peerConnectionState {

case .disconnected, .failed:
transport.close ()

default:
return
}

// connectionState is RTCPeerConnectionState
/ *
enum RTCPeerConnectionState {
   "closed",
   "failed",
   "disconnected",
   "new",
   "connecting",
   "connected"
};
* /`

kgenrih17 avatar Dec 17 '20 15:12 kgenrih17

@kgenrih17 hello, are you able to close "sendTransport" ? on my side, it crashes all the time.

Thanks

Bengua27 avatar Jan 21 '21 14:01 Bengua27

Hello,

I fixed the issue:

  • call close when you are closing the call and the status of sendTransport is "disconnected"
  • call stop of the mediaCapture when the status of sendTransport is "closed"

Bengua27 avatar Jan 29 '21 13:01 Bengua27

Thanks.

Henrikh91 avatar Apr 20 '21 20:04 Henrikh91

Please check this PR: https://github.com/ethand91/mediasoup-ios-client/pull/107. Still with memory leaks, but seems to fix the crash on disconnect.

fedulvtubudul avatar Aug 02 '21 06:08 fedulvtubudul

Hello,

I fixed the issue:

  • call close when you are closing the call and the status of sendTransport is "disconnected"
  • call stop of the mediaCapture when the status of sendTransport is "closed"

@Bengua27 Could you please tell me how you've solved this crash? I can not find stop method in the MediaCapture class.

rushisangani avatar Sep 07 '21 09:09 rushisangani

doesn't work for me. does anyone use libmediasoup directly on ios?

newOcean avatar Jun 24 '22 11:06 newOcean

@rushisangani @fedulvtubudul thanks, working.

@newOcean yes, using and good working with 100+ users with audio + video streaming.

Henrikh91 avatar Jan 02 '23 01:01 Henrikh91