ImageManager console errors with HEIC in iOS 11 Beta 6

iOS11, Beta 6. Xcode 9.0 Beta6.

Test device: iPhone 7 with iOS11, Beta 6


Images on device:


/var/mobile/Media/DCIM/100APPLE/IMG_0001.HEIC <-- portrait image taken on camera

/var/mobile/Media/DCIM/100APPLE/IMG_0002.HEIC <-- portrait image taken on camera

/var/mobile/Media/DCIM/100APPLE/IMG_0003.HEIC <-- landscape image taken on camera

Description:
When we query HEIC PHAssets and then try to convert them to UIImages, we notice that if the requested UIImage is a certain size, we get an error logged to the console. When I look at the UIImage in the debugger, the image data appears to have loaded correctly. That said, we have seen some questionable downstream behavior which combined with the error in the console makes us wonder if there is a bug on the Apple side. The code snippet below distills this as simple as possible. I am debugging on the iPhone 7 with it attached to the Mac. Note the tests below and how they relate to the portrait/landscape version of the images.


Code:


- (void)load

{

PHFetchResult<PHAsset *> *fetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil];

PHCachingImageManager *manager = [[PHCachingImageManager alloc] init];


for (NSUInteger index=0; index < fetchResult.count; index++) {


PHAsset *localAsset = (PHAsset *)[fetchResult objectAtIndex:index];

CGSize targetSize = CGSizeMake(300,300);


PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];

options.resizeMode = PHImageRequestOptionsResizeModeExact;

options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;

options.networkAccessAllowed = YES;

options.synchronous = NO;

options.version = PHImageRequestOptionsVersionCurrent;


[manager requestImageForAsset:localAsset targetSize:targetSize contentMode:PHImageContentModeAspectFill options:options

resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {

NSLog(@"================> %@", result);

}];

}

}


Output:


2017-08-25 14:42:30.179230-0600 FakePicker[942:335069] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0001.HEIC

2017-08-25 14:42:30.180855-0600 FakePicker[942:335069] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0002.HEIC

2017-08-25 14:42:30.182445-0600 FakePicker[942:335071] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0003.HEIC

2017-08-25 14:42:30.193726-0600 FakePicker[942:335050] refreshPreferences: HangTracerEnabled: 1

2017-08-25 14:42:30.193766-0600 FakePicker[942:335050] refreshPreferences: HangTracerDuration: 500

2017-08-25 14:42:30.193784-0600 FakePicker[942:335050] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0

2017-08-25 14:42:30.331189-0600 FakePicker[942:335050] ================> <UIImage: 0x1c40a4e60>, {300, 300}

2017-08-25 14:42:30.349985-0600 FakePicker[942:335050] ================> <UIImage: 0x1c40a4c80>, {300, 300}

2017-08-25 14:42:30.351027-0600 FakePicker[942:335050] ================> <UIImage: 0x1c40a52e0>, {300, 300}

=================

With CGSize targetSize = CGSizeMake(200,200);


Output:


2017-08-25 14:44:27.083576-0600 FakePicker[944:335644] refreshPreferences: HangTracerEnabled: 1

2017-08-25 14:44:27.083620-0600 FakePicker[944:335644] refreshPreferences: HangTracerDuration: 500

2017-08-25 14:44:27.083637-0600 FakePicker[944:335644] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0

2017-08-25 14:44:27.089644-0600 FakePicker[944:335644] ================> <UIImage: 0x1c02a2520>, {200, 200}

2017-08-25 14:44:27.090336-0600 FakePicker[944:335644] ================> <UIImage: 0x1c42a07e0>, {200, 200}

2017-08-25 14:44:27.090941-0600 FakePicker[944:335644] ================> <UIImage: 0x1c02a2520>, {200, 200}

=================

With CGSize targetSize = CGSizeMake(300,200);


Output:


2017-08-25 14:45:03.476569-0600 FakePicker[947:335984] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0001.HEIC

2017-08-25 14:45:03.477288-0600 FakePicker[947:335982] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0002.HEIC

2017-08-25 14:45:03.490331-0600 FakePicker[947:335959] refreshPreferences: HangTracerEnabled: 1

2017-08-25 14:45:03.490373-0600 FakePicker[947:335959] refreshPreferences: HangTracerDuration: 500

2017-08-25 14:45:03.490390-0600 FakePicker[947:335959] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0

2017-08-25 14:45:03.500767-0600 FakePicker[947:335959] ================> <UIImage: 0x1c00bbe40>, {300, 200}

2017-08-25 14:45:03.598622-0600 FakePicker[947:335959] ================> <UIImage: 0x1c00bbba0>, {300, 200}

2017-08-25 14:45:03.603892-0600 FakePicker[947:335959] ================> <UIImage: 0x1c00b90e0>, {300, 200}

=================

With CGSize targetSize = CGSizeMake(200,300);

Output:


2017-08-25 14:45:40.443282-0600 FakePicker[949:336319] [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/100APPLE/IMG_0003.HEIC

2017-08-25 14:45:40.445260-0600 FakePicker[949:336297] refreshPreferences: HangTracerEnabled: 1

2017-08-25 14:45:40.445296-0600 FakePicker[949:336297] refreshPreferences: HangTracerDuration: 500

2017-08-25 14:45:40.445312-0600 FakePicker[949:336297] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0

2017-08-25 14:45:40.449138-0600 FakePicker[949:336297] ================> <UIImage: 0x1c40b0f80>, {200, 300}

2017-08-25 14:45:40.450187-0600 FakePicker[949:336297] ================> <UIImage: 0x1c00b1040>, {200, 300}

2017-08-25 14:45:40.539843-0600 FakePicker[949:336297] ================> <UIImage: 0x1c00b1040>, {200, 300}

Replies

I am seeing similar problem with ordinary photos, since upgrading to iOS 11. If I request small size for thumbnails, everythings loads. When I try to get larger size, about 20% fail. I haven't figured out what the pattern is yet.

I'm getting the same error. Did you find out why this keep happening?

Same here. Did you guys find any workaround?