ethand91 / mediasoup-ios-client

Mediasoup 3 iOS Client
ISC License
130 stars 64 forks source link

iOS - Crash after trying sendTransport.close() #92

Open kgenrih17 opened 3 years ago

kgenrih17 commented 3 years ago

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

info: There are two sending transports:

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 commented 3 years ago

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"
};
* /`
Bengua27 commented 3 years ago

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

Thanks

Bengua27 commented 3 years ago

Hello,

I fixed the issue:

Henrikh91 commented 3 years ago

Thanks.

fedulvtubudul commented 3 years ago

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.

rushisangani commented 3 years ago

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.

newOcean commented 2 years ago

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

Henrikh91 commented 1 year ago

@rushisangani @fedulvtubudul thanks, working.

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