[IOS] After close sendTransport in first call. In second video call, sendTransport close automatically

Hi,

I am having an issue, please help.

In first call, all are normal. When end call, I disconnect socket, so it called function and run “if inside”:

`func onConnectionStateChange(_ transport: Transport!, connectionState: String!) {
if parent.isEndCall && !transport.isClosed() {
self.parent.sendTransport?.close()
self.parent.sendTransport?.dispose()
self.parent.sendTransport = nil
}

}`

In new call, after connect socket , I initialized:

self.sendTransport = self.device.createSendTransport(self.sendTransportHandler!.delegate!, id: id, iceParameters: iceParameters.description, iceCandidates: iceCandidatesArray.description, dtlsParameters: dtlsParameters.description)

In here, I printed:

self.sendTransport!.isClosed() and it is false (not close). But after that, it change to true(closed) soon. So I get crash at

let kindProducer: Producer = self.sendTransport!.produce(self.producerHandler!.delegate!, track: track, encodings: encodings, codecOptions: codecOptions)

And sure, I debugged, in second call, didn’t call anything related these lines:

self.parent.sendTransport?.close() self.parent.sendTransport?.dispose() self.parent.sendTransport = nil

Anyone have idea?

crash log

*** Terminating app due to uncaught exception ‘RuntimeException’, reason: ‘SendTransport closed’
terminating with uncaught exception of type NSException
2021-01-18 18:09:01.647078+0700 [644:135559] *** Terminating app due to uncaught exception ‘RuntimeException’, reason: ‘SendTransport closed’
*** First throw call stack:
(0x183310ec4 0x1824e1a40 0x107146ef0 0x1024b1de0 0x1024b15e4 0x102521038 0x102520ba8 0x102520990 0x10251d7a8 0x10251d4dc 0x10251d50c 0x18327f94c 0x18327f918 0x18327ee08 0x18327eab4 0x1831f6c90 0x18327e540 0x1024b6e0c 0x1024e3b88 0x1024a808c 0x10955b824 0x10955cdc8 0x10956aa78 0x1832a0df4 0x18329bcbc 0x18329b1f0 0x185514584 0x1b04a6bc0 0x1094cd468 0x102536be4 0x102536b5c 0x102536c28 0x182d5abb4)
libc++abi.dylib: terminating with uncaught exception of type NSException

1 Like

Hello,

I am in the same situation. Calling close for a transport crashes the app.

@ethand91 Would you have a simple example to close a video call using swift or objc in order to avoid memory leaks ?

Thanks

1 Like

You can use trick, like me. Disconnect socket first. After that, close transport.

Hello,

Thanks for your answer.

I tried to use a flag like “endCall” and to close the sendTransport after disconnecting the socket. But is till crashes.
Even with a dispatch after 10 seconds (for debug purpose), calling close still crashes the app.

Any help with clear steps is more than welcome.

Thanks

try close at delegate bro in

private class RecvTransportHandler : NSObject, RecvTransportListener and private class SendTransportHandler : NSObject, SendTransportListener

func onConnectionStateChange(_ transport: Transport!, connectionState: String!) {
print("RecvTransport::onConnectionStateChange newState = " + connectionState)
if parent.isEndCall && !transport.isClosed() {

            self.parent.recvTransport?.close()
            self.parent.recvTransport?.dispose()
            //self.parent.recvTransport = nil
        }
        //print(transport.getConnectionState())
    }
1 Like

Hello,

Thanks,
It works for recvTransport. I can call close and call dispose for it. But if I do the same thing for sendTransport, it crashes…

Do you have crash log?

I hope it helps

Thanks a lot @cavoixanh

Just debug, as I saw,

SendTransport::onConnectChange : disconnected

========== 404 - close trans

SendTransport::onConnectChange : closed

I also close transport at state: disconnected
I can ask about socket code, do you use sample of Ethan91? (EchoSocket, ActionEvent, MessageObserver, RoomClient,…)

1 Like

Thanks,

I use SocketRocket library. Do you think it’s because of it ? Thanks

I ask about socket library because I used sample of Ethan91, and it created bug that I posted( issue related thread). After coded socket send/recv method again, issue is fixed. Not sure if it also is issue of your project.

Thanks,

What library do you use for the socket management ?

I used starscream, version in sample.

pod ‘Starscream’, ‘3.0.6’

1 Like

Thanks,

Are you still using this library ?

Yes, I still use it, but removed DispatchSemaphore.