mediasoup-ios-client: associated promise error
I again,
When I try to handle the SendTransportListener
events with a separate class I run into this error again:
[ERROR] transport_wrapper::+[TransportWrapper nativeProduce:listener:track:encodings:codecOptions:appData:]() | The associated promise has been destructed prior to the associated state becoming ready. The associated promise has been destructed prior to the associated state becoming ready.
when calling sendTransport.produce(...
the HandlerClass looks like:
class SendTransportHandler: NSObject, SendTransportListener {
private let socket: Socket
weak var delegate: SendTransportListener?
init(socket: Socket) {
self.socket = socket
super.init()
}
func onProduce(_ transport: Transport!,
kind: String!,
rtpParameters: String!,
appData: String!,
callback: ((String?) -> Void)!) {
l.info("** onProduce")
guard let kind = kind else { return }
let rtp = JSON(parseJSON: rtpParameters)
let params: JSON = [
"transportId": transport.getId() ?? "",
"kind": kind,
"rtpParameters": rtp
]
guard let obj = params.dictionaryObject else { return }
socket.request("produce", data: obj) { res in
l.debug("xx produce result \(res)")
callback(res["id"].stringValue)
}
}
func onConnect(_ transport: Transport!, dtlsParameters: String!) {
guard let params = JSON(parseJSON: dtlsParameters).dictionaryObject else { return }
socket.syncRequest("connectProducerTransport", data: [ "dtlsParameters": params ])
}
func onConnectionStateChange(_ transport: Transport!, connectionState: String!) {
l.verbose("** Send Con change: \(connectionState ?? "n/a")")
}
}
// callsite
self.sendTransport = self.device.createSendTransport(sendTransportHandler.delegate,
id: id,
iceParameters: iceParams,
iceCandidates: iceCandidates,
dtlsParameters: dtlsParams)
This doesn’t happen if I just declare my RoomClient that’s already containing the sendTransport as SendTransportListener
and handle the delegate methods there.
I see the associated promise
error coming up a lot in other issues here. Wrapping in async queues didn’t really help.
#67 might be related.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (2 by maintainers)
I personally gave up, it seems that multithreading is not handled correctly and nobody has the time to focus on mediasoup iOS library. I tried various approaches to sync threads but even if you do that it is not guaranteed that your callback will be invoked on the same thread that mediasoup handler is called.
@cavoixanh yes, the issues you describe are probably the same I had. closing transports didn’t free up memory and added around 40mb every time until the app crashes.
I’m currently not actively working on it anymore b/c of lack of time, sorry I can’t be of more help to you.
I went full web responsive at the moment. Not very confident in this library since I couldn’t make a simple sample work in native iOS. Never tried native android.
Same here, we’d like some more info or the sample working, the promise callback handler error is a nasty one. Thanks for the help in advance.
@tanaymondal If you can share sample ios demo? I also finished demo app but It still get bugs in third, fourth call. Which framework version do you using? or you build framework from code yourself?
Finally, all issues are resolved. The demo app is working fine with the media soup demo server.
Yes, they were on different queues. The
onProduce
is called ondefault-qos
and the socket.io request is being returned on a designated queue since all it’s requests should be handled over the same queue (see https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketManager.html#/c:@M@SocketIO@objc(cs)SocketManager(py)handleQueue ).I’ve rewriten the handler to run sequentially (with a semaphore) in order to return on the same thread. I’ll observe whether this resolves the problem.
The promise object seems to be destructed, basically it considers itself finished… This may be caused when onProduce is called on thread 1, but you are returning the producerId on Thread 2?