GithubHelp home page GithubHelp logo

Comments (6)

bensadiku avatar bensadiku commented on May 29, 2024

cc @davidgyoung if you have any recommendations, this seems to be a big issue.;

from android-beacon-library.

davidgyoung avatar davidgyoung commented on May 29, 2024

I really do not think that I have seen this -- crashes happen pretty normally during app development, and I know I do not need to reboot my phones or power cycle bluetooth regularly during beacon scanning app development. Are you sure that the value of x in bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=x always increments after a crash no matter how long you wait? Is it possible it will go down in time if you wait, say 10 minutes between force crashes?

If the number does not go down, then I suspect there may be something different about your devices or the apps running on them that makes the OS gatt clients never get recycled. The core problem you are seeing should in theory exist even for apps not using this library, if they start an Android's Bluetooth LE scan using Android's built-in SDKs, then crash.

It may be possible to prevent a GATT client leak by using an uncaught exception handler and making it stop any scan started by the app.

But before even considering the above I think it is important to confirm there is no existing recovery mechanism.

from android-beacon-library.

bensadiku avatar bensadiku commented on May 29, 2024

This is the main problem here, there does not seem to be a recovery mechanism OS side because we've had devices reach max GATT clients while running the app that has beacon lib.
Ran some more tests with the sample app and the time does not play a role. FYI, testing with the Kotlin sample app i linked.
In theory this seems like a GATT issue but i was unable to reproduce with a plain GATT server connection. The behavior with this simple server is that Gatt clients increase by 1 on app install and decrease by 1 when app crashes.

When using a plain GATT server connection, OS seems to do some clean-up in background when app crashes:

2023-10-03 11:19:28.180 30682-30733/com.android.bluetooth E/bt_stack: [ERROR:gatt_api.cc(313)] Active Service Found: 00001805-0000-1000-8000-00805f9b34fb
2023-10-03 11:19:28.181 30682-30733/com.android.bluetooth I/bt_stack: [INFO:gatt_api.cc(380)] GATTS_StopService: 0x28

It is not doing so using the Beacon Kotlin sample app, though. I suspect it's something to do with the way this library is utilizing GATT..

from android-beacon-library.

davidgyoung avatar davidgyoung commented on May 29, 2024

Can you share the code used to start the scan in this test?

unable to reproduce with a plain GATT server connection. The behavior with this simple server is that Gatt clients increase by 1 on app install and decrease by 1 when app crashes.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on May 29, 2024

@bensadiku, I cannot reproduce this issue with the official reference app using a Google Pixel 6a / Android 13.

I created a Git branch with the same code to crash the app here: https://github.com/davidgyoung/android-beacon-library-reference-kotlin/tree/test-gatt-client-leaks

I then grep logcat as you describe, and repeatedly launch the app after it crashes 10 seconds later. I also have a beacon transmitter going and I confirm it detects before it crashes. Note that in the logs below I do not see new gatt_if creations.

 % adb logcat | grep gatt_if

10-05 10:40:38.920  2588  3372 I bt_stack: [INFO:gatt_api.cc(1355)] GATT_CancelConnect: gatt_if:7, address: 00:00:00:00:00:00, direct:0
10-05 10:40:38.921  2588  3372 I bt_stack: [INFO:gatt_api.cc(1147)] GATT_Deregister gatt_if=7

I suggest you try with this same code to see if you see the same thing. There may also be differences with Android version and OEM customizations.

from android-beacon-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.