flutter_reactive_ble icon indicating copy to clipboard operation
flutter_reactive_ble copied to clipboard

scanForDevices in statusStream causes an error

Open panhboth111 opened this issue 2 years ago • 2 comments

Describe the bug I tried to nest the scanForDevices method inside the statusStream in order to only scan for the devices when the ble status is ready

ble.statusStream.listen((BleStatus status) {
      if (status == BleStatus.ready) {
        ble.scanForDevices(withServices: []).listen((event) {});
      }
 });

By doing this, I received the following error:

reactive_ble_mobile/PluginController.swift:158: Assertion failed
reactive_ble_mobile/PluginController.swift:158: Assertion failed
* thread #1, queue = 'com.apple.main-thread', stop reason = Assertion failed
    frame #0: 0x00000001cbe390f8 libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`:
->  0x1cbe390f8 <+0>: ret    
libswiftCore.dylib`:
    0x1cbe390fc <+0>: b      0x1cbe390f8               ; _swift_runtime_on_report
libswiftCore.dylib`:
    0x1cbe39100 <+0>: adrp   x8, 365868
    0x1cbe39104 <+4>: ldrb   w0, [x8, #0xabc]
Target 0: (Runner) stopped.

panhboth111 avatar Mar 28 '23 10:03 panhboth111

I found the same crash just by starting two scans at the same time. The failing assertion is assert(!central.isScanning).

maBarabas avatar Apr 03 '23 14:04 maBarabas

This is the same issue described in https://github.com/PhilipsHue/flutter_reactive_ble/issues/221 and https://github.com/PhilipsHue/flutter_reactive_ble/issues/283.

maBarabas avatar Apr 03 '23 14:04 maBarabas