Skip to content

[image_picker_ios] Return an error for undecodable image data - #12267

Merged
auto-submit[bot] merged 7 commits into
flutter:mainfrom
TeddyYeung:codex/image-picker-ios-avif-completion
Oct 8, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:mainfrom
TeddyYeung:codex/image-picker-ios-avif-completion

Conversation

@TeddyYeung

@TeddyYeung TeddyYeung commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

PHPicker can provide data for a type that conforms to UTTypeImage even when UIImage cannot decode the bytes. The linked issue reports this with an AVIF selection. The existing path continues with a nil image and can treat the selection as successfully saved.

This change completes the operation with the existing invalid_image error when decoding fails. It also adds a regression test that verifies the callback returns no path and that the NSOperation finishes.

Fixes flutter/flutter#132154

No public API documentation changes are needed because this uses the existing image-picker error contract.

Tests run:

  • flutter_plugin_tools format --packages image_picker_ios --fail-on-change
  • flutter_plugin_tools analyze --ios --packages image_picker_ios
  • flutter_plugin_tools dart-test --packages image_picker_ios
  • flutter_plugin_tools native-test --ios --no-integration --packages image_picker_ios
  • flutter_plugin_tools validate --packages image_picker_ios
  • flutter_plugin_tools license-check
  • (from packages/image_picker/image_picker_ios) dart pub publish --dry-run

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

PHPicker can provide image-conforming data that UIImage cannot decode. Complete the save operation with invalid_image instead of passing a nil image to the save path.
@google-cla

google-cla Bot commented Jul 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@TeddyYeung
TeddyYeung marked this pull request as ready for review July 22, 2026 04:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the iOS implementation of the image_picker plugin to handle cases where selected image data cannot be decoded. In FLTPHPickerSaveImageToPathOperation.m, a check has been added to verify if the UIImage is nil after initialization; if so, the operation completes with an 'invalid_image' FlutterError. A corresponding unit test has been added to PickerSaveImageToPathOperationTests.m to verify this behavior, and the package version has been bumped to 0.8.13+7 in both pubspec.yaml and CHANGELOG.md. There are no review comments to address.

@stuartmorgan-g stuartmorgan-g added the triage-ios Should be looked at in iOS triage label Jul 28, 2026
@vashworth vashworth added the CICD Run CI/CD label Aug 25, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 28, 2026
@okorohelijah okorohelijah added the CICD Run CI/CD label Sep 3, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@LongCatIsLooong

Copy link
Copy Markdown
Contributor

@TeddyYeung could you resolve the merge conflicts?

Merge current upstream main and retain both the upstream PHPicker operation tests and the AVIF decoding regression test from this PR.

Constraint: Upstream added independent tests at the same insertion point.
Rejected: Prefer either side wholesale | would discard valid regression coverage.
Confidence: high
Scope-risk: narrow
Directive: Keep the undecodable-image assertion when updating this test fixture.
Tested: flutter_plugin_tools format; dart analyze
Not-tested: iOS native tests and Xcode analysis (full Xcode/simctl unavailable)
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 4, 2026
@TeddyYeung

Copy link
Copy Markdown
Contributor Author

Resolved in af0badc. I merged the current upstream main and retained both the upstream PHPicker operation coverage and this PR's undecodable-image regression test. Formatting and Dart analysis pass; the iOS native test suite could not run locally because this environment does not have Xcode/simctl installed.

@TeddyYeung

Copy link
Copy Markdown
Contributor Author

The merge conflicts have been resolved. Could you please re-add the CICD label to trigger presubmit?

@okorohelijah okorohelijah added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Sep 10, 2026
@auto-submit

auto-submit Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/12267, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 16, 2026
@elliette

Copy link
Copy Markdown
Member

Hi @TeddyYeung - it looks like you force pushed with an account that you didn't sign the CLA with. You will need to amend the commit locally with the correct email address and then force push before we can take a look again. Thank you!

@elliette elliette added the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Sep 22, 2026
@TeddyYeung
TeddyYeung force-pushed the codex/image-picker-ios-avif-completion branch from d226208 to 0707379 Compare September 27, 2026 12:32
@github-actions github-actions Bot removed the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Sep 27, 2026
The fix was listed under 0.8.13+7, which has already been published.
@TeddyYeung

Copy link
Copy Markdown
Contributor Author

Hi @elliette, thanks! The commit authors are now fixed and cla/google is passing. I also merged the latest main and moved the CHANGELOG entry to a new 0.8.13+9 version, since 0.8.13+7 was already published. Could someone re-add the CICD label when you get a chance?

@vashworth vashworth added the CICD Run CI/CD label Oct 1, 2026
@cbracken

cbracken commented Oct 1, 2026

Copy link
Copy Markdown
Member

@TeddyYeung apologies -- do you mind resolving the merge conflicts on this one then we'll get right back to it.

- Bump image_picker_ios to 0.8.13+10 (0.8.13+9 was taken upstream)
- Port undecodable image test to Swift Testing after ObjC tests were migrated
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 2, 2026
@TeddyYeung

Copy link
Copy Markdown
Contributor Author

Thanks @cbracken! Merged the latest main and resolved the conflicts in bb0d0c3:

Could you re-add the CICD label to trigger presubmit?

@tarrinneal tarrinneal added the CICD Run CI/CD label Oct 2, 2026
@vashworth vashworth added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2026
@auto-submit
auto-submit Bot merged commit 54706bd into flutter:main Oct 8, 2026
14 checks passed
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 8, 2026
flutter/packages@7660d46...54706bd

2026-10-08 [email protected] [image_picker_ios] Return an error
for undecodable image data (flutter/packages#12267)
2026-10-07 [email protected] [flutter shaders] update min flutter
version (flutter/packages#13160)
2026-10-07 [email protected] Import flutter_shaders package
(flutter/packages#12583)
2026-10-07 [email protected]
[material_ui] Migrate M3 Typography template to use new gen_defaults
(flutter/packages#13074)
2026-10-07 [email protected] Sync release-material_ui-1.6.0 to
main (flutter/packages#13149)
2026-10-07 [email protected] [pigeon] Fix native interop (JNI) calls
in minified Android release builds (flutter/packages#13151)
2026-10-06 [email protected] [material_ui] Migrate
ListTile and SwitchListTile API doc snippets to {@example} (batch 10)
(flutter/packages#13097)
2026-10-06 [email protected] Sync release-cupertino_ui-1.1.2 to
main (flutter/packages#13150)
2026-10-06 [email protected]
[material_ui] Fix `TabBar` assertion to allow `indicatorWeight: 0` with
a themed `indicator` (flutter/packages#12696)
2026-10-06 [email protected] [material_ui] Fix time picker input
validation for 24-hour locales (flutter/packages#13033)
2026-10-06 [email protected] [material_ui] Migrate
Checkbox, CheckboxListTile, Radio, and RadioListTile API doc snippets to
{@example} (batch 9) (flutter/packages#13112)
2026-10-06 [email protected] [quick_actions_android] Return null from
getLaunchAction when no activity is attached (flutter/packages#12331)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
technobibi added a commit to technobibi/packages that referenced this pull request Oct 15, 2026
Resolves conflicts with flutter#12267, flutter#13079, and flutter#13224:

- Moves this change to 0.8.13+13, above main's 0.8.13+12 entry.
- Keeps main's removal of the kUTTypeGIF fallback in the GIF writer and
  this change's NULL destination check.
- Ports the two UIImagePickerController save-failure tests to the Swift
  plugin tests, using the PHImageManager seam instead of OCMock.
- Replaces the undecodable-data PHPicker test, which flutter#12267 now rejects
  earlier, with one that reaches the save failure through maxWidth 0.
- Drops the test bridging header, which main removed: the test subclass
  now replaces +temporaryFilePath: by selector, and the GIF destination
  test goes through the public save method.
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
flutter/packages@7660d46...54706bd

2026-10-08 [email protected] [image_picker_ios] Return an error
for undecodable image data (flutter/packages#12267)
2026-10-07 [email protected] [flutter shaders] update min flutter
version (flutter/packages#13160)
2026-10-07 [email protected] Import flutter_shaders package
(flutter/packages#12583)
2026-10-07 [email protected]
[material_ui] Migrate M3 Typography template to use new gen_defaults
(flutter/packages#13074)
2026-10-07 [email protected] Sync release-material_ui-1.6.0 to
main (flutter/packages#13149)
2026-10-07 [email protected] [pigeon] Fix native interop (JNI) calls
in minified Android release builds (flutter/packages#13151)
2026-10-06 [email protected] [material_ui] Migrate
ListTile and SwitchListTile API doc snippets to {@example} (batch 10)
(flutter/packages#13097)
2026-10-06 [email protected] Sync release-cupertino_ui-1.1.2 to
main (flutter/packages#13150)
2026-10-06 [email protected]
[material_ui] Fix `TabBar` assertion to allow `indicatorWeight: 0` with
a themed `indicator` (flutter/packages#12696)
2026-10-06 [email protected] [material_ui] Fix time picker input
validation for 24-hour locales (flutter/packages#13033)
2026-10-06 [email protected] [material_ui] Migrate
Checkbox, CheckboxListTile, Radio, and RadioListTile API doc snippets to
{@example} (batch 9) (flutter/packages#13112)
2026-10-06 [email protected] [quick_actions_android] Return null from
getLaunchAction when no activity is attached (flutter/packages#12331)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: image_picker platform-ios triage-ios Should be looked at in iOS triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[image_picker][iOS] Selecting an AVIF file on iOS causes indefinite loader and no response / crash

8 participants