Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

PHPickerResult take loong time to load large video

On some devices, loadFileRepresentation(forTypeIdentifier: completionHandler) take a loong time(about two minute) to callback result for some large video(about 200 MB, take by device camera).

environment:

  • Model: iPhone 12
  • Model Number: MGGM3CH/A
  • iOS Version: 18.3.2

PHPickerResult.NSItemProvider.loadFileRepresentation()

    // import PhotosUI
    func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
        picker.dismiss(animated: true, completion: nil)
        guard let provider = results.last?.itemProvider else { return }
        
        guard provider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) else {
            return
        }
        
        Task {
            provider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { url, error in
                guard let url = url else {
                    return
                }
                
                // Do some stuff...
            }
        }
    }

ps: I also try some other function, eg: provide.loadItem(forTypeIdentifier:), but not work too.

Add the picker configuration:

        var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
        configuration.filter = .any(of: [.images, .videos])
        configuration.selectionLimit = 1
        configuration.selection = .default
        configuration.preferredAssetRepresentationMode = .current
        configuration.disabledCapabilities = .search
        configuration.edgesWithoutContentMargins = .bottom
PHPickerResult take loong time to load large video
 
 
Q