qaul / qaul.net

Internet Independent Wireless Mesh Communication App
https://qaul.net
GNU Affero General Public License v3.0
496 stars 63 forks source link

2.0.0-beta.16 and 2.0.0-beta.17 crashes on Android when initializing Bluetooth #589

Closed link2xt closed 3 months ago

link2xt commented 10 months ago

I installed https://github.com/qaul/qaul.net/releases/download/v2.0.0-beta.16/qaul-2.0.0-beta.16.apk from the website.

The application keeps crashing before showing any UI.

adb logcat output:

08-16 16:32:10.452 25363 28847 I libqaul::connections:..: BLE module start result received
08-16 16:32:10.452 25363 28847 I libqaul::connections:..: BLE Module successfully started
08-16 16:32:10.456  3489 13364 E Parcel  : Attempt to read from protected data in Parcel 0x7a6906ca68
08-16 16:32:10.459 25363 28874 E AndroidRuntime: FATAL EXCEPTION: pool-5-thread-1
08-16 16:32:10.459 25363 28874 E AndroidRuntime: Process: net.qaul.qaul_app, PID: 25363
08-16 16:32:10.459 25363 28874 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder android.os.IInterface.asBinder()' on a null object reference
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.os.Parcel.createException(Parcel.java:2077)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:2039)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1987)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.bluetooth.IBluetoothGatt$Stub$Proxy.startAdvertisingSet(IBluetoothGatt.java:1526)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertisingSet(BluetoothLeAdvertiser.java:434)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertisingSet(BluetoothLeAdvertiser.java:306)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertising(BluetoothLeAdvertiser.java:158)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertising(BluetoothLeAdvertiser.java:93)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at net.qaul.ble.service.BleService.startAdvertise$lambda-1(BleService.kt:47)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at net.qaul.ble.service.BleService.e(Unknown Source:0)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at b7.b.run(Unknown Source:4)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
08-16 16:32:10.459 25363 28874 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:919)
08-16 16:32:10.463  1466 28877 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
08-16 16:32:10.463  1466 17560 W ActivityTaskManager:   Force finishing activity net.qaul.qaul_app/.MainActivity
08-16 16:32:10.467  1466 28877 W DropBoxManagerService: Dropping: data_app_crash (1377 > 0 bytes)
MathJud commented 9 months ago

Could you provide more information?

MathJud commented 9 months ago

Have you tried install the app via Google Play store?

link2xt commented 9 months ago

It is Android 10 on Xiaomi Redmi Note 3 (codename kenzo). I only tried the APK from the website so far, could try to download Google Play version via Aurora Store, but don't have actual Google Play account.

link2xt commented 9 months ago

Maybe you need to reduce targetSdk? I don't see it set anywhere in https://github.com/qaul/qaul.net/blob/5385e61de5a63201e11e4be34ba3cd28be1c6ea9/qaul_ui/android/build.gradle

link2xt commented 9 months ago

Aurora Store currently does not work for me, so I cannot test the version from Google Play.

eleius commented 6 months ago

Aurora Store currently does not work for me, so I cannot test the version from Google Play.

You can also get it from Apkpure: https://apkpure.com/qaul-%D9%82%D9%88%D9%84/net.qaul.qaul_app

link2xt commented 3 months ago

I have downloaded 2.0.0-beta.17 from https://github.com/qaul/qaul.net/releases/tag/v2.0.0-beta.17 and installed it with adb install qaul-2.0.0-beta.17.apk over USB.

If I start the app without enabling bluetooth and do not enable it when it says "qaul wants to turn on Bluetooth" (click "Deny"), it works. But if I click "Allow" and bluetooth gets enabled, after "Turning on Bluetooth..." popup it crashes.

Crash log from adb logcat:

03-25 02:56:56.835 29022 31329 I libqaul::connections:..: BLE module start result received
03-25 02:56:56.835 29022 31329 I libqaul::connections:..: BLE Module successfully started
03-25 02:56:56.841 30700 30716 E Parcel  : Attempt to read from protected data in Parcel 0x6fd0427a68
03-25 02:56:56.843 29022 31351 E AndroidRuntime: FATAL EXCEPTION: pool-5-thread-1
03-25 02:56:56.843 29022 31351 E AndroidRuntime: Process: net.qaul.qaul_app, PID: 29022
03-25 02:56:56.843 29022 31351 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder android.os.IInterface.asBinder()' on a null object reference
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.os.Parcel.createException(Parcel.java:2077)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:2039)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1987)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.bluetooth.IBluetoothGatt$Stub$Proxy.startAdvertisingSet(IBluetoothGatt.java:1526)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertisingSet(BluetoothLeAdvertiser.java:434)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertisingSet(BluetoothLeAdvertiser.java:306)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertising(BluetoothLeAdvertiser.java:158)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at android.bluetooth.le.BluetoothLeAdvertiser.startAdvertising(BluetoothLeAdvertiser.java:93)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at net.qaul.ble.service.BleService.startAdvertise$lambda-1(BleService.kt:47)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at net.qaul.ble.service.BleService.e(Unknown Source:0)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at c7.b.run(Unknown Source:4)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-25 02:56:56.843 29022 31351 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:919)
link2xt commented 3 months ago

I have built the app myself and got the same crash. Made workaround #616.

link2xt commented 3 months ago

Some other interesting output from the log:

03-25 02:54:06.740  1549  1823 D BluetoothManagerService: MESSAGE_REGISTER_ADAPTER
03-25 02:54:06.753  1010 30589 I libqaul::connections:..: ========================= 
03-25 02:54:06.753  1010 30589 I libqaul::connections:..: BLE info received
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: -------------------------
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: This Devices ID
...
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: -------------------------
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: BLE Supported: true
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: ID:  
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: Name: f3flA
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: Bluetooth Enabled: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: Advertisement Extended: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: 2M supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE coded supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE audio supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE periodic advertisement supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE multiple advertisement supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: offload filter supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: offload scan batching supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: =========================
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: BLE send start request 

Could be this is the reason startAdvertising does not work?

03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE periodic advertisement supported: false
03-25 02:54:06.754  1010 30589 I libqaul::connections:..: LE multiple advertisement supported: false

EDIT: seems we are not using PeriodicAdvertisingParameters, so should not be the issue.

Maybe we should not try to setup bluetooth LE advertising if it is not supported?

link2xt commented 3 months ago

Documentation for reference: https://source.android.com/docs/core/connect/bluetooth/ble_advertising Maybe use startAdvertisingSet directly as example shows, instead of calling startAdvertising which then fails?

Another example uses startAdvertising: https://github.com/android/connectivity-samples/blob/777517eb2898cd48e139446246808a2106d343cc/BluetoothAdvertisementsKotlin/app/src/main/java/com/example/bluetoothadvertisements/service/AdvertiserService.kt They handle it as error if multiple advertisement is not supported: https://github.com/android/connectivity-samples/blob/777517eb2898cd48e139446246808a2106d343cc/BluetoothAdvertisementsKotlin/app/src/main/java/com/example/bluetoothadvertisements/MainActivity.kt#L59-L60

link2xt commented 3 months ago

I also found someone reporting similar stacktrace on different phones: https://gitlab.com/LineageOS/issues/android/-/issues/2205 There an app calls startAdvertisingSet directly, so using it without startAdvertising likely does not help.

MathJud commented 3 months ago

qaul uses normal BLE advertising, which BLE standard and every device must support it. IMHO the failure of being able to advertise on BLE is a vendor/manufacturer bug, which cannot be fixed on application level, only mitigated as you did in #616 (thanks for that!).

link2xt commented 3 months ago

It should probably be more visible in the UI that BLE initialization failed, but closing this once there is a version that does not crash is also fine.

MathJud commented 3 months ago

fixed by #616

Still a TODO is a user information about the state and the possibilities of the BLE interface.

link2xt commented 2 months ago

By the way Briar works over bluetooth on the same phone. I have tested with Wi-Fi disabled, no internet connectivity possible, and in Briar itself I also disabled everything but bluetooth. So maybe reopen this issue and try to copy what Briar does?

Briar requires scanning the QR code so maybe it does not do "advertising". But better look into the code.