App crash after closing session
k0ry opened this issue · 1 comments
Hello, after going to authorizationStateClosed and trying to create a new instance of TdClientImpl I receive SIGABRT with logging information "Receive is called after Client destroy, or simultaneously from different threads. Fatal error: Attempted to read an unowned reference but object 0xXXXXX was already deallocated".
Deinit of TdClientImpl calls func close(), after that in run func used unowned self - leading to SIGABRT. What can I do in this situation? May be rewrite func something like this?:
public func run(updateHandler: @escaping CompletionHandler) {
self.updateHandler = updateHandler
createClientIfNeeded()
tdlibMainQueue.async { [weak self] in
guard !self.isClientDestroyed else { return }
guard let self = self else {return}
while (!self.stopFlag) {
guard
let res = td_json_client_receive(self.client, 10),
let data = String(cString: res).data(using: .utf8)
else {
continue
}
self.logger?.log(String(cString: res), type: .receive)
self.queryResultAsync(data)
}
}
}
Got into same error. Am I wrong or is the td_json_client old and unsupported? Is this lib supported? Did you find a solution here?