Closed wcoder closed 6 months ago
thanks for filing issue.
can you fix it and open PR? thanks.
fixed in 1.32.6
I'm using flutter_blue_plus: ^1.32.7 on android and got same bug!!
D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 1 I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): could not find callback wrapper I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): Start Scan with callback D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 1 I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): could not find callback wrapper I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): Start Scan with callback D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 1 I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): could not find callback wrapper I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): Start Scan with callback D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0 I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): could not find callback wrapper I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): Start Scan with callback D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 0 I/ViewRootImpl@efd322cMainActivity: ViewPostIme pointer 1 I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): could not find callback wrapper I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON I/BluetoothAdapter(12262): STATE_ON D/BluetoothLeScanner(12262): Start Scan with callback D/BluetoothLeScanner(12262): onScannerRegistered() - status=6 scannerId=-1 mScannerId=0
Requirements
Have you checked this problem on the example app?
Yes
FlutterBluePlus Version
1.32.5
Flutter Version
3.19.6
What OS?
Android
OS Version
Android 11
Bluetooth Module
Not related yet
What is your problem?
startScan and stopScan are not synced between Dart and native layers. Android StopScan doesn't have a proper mechanism to track its scanning state.
As a result, scanResult is broken and returns empty list.
Sometimes, new scanning can't be started because it returns the error
SCAN_FAILED_ALREADY_STARTED
and then can't be stopped for restart scanning (fixes by restart app).StopScan on Android looks like it is not synchronous under the hood and needs some time for all the next startScan, but FBP doesn't handle this.
See a demo of this issue on the example app:
https://github.com/boskokg/flutter_blue_plus/assets/766193/d7b8132c-37fe-445e-a416-c1b97e7f718d
Logs