52

My iOS app accesses the user's Photos with ALAssetsLibrary. When I change the privacy settings for the app (Settings → Privacy → Photos), the app gets killed by system (SIGKILL). Is this a bug?

mfaani
  • 33,269
  • 19
  • 164
  • 293
qiz
  • 869
  • 1
  • 9
  • 14
  • Uh-oh... I have test with Apple's [MyImagePicker](http://developer.apple.com/library/ios/#samplecode/MyImagePicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010135) and get the same crash. – qiz Sep 29 '12 at 11:59
  • is it crashing or just restarting? I have also seen this behavior but looks to be our of our control. – brightintro Oct 01 '12 at 17:53
  • Good report, good testing. I've elaborated a little in my answer regarding UIImagePickerController; it's clearly the same bug. Thanks for posting about this. – matt Dec 01 '12 at 17:51
  • 1
    Seeing the same thing here with the Calendar privacy settings. – Simon May 09 '13 at 16:26
  • 1
    As of iOS7, at least, when running the app on the device proper (NOT in Xcode device debugging or simulator), the app will be automatically restarted. If you handle the restart fine, the user will never know the app "crashed". – leanne May 04 '14 at 22:18
  • 1
    Greetings from the future! Still happening in iOS 9. I've added a little "the app may need to restart" warning before directing the user to settings. – sudo make install Feb 16 '16 at 00:05
  • Still happening in iOS10 but seems to be expected behaviour. When app permissions are changed, iOS restarts the app in background. – ElectroBuddha Mar 25 '17 at 10:03
  • Still happens on IOS11 (at least in simulator). App exits when privacy settings are toggled. Judging by the info here It seems this is intended behaviour and won't change anytime soon – Yarek T Oct 10 '18 at 08:14
  • Allow me to add that it still happening on iOS 12 :'( – Elsammak Feb 07 '19 at 08:52
  • Happens for bluetooth as well. Suprisingly doesn't happen for access to location – mfaani Oct 14 '21 at 22:04
  • I'm just going to jump on the bandwagon and add it also still happens in iOS 14. – Nebula Jun 20 '23 at 13:40

7 Answers7

40

I think it is a bug or at least poorly documented and unexpected behavior. But it does not crash it is just forced to restart. You will get a SIGKILL message but no Crash log.

If you are a registered apple developer you can check their forums for discussions about this issue

I don't know of any way how to prevent this behavior but feel free to file a bug report with apple. It is rumored they use bug duplicates as a way of measuring the bug severity. Maybe you can store your app state in order to restore it when it restarts.

clauswey
  • 1,706
  • 1
  • 12
  • 15
  • 5
    I have become more and more gloomy about this situation. I have not yet received any reply from Apple but I'm pretty sure that Apple thinks this is NOT a bug. I think their feeling is: the privacy situation has changed, so your app probably needs to begin all over again. The trouble is that they have decided badly. After all, they don't crash your iCloud app when the user switches on iCloud, the don't crash your WiFi app when the user switches on WiFi, so why crash your photo app when the user switches on photos? They should just send me a notification of some sort and let me handle it. – matt Dec 06 '12 at 15:02
  • 1
    it makes more sense if the permission is taken away from iOS settings for a app ( assuming app running in bg already has access to , say , photos) iOS is simply killing the app that may already have access to data. – dotnetcoder Apr 30 '13 at 02:56
  • Thanks, Is there any apple official documentation link? – Gopik Dec 22 '17 at 11:20
  • This also happens for Camera and Microphone settings. I opened a feedback report asking to at least update documentation with reasoning about it. FB9585153 – henrique Sep 01 '21 at 11:27
  • Documented in WWDC 2012 session 710 Video: https://download.developer.apple.com/videos/wwdc_2012__hd/session_710__privacy_support_in_ios_and_os_x.mov The slides of this presentation are here https://docs.huihoo.com/apple/wwdc/2012/session_710__privacy_support_in_ios_and_os_x.pdf – Pouria Almassi Oct 18 '21 at 04:55
11

This happens as well when using UIImagePickerController. The sequence goes like this:

  1. You show the UIImagePickerController. The first time, the little alert asks the user for permission to use the photo library. Let's say the user says no.

  2. All the user can do with the picker controller at this point is cancel, so let's presume that's what happens.

  3. On some later occasion, you show the UIImagePickerController. It now contains a noncustomizable message saying that there is no access to the photo library, but that the user can enable access in Settings.

  4. The user switches to Settings and enables access to the photo library for this app.

  5. The app crashes in the background. It doesn't matter whether the user has cancelled the picker or left it showing.

I've filed a bug on this and I suggest you do the same, for your situation. Apple introduced a new privacy system in iOS 6 and clearly the kinks have not been worked out.

matt
  • 515,959
  • 87
  • 875
  • 1,141
9

Search for the word "kill" within this PDF: http://adcdownload.apple.com/wwdc_2012/wwdc_2012_session_pdfs/session_710__privacy_support_in_ios_and_os_x.pdf

iOS kills apps when certain permissions change.

This info is hard to track down. It's not in any of the 'guides' (preferences programming guide, for example).

William Power
  • 686
  • 7
  • 12
3

When you test your app using simulator.Changing the permissions of the app gives you a breakpoint.You can type "c" in the console to make the app continue to run and goes back to the original state.But in your real device,that is not the story.It just reboot the app.

tounaobun
  • 14,570
  • 9
  • 53
  • 75
2

Some times SIGKILL error work as a interruption error, it gives signal to iOS that you have to restart your app and on the same time we are managing app tasks and on that instance the way of sending interruption message is not handled by app.

In my case..... I don't allow the photos and camera access in the app and whenever I am allowing to access these features, I minimize the app and enables these settings. As I enabled these, iOS get an interruption and app receives this but can't handle and result our app terminates or closed.

Gourav Joshi
  • 2,419
  • 2
  • 27
  • 45
0

Are you accessing the Asset Library using the assetForURL:resultBlock:failureBlock:?

If you are then, most likely you are not handling the failure block of the ALAssetLibrary.

You could do something like

ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Access to Photo Library is Denied "
                                                            message:@"Please allow <YOUR APP NAME> to access your Photo library from Privacy Settings"
                                                           delegate:nil
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
            [alert show];
            [alert release];
}

So when your app doesn't have access to the photo library it will ask the user to do it.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Ali
  • 4,205
  • 4
  • 25
  • 40
  • Congratulation! and thank you :-) But this is not the answer I wanted. – qiz Oct 16 '12 at 02:40
  • A permission denial has to be handled anyway. The problem here is that AFTER the user gets the denial message, they leave the app open and go to settings to turn on access. When they RETURN to the app, then, the app crashes! Not a good user experience... – leanne May 04 '14 at 21:24
  • 1
    Update to my own comment: actually, in the simulator, the app "crashes" with the SIGKILL. On the device, iOS immediately restarts the app, so the user has no idea the app abruptly ended - as long as the restart is handled correctly within the app. – leanne May 20 '14 at 20:07
-1

I am not sure how much this would help, but I am experiencing a similar issue where the app crashes when I turn off/on Bluetooth via the privacy settings (Settings → Privacy → Bluetooth), but it doesn't crash when I change the Bluetooth settings directly (Settings → Bluetooth), so I think two things could be said here.

  1. This isn't a bug specific to the app you are using, and is a more generic issue.
  2. Going through the privacy settings may be where the cause is.

I am also looking for a solution on how to prevent it though, so just sharing an insight on where the cause may be for now, but hopefully it can be solved! Thanks!

Seiu
  • 1
  • 3
  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/34356787) – jstarek May 15 '23 at 10:29