Understanding PHPickerConfiguration.AssetRepresentationMode.current

The documentation for this API mentions:

The system uses the current representation and avoids transcoding, if possible.

What are the scenarios in which transcoding takes place?

The reason for asking is that we've had a user reaching out saying they selected a video file from their Photos app, which resulted in a decrease in size from ~110MB to 35MB. We find it unlikely it's transcoding-related, but we want to gain more insights into the possible scenarios.

PHPickerViewController and AssetRepresentationMode shouldn't affect original files stored in the Photos app in any way.

The size of the file your app receives via PHPickerViewController can be different from the original file stored in the Photos app. For example, Slo-Mo videos and Cinematic Mode videos will have their effects baked in the video file.

Unless .current is specified, transcoding can happen if your app doesn't support the original file format. For example, if your app can only support JPEG but the original image is stored as HEIF, the system will transcode the image to JPEG for you.

Thanks for those insights! It seems that there's still a scenario. We've been able to reproduce the user's behavior as follows:

  1. Create a video in GoPro Quik
  2. Export it to the Photos app
  3. Import it into the WeTransfer app <- This is where we use PHPickerViewController in combination with .current
  4. Notice a difference in file size as reported by the Photos app

Even though the video is locally stored (not in iCloud), a "Preparing..." progress popup appears. That indicates transcoding is happening.

I've attached a few screenshots to indicate our issue.

Could it be that there's still some kind of setting we're missing to indicate our app allows any kind of file to be added?

After some further investigation, it turns out that the HEVC video gets transcoded into MPEG-4, even though we've configured our PHPickerViewController as follows:

var configuration = PHPickerConfiguration()
configuration.selectionLimit = 0
configuration.preferredAssetRepresentationMode = .current

return PHPickerViewController(configuration: configuration)

We're loading the file using itemProvider.loadFileRepresentation(forTypeIdentifier: "public.movie"), which I believe should be correct.

A few interesting findings:

  • If I Airdrop the file to my Mac, it remains being HEVC and keeps the correct size
  • If I load that file into the Xcode Simulator and add it to our app running in the Simulator, transcoding is not taking place

The latter is especially interesting: What is the difference between the file on the device vs. the file in the Simulator after airdropping? Why does transcoding take place on device and not in the Simulator?

I'd almost say there's some kind of device setting or iCloud influencing the result, but at this point, I've got no clue. Looking forward to get your thoughts!

Understanding PHPickerConfiguration.AssetRepresentationMode.current
 
 
Q