Skyost / Bonsoir

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.
http://bonsoir.skyost.eu/
Other
100 stars 43 forks source link

Crashes on iOS caused by DNSServiceProcessResult #91

Closed foxik0169 closed 2 months ago

foxik0169 commented 3 months ago

Describe the bug When calling resolve on a lot services (10+) on iOS there is potential for a crash in DNSServiceProcessResult() function. This can happen because the underlying socket is not available anymore. To fix this, I've implemented asynchronous socket access with DispatchSourceRead. The code can be seen in my fork https://github.com/foxik0169/Bonsoir/tree/5.1.9-stream. There are more changes because I went ahead and make the DNSServiceProcessResult() call work concurently and then send the messages to Flutter on main thread.

To Reproduce Part of the issue is that is not easily reproducible. For my network setup (hotspot on PC and 3 wifi devices connected) it did not happen at all. However when on a wifi that contains a lot of services (10+) with the type that I am trying to resolve, it might crash. All these devices are being resolved at the same time.

Expected behavior No crashes in the native code.

Screenshots image

Smartphone (please complete the following information):

Skyost commented 2 months ago

Hey,

Great, this could even be related to #89. Feel free to open a PR once you're ready 🙂

heiha100 commented 2 months ago

Describe the bug When calling resolve on a lot services (10+) on iOS there is potential for a crash in DNSServiceProcessResult() function. This can happen because the underlying socket is not available anymore. To fix this, I've implemented asynchronous socket access with DispatchSourceRead. The code can be seen in my fork https://github.com/foxik0169/Bonsoir/tree/5.1.9-stream. There are more changes because I went ahead and make the DNSServiceProcessResult() call work concurently and then send the messages to Flutter on main thread.

To Reproduce Part of the issue is that is not easily reproducible. For my network setup (hotspot on PC and 3 wifi devices connected) it did not happen at all. However when on a wifi that contains a lot of services (10+) with the type that I am trying to resolve, it might crash. All these devices are being resolved at the same time.

Expected behavior No crashes in the native code.

Screenshots image

Smartphone (please complete the following information):

  • Device: iPhone 12
  • OS: iOS 17.4.1

hey, I am facing the same problem. And Thanks for your solution. Would you open a PR for this issue🩷