flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

App crashes when switching on/off bluetooth permissions in iOS settings

Open Annelein opened this issue 4 years ago • 7 comments

I am building an app using Flutterblue and for that I need bluetooth to be switched on and bluetooth permissions. I am using permission handler to check it like this:

bluetoothPermission = await Permission.bluetooth.isGranted;

I've created a button which is green when bluetooth permission is granted and blue when not, I've created my own stream to listen to bluetoothPermission = await Permission.bluetooth.isGranted; But when I open my app settings on iOS and either switch on or off the bluetooth permission, my app crashes and I receive this SIGKILL:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL frame #0: 0x00000001dd2fb644 libsystem_kernel.dylibmach_msg_trap + 8 libsystem_kernel.dylibmach_msg_trap: -> 0x1dd2fb644 <+8>: ret libsystem_kernel.dylibmach_msg_overwrite_trap: 0x1dd2fb648 <+0>: mov x16, #-0x20 0x1dd2fb64c <+4>: svc #0x80 0x1dd2fb650 <+8>: ret
Target 0: (Runner) stopped. Lost connection to device.`

I do the same exact same with location switched on and location permission but that goes fine.

Can anyone help me out with this problem? I have no clue where to look or what might cause this.

Annelein avatar Mar 30 '21 08:03 Annelein

I can see the exact same error with the camera permission. And I can confirm that it works with locations (and for notifications)

brosnic avatar Apr 01 '21 13:04 brosnic

@Annelein it is normal behavior on iOS, nothing to do with the plugin.

petro-i avatar May 24 '21 06:05 petro-i

@petro-i even in android

Lawati97 avatar Aug 17 '21 07:08 Lawati97

even if I restart the application the moment I go to the page where it checks for that permission in crashes

Lawati97 avatar Aug 17 '21 07:08 Lawati97

Any updates/confirmations? I am facing this issue on both Android (location permission) and iOS (bluetooth permission). In my case, the crashes happen when I turn off the permissions in Settings on Android and toggle either on or off in Settings on iOS.

The error message I have on iOS is same with @Annelein.

For Android, I got this: D/Surface (31553): Surface::disconnect(this=0x72ee5ea000,api=-1) D/Surface (31553): Surface::disconnect(this=0x729d0b1000,api=1) I/GED (31553): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 29, oppidx_max 29, oppidx_min 0 Lost connection to device. Exited (sigterm)

jasonhtpham avatar Oct 19 '21 01:10 jasonhtpham

This issue is happening to me as well in iOS - App detects the user has permanently denied bluetooth access, prompts them to go to the settings page. On the settings page, if they switch Bluetooth to the ON position the app instantly crashes:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL frame #0: 0x00000002100d74e0 libsystem_kernel.dylibmach_msg_trap + 8 libsystem_kernel.dylibmach_msg_trap: -> 0x2100d74e0 <+8>: ret libsystem_kernel.dylibmach_msg_overwrite_trap: 0x2100d74e4 <+0>: mov x16, #-0x20 0x2100d74e8 <+4>: svc #0x80 0x2100d74ec <+8>: ret Target 0: (Runner) stopped. Lost connection to device. ` Anyone have a solution for this?

tas246 avatar Apr 23 '22 23:04 tas246

This isn't an issue pertaining to the package, as explained in this comment from similar issue #293

This is not a problem of this lib. If you try to run you app without doing anything and open iOS settings and try to change app permission the app exit automatically.

You can test this behavior on any existing apps.

ie. Instagram.

  1. If you go deep into a navigation flow
  2. have some state in a page (scroll, content)
  3. close the app (not kill)
  4. go to OS settings
  5. toggle Instagram permissions
  6. go back to Instagram app
  7. you'll notice that Instagram is rebooted again from scratch (not saving any of your previous states)

Since the app is essentially "rebooted", Flutter assumes you Lost connection to deviceand throws this error and In order to get around this to test your app. You would need to launch in release mode

in the terminal flutter run --release

luggy-wuggy avatar Apr 29 '22 19:04 luggy-wuggy

@luggy-wuggy thanks, works exactly as you said

konradjurkowski avatar Dec 01 '22 10:12 konradjurkowski

@luggy-wuggy Thank you~~~~, I thought there was something wrong with my program

bakboem avatar Feb 01 '23 02:02 bakboem

Closing this issue, as the problem has been identified: the behavior is driven by the OS, not the plugin. See the https://github.com/Baseflow/flutter-permission-handler/issues/509#issuecomment-1113636977 for an explanation. Thanks @luggy-wuggy!

JeroenWeener avatar Jul 03 '23 14:07 JeroenWeener