Question : Is Starting Bluetooth Scan Rate limited?
Prerequisites
- [x] I checked the documentation and FAQ without finding a solution
- [x] I checked to make sure that this issue has not already been filed
- [x] I'm sure that question is related to the library itself and not Bluetooth Low Energy or Classic in general. If that so, please post your question on StackOverflow.
- [x] I'm running the latest version
Question
When I stress test my bluetooth pairing page by leaving and returning to the page continuously, eventually the startDeviceScan method fails with the error : Cannot Start Scanning Operation.
Initially I thought the error was related to a race condition : starting the device scan starting before the previous stopDeviceScan method had been called and the promise had been resolved. However, I have since moved the bluetooth manager into a class in a provider which verifies that the previous scan has stopped before starting the next one. The issue persists.
My current guess for the cause is that the bluetooth scan is being rate limited. I am testing on a OnePlus 10T 5G. There are two behaviours that suggest this:
- When I leave and return to the page, the error triggers almost always on the 5th or 6th page visit.
- When this issue triggers the error remains for about 15-30 seconds i.e. if I navigate back to the page immediately after seeing this error, the error will remain.
Questions:
- Do operating systems rate limit the ability to start device scans?
- What other behaviours can trigger Cannot Start Scanning Operation error?
Question related code
Yes, but on Android only AFAIK. Please refer to Bluetooth scan limitations on https://proandroiddev.com/android-restrictions-you-may-encounter-during-development-process-c39ede513813.