Repository navigation
Description
What package does this bug report belong to?
image_picker (image_picker_ios)
What target platforms are you seeing this bug on?
iOS
Have you already upgraded your packages?
Yes. Reproduced with image_picker_ios 0.8.13+6; 0.8.13+7 (latest on pub.dev) and main contain the same code in FLTImagePickerImageUtil.m.
Dependency versions
image_picker 1.2.3 / image_picker_ios 0.8.13+6 / image_picker_platform_interface 2.11.1
Steps to reproduce
- On an iPhone with an HDR display running iOS 26 or later, set Settings > General > Screen Capture > Format to HDR and take a screenshot. iOS saves it as HEIF (brand
heix, 10-bit 4:4:4 HEVC, Display P3 with a PQ profile, ISO gain map) instead of PNG. - In a Flutter app call
ImagePicker().pickImage(source: ImageSource.gallery, maxWidth: 2048, maxHeight: 2048)and pick that screenshot. - Read the returned
XFile.
Verified on iPhone 15 Pro / iOS 27.0 (two different HDR screenshots). SDR screenshots (PNG) and HEIC camera photos from the same library work.
Expected results
A scaled JPEG/PNG, or a PlatformException if the image cannot be processed.
Actual results
pickImage resolves with a path to a 0-byte file, so the app treats the pick as successful and fails later when decoding. No error is reported.
Where it breaks (traced with os_log added to the plugin):
PHPickerResultis returned (typespublic.heic,public.png),loadDataRepresentation(public.image)yields 907,458 bytes.[[UIImage alloc] initWithData:]succeeds (1179x2556) andCGImageis non-NULL.FLTImagePickerImageUtil scaledImage:returns an image of size 0x0: theUIGraphicsImageRenderercreated withimageToScale.imageRendererFormatinFLTImagePickerDrawScaledImageproduces an empty image for this source.UIImageJPEGRepresentationof the 0x0 image is nil, andFLTImagePickerPhotoAssetUtil createFile:writes the nil data as an empty file and still returns the path.
Without maxWidth/maxHeight the scaler is skipped and the pick works.
Code sample
final picked = await ImagePicker().pickImage(
source: ImageSource.gallery,
maxWidth: 2048,
maxHeight: 2048,
);
final bytes = await picked!.readAsBytes();
print(bytes.length); // 0 for an iOS 26+ HDR screenshotScreenshots or Videos
No response
Logs
Instrumented run on the device (os_log added around the existing steps):
didFinishPicking count=1
result types=("public.heic", "public.png", "com.apple.private.photos.thumbnail.standard", "com.apple.private.photos.thumbnail.low")
loadData bytes=907458 err=(null)
decode ok w=1179 h=2556 cg=ok
scaled ok w=0 h=0
saved bytes=0
Proposed fix (happy to open a PR against flutter/packages if you want it)
Verified on the same device:
- In
FLTImagePickerDrawScaledImage, if the renderer built fromimageToScale.imageRendererFormatreturns an image whose size is 0x0, render again with an explicit format (UIGraphicsImageRendererFormat.defaultFormat,scale = 1,opaque = NO,preferredRange = UIGraphicsImageRendererFormatRangeStandard) and draw with[imageToScale drawInRect:]. This yields the expected 945x2048 image for the HDR screenshot and leaves other images on the existing path. - Make
createFile:return nil for empty data and haveFLTPHPickerSaveImageToPathOperationcomplete with aninvalid_imageFlutterErrorwhen the saved path is nil, so a failed encode surfaces as an exception instead of a 0-byte file. (The UIImagePickerController paths wrapsavedPathin an array literal, so they need the same nil guard.)
Flutter Doctor output
[✓] Flutter (Channel stable, 3.44.2, on macOS 26.5 25F71 darwin-arm64, locale ja-JP) [267ms]
• Flutter version 3.44.2 on channel stable at /opt/homebrew/share/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c9a6c48423 (3 months ago), 2026-06-10 15:52:41 -0700
• Engine revision 77e2e94772
• Dart version 3.12.2
• DevTools version 2.57.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, no-enable-swift-package-manager, omit-legacy-version-file, no-enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [991ms]
• Android SDK at /Users/techno-bibi/Library/Android/sdk
• Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
Activity
mbcorona commentedon Sep 21, 2026
HI @technobibi , thanks for reporting. I was able to reproduce on:
iPhone 15 Pro Max iOS 27
Flutter 3.47.5
image_picker 1.2.3
Picking an HDR screenshot (Settings > General > Screen Capture > Format = HDR, then screenshot HDR content, saved as 10-bit HEIF):
So it is specific to the scaler on a 10-bit HDR source, matching the scaledImage 0x0 trace above.
Minimal self contained repro (drop into a fresh
flutter create, add image_picker to pubspec and NSPhotoLibraryUsageDescription to ios/Runner/Info.plist, run on a physical HDR iPhone):Routing to the iOS team for further investigation.
okorohelijah commentedon Sep 23, 2026
What this is:
FLTImagePickerDrawScaledImageinitializesUIGraphicsImageRendererfromimageToScale.imageRendererFormat, which fails on 10-bit wide-gamut sources (such as iOS 26 HDR HEIF screenshots) and causesFLTImagePickerPhotoAssetUtilto write a 0-byte temp file whenmaxWidth/maxHeightare set. This is the same root cause as #185623, which has an approved fix in flight in flutter/packages#12557.What I verified:
eb2ecc26,FLTImagePickerDrawScaledImagepassesimageToScale.imageRendererFormatdirectly toUIGraphicsImageRenderer(introduced in Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGraphicsImageRenderer packages#6285, shipped inimage_picker_ios0.8.9+2): https://github.com/flutter/packages/blob/eb2ecc26/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerImageUtil.m#L36-L38UIImage.imageRendererFormatcan carryUIGraphicsImageRendererFormat.Range.unspecified("avoid specifying this value for an image renderer format"): https://developer.apple.com/documentation/uikit/uigraphicsimagerendererformat/range/unspecified, andUIImage.jpegData(compressionQuality:)returnsnilwhen the underlyingCGImageRefhas no data or an unsupported bitmap format: https://developer.apple.com/documentation/uikit/uiimage/jpegdata(compressionquality:)dataisnil,+createFile:suffix:callscreateFileAtPath:contents:nil(creating a 0-byte file) and has a no-opnil;statement on line 154: https://github.com/flutter/packages/blob/eb2ecc26/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPhotoAssetUtil.m#L149-L157FLTImagePickerDrawScaledImageby settingpreferredRange = UIGraphicsImageRendererFormatRangeStandard, though it does not add anil-data guard increateFile:suffix:.What I could not verify: Runtime behavior on an iOS 26+ device or simulator — I am on a Linux host without Xcode.
Confidence: Medium — the code path, Apple documentation, and in-flight PR flutter/packages#12557 align with both reports on this thread, though I could not execute the Objective-C scaler on iOS.
To move this forward: @LouiseHsu / @hellohuanlin — should this issue be closed as a duplicate of #185623 once flutter/packages#12557 lands, or kept open to also guard
+createFile:suffix:againstnilimage data?Pre-triage by
Elijah's_triage_agent— verify before acting on it.hellohuanlin commentedon Sep 24, 2026
@technobibi yes PRs are always welcome!
technobibi commentedon Sep 24, 2026
I confirmed on an iPhone 15 Pro (iOS 27.0) that the HDR screenshot failure is fixed by flutter/packages#12557 (0.8.13+8).
The 0-byte file part was still unfixed, so I opened flutter/packages#12998. It is verified on the device and covered by native tests. Please take a look when you have time.
[image_picker_ios] Return an error instead of an empty file when an i…