Closed seidju closed 2 years ago
@FZambia maybe I figured out why it could crash.
Access to specific subscription in serverSubs
is happening asynchronously, so at that moment we can't be sure, that specific object exists for key (channel). Unwrapping is performing on another thread.
private func handleAsyncData(data: Data) throws {
//...
if let _ = self.serverSubs[channel] {
self.delegateQueue.addOperation {
var info: CentrifugeClientInfo? = nil;
if pub.hasInfo {
info = CentrifugeClientInfo(client: pub.info.client, user: pub.info.user, connInfo: pub.info.connInfo, chanInfo: pub.info.chanInfo)
}
let event = CentrifugeServerPublishEvent(channel: channel, data: pub.data, offset: pub.offset, info: info)
self.delegate?.onPublish(self, event)
// remove force unwrap
if self.serverSubs[channel]?.recoverable == true && pub.offset > 0 {
self.serverSubs[channel]?.offset = pub.offset
}
}
//...
}
@seidju hello, I think makes sense - most probably I blindly added force unwrapping by applying the wrong XCode auto fix suggestion.
@FZambia could make a PR for this fix, so we could use updated version of framework in our production app?
Yep, thanks a lot
Closing, let's hope fix from #62 resolves a crash, please re-open if it's still an issue after updating.
Hello! We faced multiple crashes in method
handleAsyncData(data:)
We're using 0.4.2 version in our app
Stack trace: