Post not yet marked as solved
iOS 16 Beta 3 introduces the "Shared Photo Library". PhotoKit however currently lacks any functionality to import photos/videos into the "Shared Photo Library"
It would be welcome, if PHAssetCreationRequest could be extended with e.g. a property "destination" that defaults to the personal library, but can also be set to the shared library.
Scenarios:
3rd party camera apps that should be able to import into the "Shared Library"
Any type of family orientated apps that should be able to import into the "Shared Library"
Filled this also as FB10577456
Post not yet marked as solved
specifically:
https://www.macrumors.com/2022/06/15/ios-16-remove-subject-from-background/
Post not yet marked as solved
Used to be able to assign a Live Photo as a new Wallpaper showing the static and video image prior to iOS 16. The beta version of iOS 16.0 accepts the Live Photo as a static image only.
Not sure if this is a bug in the current prerelease or a permanently dropped feature.
Anyone else observed this issue?
Post not yet marked as solved
Environment: iOS 16 beta 2, beta 3. iPhone 11 Pro, 12 mini
Steps to reproduce:
Subscribe to Photo Library changes via PHPhotoLibraryChangeObserver, put some logs to track inserted/deleted objects:
func photoLibraryDidChange(_ changeInstance: PHChange) {
if let changeDetails = changes.changeDetails(for: allPhotosFetchResult) {
for insertion in changeDetails.insertedObjects {
print("🥶 INSERTED: ", insertion.localIdentifier)
}
for deletion in changeDetails.removedObjects {
print("🥶 DELETED: ", deletion.localIdentifier)
}
}
}
Save a photo to camera roll with PHAssetCreationRequest
Go to the Photo Library, delete the newly saved photo
Come back to the app and watch the logs:
🥶 INSERTED: 903933C3-7B83-4212-8DF1-37C2AD3A923D/L0/001
🥶 DELETED: 39F673E7-C5AC-422C-8BAA-1BF865120BBF/L0/001
Expected result: localIdentifier of the saved and deleted asset is the same string in both logs.
In fact: It's different.
So it appears that either the localIdentifier of an asset gets changed after successful saving, or it's a bug in the Photos framework in iOS 16. I've checked - in iOS 15 it works fine (IDs in logs match).
Post not yet marked as solved
The smart albums PHAssetCollectionSubtypeSmartAlbumAllHidden now requires authorisation in iOS 16. How can we access PHAssetCollectionSubtypeSmartAlbumAllHidden from PhotoKit now and provide the necessary authorisation inside a 3rd party app?
Cheers,
Hendrik
Post not yet marked as solved
Trying to follow along the code with PhotosPicker.
It returns nil when loadTransferable(type:Image.self), and it works well using Data.self
Post not yet marked as solved
Where is the .isEditing option???
Post not yet marked as solved
Hello, Recently we added a change in our app that changed the resource addition to Photos - Until now we called addResourceWithType:fileURL:options: with PHAssetResourceCreationOptions.shouldMoveFile set to YES, and when we changed it to NO (the default value) we observed much more asset creation failures. Specifically we see a new error code in the procedure - PHPhotosErrorNotEnoughSpace. One can clearly see a connection between adding more storage to the file system and an asset creation failure that is related to storage, but we are struggling to understand a few things:
The storage of the device is always higher than the video size, usually by a great amount - We observed failures for devices with 120GB free storage, while the video size was 200MB.
Generally we save quite a lot of resources to the file system, so it is quite surprising to see supposedly storage issues when adding a relatively low amount of extra storage.
The asset creation is part of a bigger procedure of encoding a video to a file system, and then moving/copying it to Photos. Is it that big of a difference to copy a video of 100MB-200MB instead of moving it, such that the overall procedure failure will increase drastically?
Appreciate any help.
Post not yet marked as solved
I have a popular app and i'm seeing a sporadic crash that I don't understand:Fatal Exception: NSInternalInconsistencyException
This method can only be called from inside of -[PHPhotoLibrary performChanges:completionHandler:] or -[PHPhotoLibrary performChangesAndWait:error:]Here is the code, it crashes on line 3 (creationRequestForAssetFromImage) below: PHPhotoLibrary.shared().performChanges({
guard
let changeRequest = PHAssetChangeRequest.creationRequestForAssetFromImage(atFileURL: animatedImageFileURL),
let albumChangeRequest = PHAssetCollectionChangeRequest.init(for: album),
let placeholder = changeRequest.placeholderForCreatedAsset else {
WLog("ActionExecuter: error, couldn't init creationRequests")
completionBlock(nil)
return
}
...Clearly this IS in a performChanges block.Full stack of crash, from line 3 above onwards:Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x184da6d8c __exceptionPreprocess
1 libobjc.A.dylib 0x183f605ec objc_exception_throw
2 Photos 0x193cad220 -[PHPhotoLibrary recordInsertRequest:]
3 Photos 0x193c3cf78 -[PHChangeRequestHelper initForNewObjectWithUUID:changeRequest:]
4 Photos 0x193c6dfc4 -[PHAssetCreationRequest initForNewObjectWithUUID:]
5 Photos 0x193c699c0 +[PHAssetCreationRequest _creationRequestForAssetUsingUUID:]
6 Photos 0x193c69ce4 +[PHAssetCreationRequest creationRequestForAssetFromImageAtFileURL:]I am wondering if this is some threading issue. Is there a rule about what thread performChanges et al have to be called from?It seems to be slower devices that hit this: iOS 11 on an iPad Air 1 is the latest crash in the wild I saw of this one.Thanks for any help
Post not yet marked as solved
Pick 2 Photo with PhotosPicker
Deselect 2 Photo in PhotosPicker And Done
selection(PhotosPickerItem) doesn't change
PhotosPicker(selection: $photoPickerItems,
maxSelectionCount: 0,
selectionBehavior: .ordered,
matching: nil,
preferredItemEncoding: .current,
photoLibrary: .shared()) {
Image(systemName: "photo")
}
Post not yet marked as solved
I use loadFileRepresentation(forTypeIdentifier:completionHandler:) to load video with PHPickerViewController
What can I use load video with?
// my sample code
func loadPhoto(pickerItem: PhotosPickerItem) async throws -> Photo {
if let livePhoto = try await pickerItem.loadTransferable(type: PHLivePhoto.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: livePhoto)
return photo
} else if let url = try await pickerItem.loadTransferable(type: URL.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: url)
return photo
} else if let data = try await pickerItem.loadTransferable(type: Data.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: data)
return photo
}
throw PhotoError.load
}
Post not yet marked as solved
Our
team has implemented PHPickerViewController to allow multiple photos to be
selected. It works fine in the simulator but when tested on actual iPad we have
this strange behaviour. The first time the gallery is displayed it works fine.
If we try and display the gallery again it displays a window with this message
“Unable to Load Items - [Try Again]”. If I tap [Try Again] or if I
use our Gallery button it does display the gallery. And it keeps cycling
through this behaviour. ie. every second attempt to display the gallery leads
to the “Unable to Load Items” window.
Every time we display the gallery we dismiss the old instance and create/initialize a
new instance of the controller. Our code is written in objective-c…
-(void)initPHPickerController
{
[self dismiss];
mPHPickerController = nullref;
PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
config.selectionLimit = 0; // 0 represents no selection limit.
config.filter = [PHPickerFilter imagesFilter];
config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;
PHPickerViewController *pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];
pickerViewController.delegate = self;
mPHPickerController = pickerViewController;
}
- (void)dismiss
{
if (mPHPickerController)
{
[+mPHPickerController dismissViewControllerAnimated:YES completion:nil];
}
...
}
Any suggestions on how to fix this ?
I have seen a post on stackoverflow that this may be a bug in iOS.
Post not yet marked as solved
While trying to save a photo to a custom album on some devices we get the following error:
The operation couldn’t be completed. (PHPhotosErrorDomain error 3300).
code: 3300
This is the part of the code where the issue happens
PHPhotoLibrary.shared().performChanges({
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
guard let placeholder = assetChangeRequest.placeholderForCreatedAsset else { return }
let albumChangeRequest = PHAssetCollectionChangeRequest(for: album)
albumChangeRequest?.addAssets([placeholder] as NSArray)
}, completionHandler: { success, error in
completion(success, error)
})
I would be thankful for any tips since I am out of ideas.
Post not yet marked as solved
Code from wwdc20-10652 is used.
Open PHPickerViewController
Choose 1 photo
Do nothing and dismiss
Leak is shown as below.
@IBAction private func chooseImagePressed(_ sender: Any) {
if #available(iOS 14, *) {
var configuration = PHPickerConfiguration()
configuration.filter = .images
let picker = PHPickerViewController(configuration: configuration)
picker.delegate = self
present(picker, animated: true)
} else {
// Fallback on earlier versions
}
}
extension PhotosVC: PHPickerViewControllerDelegate {
@available(iOS 14, *)
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
dismiss(animated: true)
}
}
Post not yet marked as solved
I use PHPhotoLibrary in iOS to save JPG files to the camera roll.
There is a difference in the date and time displayed in the "Photos" app depending on whether the 24-hour display setting in iOS is set to On or Off when saving.
When saving with "24-hour display: Off", the date and time in the Exif of the JGP file is displayed.
When saved with "24 Hour Display: On", the date and time when the file was saved is displayed.
JPG files are saved with the following code.
HPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromImage(atFileURL: jpgFileUrl)
}, completionHandler: { (success: Bool, error: Error?) in
print("success=\(success), error=\(String(describing: error))")
})
Is this an iOS specification or a bug? Or is there a problem with the code?
I would appreciate it if you could provide me with some information.
Thank you in advance.
Post not yet marked as solved
Will the code for the SwiftUI PhotosPicker app shown during the session be made available in the code sample area? Trying to follow along and duplicate the app, but not all of the code is visible. Thanks!
Post not yet marked as solved
Incident Identifier: 3400A577-E4A0-483B-AF20-53F105BCB104
CrashReporter Key: 8d970b914f1fd529bba76fcaa1d0ba1588c88c47
Hardware Model: iPhone14,5
Process: Animalsocial [1096]
Path: /private/var/containers/Bundle/Application/A645D0E7-C811-4A46-977C-0D46A755C68A/Animalsocial.app/Animalsocial
Identifier: org.reactjs.developer.Animalsocial
Version: 1.0 (1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: org.reactjs.developer.Animalsocial [550]
Date/Time: 2022-06-10 20:11:40.0525 +0530
Launch Time: 2022-06-10 20:11:30.5303 +0530
OS Version: iPhone OS 15.5 (19F77)
Release Type: User
Baseband Version: 1.61.00
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000014000
Exception Codes: 0x0000000000000001, 0x0000000000014000
VM Region Info: 0x14000 is not in any region. Bytes before following region: 4307402752
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 100bf0000-1022e8000 [ 23.0M] r-x/r-x SM=COW .../Animalsocial
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [1096]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x1c6e04c54 weak_entry_insert(weak_table_t*, weak_entry_t*) + 72
1 libobjc.A.dylib 0x1c6e0dffc weak_resize(weak_table_t*, unsigned long) + 112
2 libobjc.A.dylib 0x1c6dfea44 weak_register_no_lock + 256
3 libobjc.A.dylib 0x1c6e03924 objc_storeWeak + 448
4 Foundation 0x1af890ba4 -[NSConcreteHashTable addObject:] + 100
5 Animalsocial 0x1013ca198 -[SDImagePhotosLoader requestImageWithURL:options:context:progress:completed:] + 1216
6 Animalsocial 0x10139fc18 -[SDImageLoadersManager requestImageWithURL:options:context:progress:completed:] + 444
7 Animalsocial 0x1013b5240 -[SDWebImageManager callDownloadProcessForOperation:url:options:context:cachedImage:cachedData:cacheType:progress:completed:] + 1632
8 Animalsocial 0x1013b4164 __89-[SDWebImageManager callCacheProcessForOperation:url:options:context:progress:completed:]_block_invoke + 644
9 Animalsocial 0x10138c048 __73-[SDImageCache queryCacheOperationForKey:options:context:cacheType:done:]_block_invoke_2 + 56
10 libdispatch.dylib 0x1add7ae6c _dispatch_call_block_and_release + 32
11 libdispatch.dylib 0x1add7ca30 _dispatch_client_callout + 20
12 libdispatch.dylib 0x1add8af48 _dispatch_main_queue_drain + 928
13 libdispatch.dylib 0x1add8ab98 _dispatch_main_queue_callback_4CF + 44
14 CoreFoundation 0x1ae0cd800 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
15 CoreFoundation 0x1ae087704 __CFRunLoopRun + 2532
16 CoreFoundation 0x1ae09abc8 CFRunLoopRunSpecific + 600
17 GraphicsServices 0x1ca1ce374 GSEventRunModal + 164
18 UIKitCore 0x1b0a0a648 -[UIApplication _run] + 1100
19 UIKitCore 0x1b078bd90 UIApplicationMain + 364
20 Animalsocial 0x100bf6258 main + 104
21 dyld 0x104e7dce4 start + 520
Thread 1 name: Dispatch queue: com.apple.avplayeritem.figplaybackitem.accessor
Thread 1:
0 libsystem_kernel.dylib 0x1e5b4bf24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x21f25f298 _pthread_cond_wait + 1236
2 CoreMedia 0x1b8c348c4 WaitOnCondition + 20
3 CoreMedia 0x1b8c91bd0 FigConditionVariableWaitRelative + 16
4 MediaToolbox 0x1b8430574 itemasync_CopyProperty + 500
5 AVFCore 0x1b76da950 +[AVPlayerItem _copyTimebaseFromFigPlaybackItem:] + 180
6 AVFCore 0x1b7707620 __31-[AVPlayerItem _updateTimebase]_block_invoke + 80
7 libdispatch.dylib 0x1add7ae6c _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x1add7ca30 _dispatch_client_callout + 20
9 libdispatch.dylib 0x1add84124 _dispatch_lane_serial_drain + 668
10 libdispatch.dylib 0x1add84c80 _dispatch_lane_invoke + 392
11 libdispatch.dylib 0x1add8f500 _dispatch_workloop_worker_thread + 648
12 libsystem_pthread.dylib 0x21f2580bc _pthread_wqthread + 288
13 libsystem_pthread.dylib 0x21f257e5c start_wqthread + 8
Thread 2 name: Dispatch queue: com.apple.avplayeritem.figplaybackitem.accessor
Thread 2:
0 libsystem_kernel.dylib 0x1e5b4bf24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x21f25f298 _pthread_cond_wait + 1236
2 CoreMedia 0x1b8c348c4 WaitOnCondition + 20
3 CoreMedia 0x1b8c91bd0 FigConditionVariableWaitRelative + 16
4 MediaToolbox 0x1b8430574 itemasync_CopyProperty + 500
5 AVFCore 0x1b76da950 +[AVPlayerItem _copyTimebaseFromFigPlaybackItem:] + 180
6 AVFCore 0x1b7707620 __31-[AVPlayerItem _updateTimebase]_block_invoke + 80
7 libdispatch.dylib 0x1add7ae6c _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x1add7ca30 _dispatch_client_callout + 20
9 libdispatch.dylib 0x1add84124 _dispatch_lane_serial_drain + 668
10 libdispatch.dylib 0x1add84c80 _dispatch_lane_invoke + 392
11 libdispatch.dylib 0x1add8f500 _dispatch_workloop_worker_thread + 648
12 libsystem_pthread.dylib 0x21f2580bc _pthread_wqthread + 288
13 libsystem_pthread.dylib 0x21f257e5c start_wqthread + 8
Thread 3 name: com.apple.uikit.eventfetch-thread
Thread 3:
0 libobjc.A.dylib 0x1c6e1c3c4 class_rw_t::methods() const + 112
1 libobjc.A.dylib 0x1c6dfc2b4 class_copyMethodList + 144
2 BaseBoard 0x1b368a084 BSProtobufClassImplmementsProtobufSchema + 40
3 BaseBoard 0x1b36b45ac _BSProtobufValidateClassForEncoding + 44
4 BaseBoard 0x1b367d174 +[BSProtobufSerialization
Is it possible to develop an iOS application that shows all of the user's photos in a custom view ?
Post not yet marked as solved
I'm trying to move a video I create from images within my app from a temporary path to the photo library.
I've verified that the movie exists by downloading the app data via devices/xcode and the movie then plays fine on my macbook.
I've tried:
UISaveVideoAtPathToSavedPhotosAlbum(
videoPath,
self,
#selector(self.video(_:didFinishSavingWithError:contextInfo:)),
nil)
with Error:
Optional(Error Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo={NSLocalizedDescription=Unknown error, NSUnderlyingError=0x283684570 {Error Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo={NSLocalizedDescription=Unknown error, NSUnderlyingError=0x283681860 {Error Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo={NSLocalizedDescription=Unknown error, NSUnderlyingError=0x28366e490 {Error Domain=com.apple.photos.error Code=42001 "(null)"}}}}}})
and
PHPhotoLibrary.requestAuthorization { status in
// Return if unauthorized
guard status == .authorized else {
print("Error saving video: unauthorized access")
return
}
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL as URL)
}) { success, error in
if !success {
print("Error saving video: \(String(describing: error))")
}
}
}
with Error:
Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo= ...... {Error Domain=com.apple.photos.error Code=42001 "(null)"
both compile fine and are called, but end up giving me errors that do not help in the slightest.
I have a full help request on StackOverflow with a link to the project (that it does not let me post here): https://stackoverflow.com/questions/63575539/swift-ios-save-video-to-library
Post not yet marked as solved
I have been trying to load an image from the photo library on a swifui app. I am running Xcode 13.2.1 and building IOS 15.2
My code is as below
@Binding var image: UIImage?
func makeUIViewController(context: Context) -> PHPickerViewController {
var config = PHPickerConfiguration()
config.filter = .images
config.selectionLimit = 1
config.preferredAssetRepresentationMode = .compatible
let controller = PHPickerViewController(configuration: config)
controller.delegate = context.coordinator
return controller
}
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { }
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
// Use a Coordinator to act as your PHPickerViewControllerDelegate
class Coordinator: NSObject, PHPickerViewControllerDelegate {
private let parent: PhotoPicker
init(_ parent: PhotoPicker) {
self.parent = parent
}
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
picker.dismiss(animated: true)
print(results)
guard !results.isEmpty else {
return
}
guard let itemProvider = results.first?.itemProvider else { return }
print("Invoking getPhoto")
self.getPhoto2(from: itemProvider)
//parent.didFinishPicking(!results.isEmpty)
}
private func getPhoto2(from itemProvider: NSItemProvider) {
print("getPhoto")
if itemProvider.canLoadObject(ofClass: UIImage.self) {
itemProvider.loadObject(ofClass: UIImage.self) { image, error in
self.parent.image = image as? UIImage
print("Loaded Image \(error)")
}
}
}
}
}
On the console I see the following error
022-01-27 00:40:01.485085-0500 Vescense[3174:884964] [Picker] Showing picker unavailable UI (reason: still loading) with error: (null)
Further when I print the result I see
[PhotosUI.PHPickerResult(itemProvider: <PUPhotosFileProviderItemProvider: 0x2818fc980> {types = (
"public.jpeg",
"public.heic"
)}, assetIdentifier: nil)]
It doesn't appear like the error on loadObject has a value. And it's suspicious that assetIdentifier is nil.
Any thoughts on what I might be missing here would be most helpful.