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 with latest dependency updates #594

Closed nrbrook closed 1 month ago

nrbrook commented 1 month ago

I see dependencies were updated today. Unfortunately my app now crashes every time it starts because of the CocoaAsyncSocket dependency:

Screenshot 2024-05-16 at 16 29 44

I'm not sure why this dependency was changed, because CocoaAsyncSocket is older than the fork MqttCocoaAsyncSocket, which was the previous dependency.

HuseyinVural commented 1 month ago

I don't think MqttCocoaAsyncSocket is more up-to-date than CocoaAsyncSocket. CocoaAsyncSocket is supported by many more developers and can stay more up-to-date.

We use the version that works with CocoaAsyncSocket in applications that are released to a large number of users. We have not encountered such a crash.

If you can give more details about the environment where you experienced the crash, I think we can have a better idea about the cause of this crash and find a better solution.

This problem may also be related to a problem in your working environment or a problem with the way you use your application. It would be great if you could share more information to clarify the details.

nrbrook commented 1 month ago
Screenshot 2024-05-17 at 17 23 36

As you can see, MqttCocoaAsyncSocket is a fork from CocoaAsyncSocket, and is 16 commits ahead. The latest commit was in 2022 compared to 2020 for CocoaAsyncSocket. The commits since the fork have a number of fixes.

I have provided a stack trace above, let me know what else you would like to know.

It should be easy to reproduce as it occurs when connection is opened.

nrbrook commented 1 month ago

Indeed, this commit in MqttCocoaAsyncSockets appears to be the one that fixes my specific crash: https://github.com/robbiehanson/CocoaAsyncSocket/commit/93ae5cf1c1832a2148b5c8314be8fda6e9752124

HuseyinVural commented 1 month ago

Thanks 🙏

I am aware of this commit history difference. I just wanted to emphasize that it might be safer to use a version that is supported and followed by many more people.

Contrary to what you said, I do not encounter this error. As you said, there is no problem when I open the application, everything is stable.

Of course, there may be users like you who encounter this problem. Or we may assume that the problem you are experiencing is specific to you and that you need to update your own project environment to solve this problem.

I think the changes used for the fix can be pushed to the main CocoaAsyncSocket repo as PR. Of course, I would be happy to support your "revert" commit to quickly resolve your situation.

My only wish is to add the addiction followed by 13K people to the project in the long run.

nrbrook commented 1 month ago

Given that the CocoaAsyncSocket project has not been updated since 2020, it does not appear to be actively maintained. I suggest that my PR is merged to restore the fixes included in MqttCocoaAsyncSocket, and then yes PRs on CocoaAsyncSocket can be submitted, but as it does not appear to be actively maintained then it may take some time for them to be merged.

nrbrook commented 1 month ago

I think the crash may only occur if the app supports background operation, which mine does.

nrbrook commented 1 month ago

In fact this fix was already submitted as a PR, but expired due to no activity from the maintainer. There are many more dead PRs. https://github.com/robbiehanson/CocoaAsyncSocket/pull/802

HuseyinVural commented 1 month ago

Our application supports background work. This problem is not encountered again. Maybe min target may have an effect on this situation. You are right in your situation. I gave approve, but it has no effect. I suggest you make your own fork for now in order to take quick action. Thanks for the support and warning.