Open PavlosTze opened 1 month ago
Can you provide a breakdown of the failure rate per Android version? I'm wondering if this is the result of behavior changes in newer versions of Android?
Can you provide a breakdown of the failure rate per Android version? I'm wondering if this is the result of behavior changes in newer versions of Android?
Sure, here it is:
Thanks for the info. We're seeing this in our apps as well. I'll try to allocate some time soon to investigate.
@PavlosTze I'm currently investigating this issue. Do you happen to know what version of Kable you first saw this issue in?
@twyatt It started with 0.31.1.
Thanks, I believe I've tracked down the cause:
I believe it was introduced in #648, when a bug was fixed (whereas Kable would silently ignore failures to write to a characteristic). In #648, that behavior was fixed (to now throw an exception if the write failed).
Unfortunately, some might be relying on the bug (that was fixed) where it didn't propagate a failure when the write fails.
I'm trying to determine what the best API/behavior might be for this situation. I'll follow up soon.
Sure, I just want to mention that this is a non-crash failure. Which means that if it failed before in the same way, the only thing happening now is that it's been showing up in the logs, not that big of a deal.
I'm wondering if we can solve it in the background based on what it says here?
/**
* Error code indicating that the profile service is not bound. You can bind a profile service
* by calling {@link BluetoothAdapter#getProfileProxy}.
*/
public static final int ERROR_PROFILE_SERVICE_NOT_BOUND = 9;
Is it possible to bind a profile service if we get across this failure?
I suspect that the code comment you referenced is misleading in this case.
I believe the failure happens when a write occurs after a connection is lost / disposed; because the connection was disposed, the underlying Android GATT object no longer has a "profile service" (essentially a reference to the underlying Android BLE system) and so propagates that failure. I believe it is unrelated to getProfileProxy
; perhaps Android just re-used this failure case for multiple failure conditions. 🤷
I think in most cases it is safe to ignore the failure (in the cases where it happens because the connection was recently disposed). The case where it might be problematic is where BluetoothAdapter#getProfileProxy
is being utilized (I suspect this isn't common though), in which case the failure could indicate other issues (aside from just a connection being lost).
The reason it is important for Kable to propagate the failure though, is the consumer should be aware that the requested write
operation did not complete as requested.
Hello,
I have the following code:
And for some weeks already this code is producing a lot of
ProfileServiceNotBound
types of exception, the log is the following:As you can see from these 3 screenshots issues started in early June:
![εικόνα](https://github.com/user-attachments/assets/c6bcf48c-a861-4994-987a-91d271cbae39)
In case that helps, our app producing those is Open Source.
Based on what I read in your writeResultFrom and in the Android-related code:
Any chance you can catch this error without letting it fail? What is this related to? As there aren't any logs producing it in the past and we've been using Kable for around 2 years already.