on iOS 15.2, when I call [PHPhotoLibrary registerChangeObserver:],app will stuck
ios 15.2 beta app stuck
Hi, I believe we'll need more info to help figure out what's going on here. Are you able to repro this with a small test app? If so, filing a Feedback report with it would be the most effective way at reporting the bug to Apple.
call stack
- libsystem_kernel.dylib 8 _semaphore_timedwait_trap (in libsystem_kernel.dylib)
- libdispatch.dylib 60 __dispatch_sema4_timedwait (in libdispatch.dylib)
- libdispatch.dylib 72 __dispatch_semaphore_wait_slow (in libdispatch.dylib)
- CoreData 64 -[NSXPCStoreConnectionManager _checkoutConnection] (in CoreData)
- CoreData 52 ___54-[NSXPCStoreConnectionManager sendMessageWithContext:]_block_invoke (in CoreData)
- libdispatch.dylib 16 __dispatch_client_callout (in libdispatch.dylib)
- libdispatch.dylib 52 __dispatch_sync_invoke_and_complete (in libdispatch.dylib)
- CoreData 108 -[NSXPCStoreConnectionManager sendMessageWithContext:] (in CoreData)
- CoreData 368 -[NSXPCStore sendMessage:fromContext:interrupts:error:] (in CoreData)
- CoreData 296 -[NSXPCStore loadMetadata:] (in CoreData)
- CoreData 2684 ___91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke (in CoreData)
- CoreData 200 _gutsOfBlockToNSPersistentStoreCoordinatorPerform (in CoreData)
- libdispatch.dylib 16 __dispatch_client_callout (in libdispatch.dylib)
- libdispatch.dylib 52 __dispatch_lane_barrier_sync_invoke_and_complete (in libdispatch.dylib)
- CoreData 176 __perform (in CoreData)
- CoreData 480 -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] (in CoreData)
- PhotoLibraryServices 596 -[PLPersistentContainer _configureXPCPersistentStoreCoordinator:error:] (in PhotoLibraryServices)
- PhotoLibraryServices 296 -[PLPersistentContainer newSharedPersistentStoreCoordinator] (in PhotoLibraryServices)
- PhotoLibraryServices 56 ___57-[PLPersistentContainer sharedPersistentStoreCoordinator]_block_invoke (in PhotoLibraryServices)
- PhotoLibraryServicesCore 56 _PLResultWithUnfairLock (in PhotoLibraryServicesCore)
- PhotoLibraryServices 100 -[PLPersistentContainer sharedPersistentStoreCoordinator] (in PhotoLibraryServices)
- PhotoLibraryServices 112 -[PLPhotoLibraryBundle newChangeHandlingContainer] (in PhotoLibraryServices)
- PhotoLibraryServices 44 __60-[PLPhotoLibraryBundle initWithLibraryURL:bundleController:]_block_invoke.42 (in PhotoLibraryServices)
- PhotoLibraryServicesCore 80 ___27-[PLLazyObject objectValue]_block_invoke (in PhotoLibraryServicesCore)
- PhotoLibraryServicesCore 56 _PLResultWithUnfairLock (in PhotoLibraryServicesCore)
- PhotoLibraryServicesCore 100 -[PLLazyObject objectValue] (in PhotoLibraryServicesCore)
- PhotoLibraryServices 24 -[PLPhotoLibraryBundle resumeChangeHandling] (in PhotoLibraryServices)
- Photos 268 -[PHPhotoLibrary _resumeChangeHandlingIfNeeded] (in Photos)
- libdispatch.dylib 16 __dispatch_client_callout (in libdispatch.dylib)
- libdispatch.dylib 52 __dispatch_lane_barrier_sync_invoke_and_complete (in libdispatch.dylib)
- Photos 140 -[PHPhotoLibrary registerChangeObserver:] (in Photos)
I am pretty sure that this issue persist on the 15.2 released version.
If you set photo permission to PHAuthorizationStatusDenied
in Settings, and call registerChangeObserver:
without check the permission (to do a alert or something), the App will stuck 20s.
Is there some workarounds for the old version of our apps?
We have encountered the same issue.
Our app called PHPhotoLibrary.shared().register(self)
without explicitly asking for user authorization first. And it WILL stuck on iOS 15.2.
I think this is a bug rather than a feature of the system as the official documentation suggested relying on the system's automatic prompt for user authorization. Explicitly asking for authorization is described as optional.
Delivering an Enhanced Privacy Experience in Your Photos App | Apple Developer Documentation
The first time your app performs an operation that requires authorization, the system automatically and asynchronously prompts the user for it. Avoid making PhotoKit calls when your app first launches, to avoid interrupting its startup or onboarding process. Instead, make these calls in response to direct user action. Timing the authorization prompt to coincide with a user action provides greater context to the user about why your app is requesting access.
You may also programmatically request authorization, which lets you control the timing of the prompt and determine the user’s response. Request authorization only for the level of access required. The following example shows how to request read/write access; if your app only adds photos to the library, instead, request add-only access.
We are waiting for Apple to fix this issue.
Bob (Zeyu) Huang
This is an issue to me as well.
In the application, I am only using PHPhotoLibrary.requestAuthorization
and not using PHPhotoLibrary.shared().register(self)
though app is getting stuck.
Any idea about it?