How do I test PHImageResultIsInCloudKey?
Asked Answered
S

1

6

My app has a custom photo picker that uses the Photos framework to browse albums and select a photo. I have isolated reports of a very specific bug that occurs only if the user (a) has iCloud Photo Library turned on, (b) has Optimize Storage turned on in their Photos settings and (c) that specific album and/or image has been moved off the device.

In this scenario, it looks like no actual image is returned to the closure I pass to PHCachingImageManager#requestImage. Instead, from what I gather, PHImageResultIsInCloudKey is included in the info dictionary and I need to re-invoke the request with isNetworkAccessAllowed set to true.

However, in my own testing, I just can't get this specific scenario to occur so I can confirm that my fix works. Even with iCloud Photo Library on and Optimize Storage on, I still always get an image back and never get PHImageResultIsInCloudKey.

Is there a way to force a situation where the image is off-device and has to be loaded from the cloud?

Scummy answered 8/2, 2018 at 2:35 Comment(0)
R
4

I was working with PHAssets and had a similar problem, where a user device had an unimaginably vast photo library (meaning lots of photos were off-device), which was causing performance issues.

To replicate those conditions, I made https://github.com/jrturton/DiskFiller, which, as you might guess, writes massive files to your device until it is full, which has the side effect of triggering the "optimised storage" for iCloud photos to kick in, moving older photos to the cloud. Maybe that can help.

Probably best to run it on a test device if you have one :)

Racketeer answered 27/2, 2019 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.