vokal / VOKMultiImagePicker-iOS

A multiple image picker using PhotoKit.
MIT License
12 stars 7 forks source link

Crash when attempting to access photos from a user who has declined photo permission #27

Open designatednerd opened 8 years ago

designatednerd commented 8 years ago

App name obscured, but we received a complaint from a user that they were getting crashes when trying to access photos. Then we got this stack trace:

Incident Identifier: 3FB840D8-0B65-477B-9680-7D8BBCEC22C2
CrashReporter Key:   8F13973C-83A6-40D1-8989-9ACE68747C75
Hardware Model:      iPhone5,3
Process:         [App] [8957]
Path:            /var/mobile/Containers/Bundle/Application/17323A81-DEF9-4D09-834B-9E1B33387A5F/[App].app/[App]
Identifier:      com.[App].[App]
Version:         1.1.1 (2549)
Code Type:       ARM
Parent Process:  ??? [1]

Date/Time:       2016-01-29T15:51:02Z
Launch Time:     2016-01-29T15:46:02Z
OS Version:      iPhone OS 9.2.1 (13D15)
Report Version:  104

Exception Type:  SIGABRT
Exception Codes: #0 at 0x237c9c84
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'This application is not allowed to access Photo data.'

Last Exception Backtrace:
0   CoreFoundation                       0x23b322eb __exceptionPreprocess + 127
1   libobjc.A.dylib                      0x232fedff objc_exception_throw + 36
2   PhotoLibraryServices                 0x2b60bca9 -[PLPhotoLibrary initWithTransientContext:name:] + 1474
3   Photos                               0x2bfeddeb __30-[PHPhotoLibrary photoLibrary]_block_invoke + 60
4   libdispatch.dylib                    0x236cfdc3 _dispatch_client_callout + 20
5   libdispatch.dylib                    0x236d09b3 dispatch_once_f + 60
6   Photos                               0x2bfedda7 -[PHPhotoLibrary photoLibrary] + 128
7   Photos                               0x2bfc7d7b -[PHCoreImageManager _cancelAndFlushPreheatItemsForAssets:CPLPrefetching:domain:operation:passingTestHandler:didCancelHandler:] + 128
8   Photos                               0x2bfe700f -[PHCachingImageManager stopCachingImagesForAllAssets] + 124
9   VOKMultiImagePicker_iOS              0x00c65b05 -[VOKAssetsDataSource resetCachedAssets] (VOKAssetsDataSource.m:59)
10  VOKMultiImagePicker_iOS              0x00c6599d -[VOKAssetsDataSource initWithCollectionView:fetchResult:] (VOKAssetsDataSource.m:40)
11  VOKMultiImagePicker_iOS              0x00c671bb -[VOKAssetsViewController viewDidLoad] (VOKAssetsViewController.m:61)
12  UIKit                                0x27cc9d79 -[UIViewController loadViewIfRequired] + 1026
13  UIKit                                0x27d87643 -[UINavigationController _layoutViewController:] + 36
14  UIKit                                0x27d87539 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 378
15  UIKit                                0x27d868e5 -[UINavigationController _startTransition:fromViewController:toViewController:] + 94
16  UIKit                                0x27d8651b -[UINavigationController _startDeferredTransitionIfNeeded:] + 832
17  UIKit                                0x27d8616d -[UINavigationController __viewWillLayoutSubviews] + 50
18  UIKit                                0x27d860e7 -[UILayoutContainerView layoutSubviews] + 212
19  UIKit                                0x27cc5a83 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 712
20  QuartzCore                           0x25da1ad5 -[CALayer layoutSublayers] + 126
21  QuartzCore                           0x25d9d1d1 CA::Layer::layout_if_needed(CA::Transaction*) + 350
22  QuartzCore                           0x25d9d061 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 14
23  QuartzCore                           0x25d9c581 CA::Context::commit_transaction(CA::Transaction*) + 366
24  QuartzCore                           0x25d9c233 CA::Transaction::commit() + 612
25  UIKit                                0x27cbcc09 _afterCACommitHandler + 174
26  CoreFoundation                       0x23af4b21 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
27  CoreFoundation                       0x23af2e17 __CFRunLoopDoObservers + 280
28  CoreFoundation                       0x23af3255 __CFRunLoopRun + 970
29  CoreFoundation                       0x23a45bb9 CFRunLoopRunSpecific + 514
30  CoreFoundation                       0x23a459ad CFRunLoopRunInMode + 106
31  GraphicsServices                     0x24cbfaf9 GSEventRunModal + 158
32  UIKit                                0x27d31fb5 UIApplicationMain + 142
33  [app]                             0x0021144c main (main.swift:16)
34  ???                                  0x236f8873 0x0 + 0

In the absence of Apple throwing up a sane warning instead of crashing when the user has denied permission to access photos, we should do so.

timroesner commented 7 years ago

Did you ever figure this out? Having the same problem. I have an image picker built on top of the photos framework and would like to do the check inside the mage picker instead of before calling on it, as we have a lot of places where we access this controller.