-
Notifications
You must be signed in to change notification settings - Fork 41
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
Getting stuck in notify after a while #151
Comments
After debugging for a while, it seems that it gets stuck in
I have temporarily fixed it for me by adding a check in the start of the function when the value is 0. |
Thanks @vermasrijan19 The event with ctxt.op as 0 is "Read characteristic event" ( |
This had taken me a while to get back because I wanted to be sure but i wanted to be sure but the code of the app is definitely not reading, it is only subscribed to the notification. Likely explanation: I have faced this with 3/4 with Android devices i have tested with. The event never seems to occur when using the highest-spec android 15 pixel7. But it can be reproduced on an older Zenfone 6 and poco f1. I have also noticed that it may be related to the bt buffer on the client device as it seems to occur faster on the lower end devices than the Zenfone. (I honestly don't know enough about bt or Android to have any clue) I have put a dirty workaround for now by using rhack and returning 0 if the event occurs but it is far from ideal. I think using something like try_lock() instead of lock() in the function might be the solution |
I changed to use |
Sorry but i haven't had the bandwidth to be able to test this, I'll try and get back to you soon |
|
okay, so i have found a way to reliably reproduced the issue I will update soon |
You are correct the issue seems to occur when a read/write operation happens during notify, this is not resolved on the |
Okay so , it looks like it is my bad, the deadlock was being caused due to a resource being locked before notify, it is not available 🤦. But i have a couple of things , i would found a couple of things that I can submit PRs for |
Okay so follow up, there were more than 1 issues , it seems that if you keep notifying in a loop, without delay it does eventually cause a deadlock. Using try_lock in my loop on the deadlock branch seems to be the solution |
Added connection Handle check before gap event is handled in characteristic to fix the deadlock issue in #151
I am using the ble to transmit constant sensor data, after running for a while, there are some Error and then code seemingly gets stuck in in notify loop.
All callbacks are working as expected but the loop in which i am transmitting data is stuck.
In the below logs I manually disconnect after a while of it being stuck in the loop
The text was updated successfully, but these errors were encountered: