mavris / MMLanScan

An iOS LAN Network Scanner library
MIT License
490 stars 121 forks source link

App crashing after ping #46

Open elisgjana opened 5 years ago

elisgjana commented 5 years ago
Screenshot 2019-06-19 at 14 39 01

When I start scanning the network, at some random time(not every time), the app crashes and I get this error. Can you please help me to fix it.

rpolenthon commented 5 years ago

I have the same issue often.

nimisha112 commented 5 years ago

I am also facing the same issue.

mavris commented 5 years ago

Can you please reproduce the error or give me some details? How many devices they are in the network? subnet etc?

elisgjana commented 5 years ago

Thank you for your response. My subnet is /24 and there are 10 devices on the network, but as far as I noticed, it doesn't depend on the number of devices. I have tried also in different networks with less devices and still after several scannings in a row, it will crash the app.

I used also the commit that @jpalten did with all the changes to your code, and the application works somehow better, the crashes happen more rare but still, they happen. Here are some images of the crash.

Screenshot 2019-10-04 at 12 07 47

Screenshot 2019-10-04 at 12 16 06

I would really appreciate if you have a look also to the @jpalten commit and after that to find some solutions for this crashing problem. My application really depends on this library.

Thank you again for the response.

mavris commented 5 years ago

Can you please create a project that reproduces this error? I will download it and I will try to find the issue. I did more than 20 scans in a row and the app is running fine.

elisgjana commented 5 years ago

https://gitlab.com/elisgjana/lan-scan-test This is a simple app just implementing your library and by refreshing I produced these types of errors (These errors are really random: some of them I faced by refreshing more than 30 times. So, sometimes the app looks like it is working fine, but if you test it for 10 to 15 minutes it will crash at some point):

Screenshot 2019-10-08 at 12 59 35 Screenshot 2019-10-08 at 12 36 27 Screenshot 2019-10-08 at 12 12 14 Screenshot 2019-10-08 at 12 15 57
rpolenthon commented 5 years ago

@elisgjana is exactly pointing the issues, which I also experience, out with the provided screenshots.

It isn't reproducible by code changes, it just happens after intensive testing. The problem is that app users could experience this issue directly during the first usage, so they got directly a negative app experience.

It would be really great if you can fix the issues anytime.

mavris commented 5 years ago

@rpolenthon I understand the impact of the negative first usage but you need to understand that I was at your place 3 years ago (I wanted to use a network scanner library) and I created one instead and I was kind enough to open source it. So I would suggest that you and @elisgjana join me, and help me to find the issue instead of requesting to be fixed.

My time is limited and this project it's just a hobby to me. So, since this bug is affecting you and @elisgjana, I would suggest starting digging in Apple's SimplePing. Something is going wrong in this class. You could try to replace it with any other Ping class (it won't be that hard). Post your updates here and I will join you as soon as I find some free time.

rpolenthon commented 5 years ago

@mavris I don’t want do criticism about your work.

I am really happy about that you shared your work with the world. I completely understand if you have not enough time to deep dive in again.

By writing in the issues, my main afford was to show that the issue (still) exists.

Yes it is bad, but I completely understand you. If I would have enough time to check out more deeply how the library works and why it may crashes, I would do so. But currently I am at my personal limit with the main app functionality.

So if someone has time to fix it, it would be awesome, otherwise I will do it in Spring 2020 when I have a bigger gap for these improvements.

Luckily the network scanner is just a tool in the app, so it is not the main use case.

elisgjana commented 5 years ago

@mavris I am really thankful for publishing your work, not only for this library but also the others and I really understand that your time is limited, that's why I will do my best to help you in order to find a mutual solution. The only barrier for me is the lack of knowledge in Objective C that's why everything looked so abstract to me. For me this is a main feature for the application (smart home app) and this is why I am testing all the possible options. I tested the commit that @jpalten did and it fixes a lot of problems even-though the app still crashes (but not so often). I think by reviewing his commit would be a good headstart. Thanks again for your support.

mavris commented 5 years ago

@elisgjana I used your project and I added a timer for a scan every 10 seconds. It ran 106 times without a crash. I understand that the bug is there. I will try to reproduce it on another network. @elisgjana can you please point me to exact commit?

elisgjana commented 5 years ago

@mavris please refer to these changes https://github.com/mavris/MMLanScan/pull/22 @jpalten has updated the SimplePing class based on the Apple Documentation because I just opened the Apple Documentation and they haven't updated the code since 2016.

Also sometimes the app crashes as soon as it scans for the first time.

elisgjana commented 4 years ago

@mavris I think I fixed one of the bugs by adding an "if condition" and checking if the socket is valid before stoping it:

Screenshot 2019-12-02 at 12 01 21

The scanning looks better now, but still crashes after some time in two different points:

Screenshot 2019-11-29 at 16 16 28

Screenshot 2019-12-02 at 12 05 13

Can you please have a look when you have time and check what can we do to fix it.

iMacHumphries commented 4 years ago

This might be related 🤷‍♂️ https://github.com/mavris/MMLanScan/pull/53