PhilipsHue / flutter_reactive_ble

Flutter library that handles BLE operations for multiple devices.
https://developers.meethue.com/
Other
661 stars 321 forks source link

Crash on permission change #828

Closed pmagnuson closed 3 months ago

pmagnuson commented 7 months ago

Describe the bug This may be in the category of "don't do that". When the app is running on IOS, if the user goes to Settings and changes the Bluetooth permissions, the app crashes.

To Reproduce Steps to reproduce the behavior:

  1. Run the example app in the repository on IOS
  2. Navigate to the Settings App and Settings for the example App
  3. Change Bluetooth permission to Off (if on)
  4. Example app crashes

Expected behavior There should be some way to detect that the permissions have changed and gracefully turn off the Bluetooth stack. When permissions are re-enabled, then the Bluetooth stack can be restarted.

Smartphone / tablet

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.85.0)
[✓] Connected device (4 available)
[✓] Network resources

terminal log

Launching lib/main.dart on iPhone12 in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 2HHUYC857H
Xcode build done.                                            8.0s
(lldb) 2024-01-05 10:16:38.295071-0700 Runner[1195:934199] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
[VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
Warning: Unable to create restoration in progress marker file
fopen failed for data file: errno = 2 (No such file or directory)
Errors found! Invalidating cache...
Connecting to VM Service at ws://127.0.0.1:64921/60ojNuWG3YE=/ws
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
    frame #0: 0x00000002109e4da8 libsystem_kernel.dylib`mach_msg2_trap + 8
libsystem_kernel.dylib`mach_msg2_trap:
->  0x2109e4da8 <+8>: ret
libsystem_kernel.dylib`macx_swapon:
    0x2109e4dac <+0>: mov    x16, #-0x30
    0x2109e4db0 <+4>: svc    #0x80
    0x2109e4db4 <+8>: ret
Target 0: (Runner) stopped.
Lost connection to device.

Exited.

log when permissions are OFF and changed to ON in Settings

Launching lib/main.dart on iPhone12 in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 2HHUYC857H
Xcode build done.                                           28.3s
(lldb) 2024-01-05 10:14:36.697132-0700 Runner[1189:932720] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
[VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
Warning: Unable to create restoration in progress marker file
fopen failed for data file: errno = 2 (No such file or directory)
Errors found! Invalidating cache...
Connecting to VM Service at ws://127.0.0.1:64771/hGMoqKsEu4I=/ws
[VERBOSE-2:FlutterDartVMServicePublisher.mm(147)] Could not register as server for FlutterDartVMServicePublisher, permission denied. Check your 'Local Network' permissions for this app in the Privacy section of the system Settings.
[VERBOSE-2:FlutterDartVMServicePublisher.mm(147)] Could not register as server for FlutterDartVMServicePublisher, permission denied. Check your 'Local Network' permissions for this app in the Privacy section of the system Settings.
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
    frame #0: 0x00000002109e4da8 libsystem_kernel.dylib`mach_msg2_trap + 8
libsystem_kernel.dylib`mach_msg2_trap:
->  0x2109e4da8 <+8>: ret
libsystem_kernel.dylib`macx_swapon:
    0x2109e4dac <+0>: mov    x16, #-0x30
    0x2109e4db0 <+4>: svc    #0x80
    0x2109e4db4 <+8>: ret
Target 0: (Runner) stopped.
Lost connection to device.

Exited.
soleilpqd commented 3 months ago

I don't think this a bug. This is Apple policy. App didn't crash. When user changes settings, iOS just kills the app. You can try other permissions like Location, Camera, Contacts ... of other apps. If you look into iOS SDK frameworks that require permissions, there are only APIs to ask user's permission, no APIs to watch permissions changing.