Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved exceeded the number of permissible registered listeners #23

Closed

Conversation

xcadrik
Copy link

@xcadrik xcadrik commented Jul 28, 2021

I was able to reproduce the issue with Samsung Galaxy A51 (Android 11) with forced to use 2G network only in our project. We use getCells() from various threads with 1s refresh rate and it seems that it has problem to unregister listener properly in some cases. When I added that line, then app continue and problem does not occur anymore for now. But I am not 100% sure if it is correct solution.

@mroczis
Copy link
Owner

mroczis commented Aug 2, 2021

Hi @xcadrik, can you please provide more information how you reproduce that crash on your side? An code example where you call NetMonster Core with threading would be helpful.

I managed to get Samsung A40 with Android 11 but can't reproduce it even when I call getCells() every 500 ms.

@mroczis mroczis added the help wanted Extra attention is needed label Aug 2, 2021
@xcadrik
Copy link
Author

xcadrik commented Aug 3, 2021 via email

@mroczis
Copy link
Owner

mroczis commented Aug 3, 2021

Hey, thanks for the sample. As far as I can see you are querying the lib from multiple places and threads. Especially getCells() is invoked at the nearly same time (a few ms diff) from different threads (saveCellInfo, updateInfo). But the main issue is how you use getNetworkType() which is invoked every 100 ms. This eventually floods internal queue of the lib and getCells() response time will be 3 000 ms+ instead of usual 300 ms (on that Samsung A40).

The only proper way how to fix it is to synchronise access from all threads to that critical section where it eventually crashes. It works but processing time increases. And in a few seconds response time is around 6 000 ms.

I'll keep looking for solutions but some code optimisation from your side would be also good!

@xcadrik
Copy link
Author

xcadrik commented Aug 3, 2021 via email

@mroczis mroczis removed the help wanted Extra attention is needed label Aug 13, 2021
@mroczis mroczis closed this Aug 13, 2021
@mroczis
Copy link
Owner

mroczis commented Aug 13, 2021

Should be fixed by caching (2ed098a); tested on your app and avg. response time on Samsung A40 was ~300ms whilst on 2G/EDGE, tested for 10 minutes. Your app seemed to work a bit better 👍.

@creg49
Copy link

creg49 commented Aug 14, 2021 via email

@xcadrik xcadrik deleted the fix/too_many_listeners_exception branch October 19, 2021 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants