emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.57k stars 411 forks source link

Crash in CocoaMQTTWebSocket #512

Closed jimbengtsson92 closed 1 year ago

jimbengtsson92 commented 1 year ago

We have received 5 crashes from CocoaMQTTWebSocket.swift - Line 193 which is the timer?.cancel() call inside here:

func reset() {
    timer?.cancel()
    timer = nil
}

All of these crashes come from v2.0.7 of CocoaMQTT. These are reported from crashlytics so the below stack trace is all info i have, I do not know of a way to reproduce it from our app.

Screenshot 2023-01-19 at 12 10 38

leeway1208 commented 1 year ago

Hi. I will try to fix it.

jimbengtsson92 commented 1 year ago

Hi,

Thank you @leeway1208 for taking the time to look at the issue. I don't think the commit fixes the issue though. Please see my comment in the commit, https://github.com/emqx/CocoaMQTT/commit/680327c65c43def6e9e23fd72e7e75b115043f59#commitcomment-97465774.

przemyslaw-szurmak commented 1 year ago

@jimbengtsson92 Hey, i have a feeling that my threading fix done in https://github.com/emqx/CocoaMQTT/pull/515 could help your case too.

jimbengtsson92 commented 1 year ago

Thanks @przemyslaw-szurmak, I'll get back if the problem still occurs with this fix included.

sky-NunoPereira commented 1 year ago

Hi, @jimbengtsson92 were you able to reproduce the crash with this new fix? Or this crash stop occurring after the fix applied? Thanks in advance.

jimbengtsson92 commented 1 year ago

@sky-NunoPereira So far I have not seen any crashes from this package with this fix included. But it is worth noting that I have never been able to reproduce the crash myself, so I cannot say for sure that this has fixed it. But for now it looks promising at least.

jimbengtsson92 commented 1 year ago

@sky-NunoPereira I think that the fix from @przemyslaw-szurmak fixed this issue. We have at least not received any more crashes after updating to the version with the fix included.

przemyslaw-szurmak commented 1 year ago

@jimbengtsson92 Thanks for letting is know!