[image_picker] Transparent pressing on iOS 26 (#173453)
Issue: On iOS, taps on the camera confirmation bar (“Use Photo” / “Retake”) were leaking through UIImagePickerController and dismissing underlying UI (e.g., bottom sheets) — a system touch-through regression reported on iOS 26 and some 18.x devices.
Same codebase, the following beharvious is on ios 18: https://github.com/user-attachments/assets/c3989a40-e6fd-4e2c-9053-3b0accea6f46
The following behavious is on ios 26: https://github.com/user-attachments/assets/71afd88f-39d7-4b4e-8faf-a736997604af
After comment out the line 525 (Navigator.of(context).pop();) to keep the dialog after taking image from camera, we could reproduce the issue in example.
From the video on ios 18, we can see the the dialog always there no matter we cancel, use photo or retake+cancel.
On ios 26, when we cancel, we can see the dialog is still there, but when we use photo or retake+cancel and then the camera screen dismiss animation finished, the dialog got dismissed. This behavious is different to ios 18 and this is because the tap pass through to flutter layout on outside of the dialog.
What I changed: In packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPlugin.m, when presenting the camera picker I now create a transparent, high-level UIWindow to absorb background touches and restore the previous key window once the picker finishes or is cancelled. This blocks taps pass through without altering Flutter-side UX.
Fixes: flutter/flutter#173453
Pre-Review Checklist
- [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [x] I read the [Tree Hygiene] page, which explains my responsibilities.
- [x] I read and followed the [relevant style guides] and ran [the auto-formatter].
- [x] I signed the [CLA].
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I linked to at least one issue that this PR fixes in the description above.
- [x] I updated
pubspec.yamlwith an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1]. - [x] I updated
CHANGELOG.mdto add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1]. - [x] I updated/added any relevant documentation (doc comments with
///). - [x] All existing and new tests are passing.
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.
If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?
Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.
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.
@hellohuanlin can you take a look at this one since it's platform view gesture leaking? https://github.com/flutter/flutter/issues/175099
cc @hellohuanlin please review again
Thanks for your contribution, @celvinren! You checked:
[x] I signed the [CLA].
However the bot can't find that you signed it: https://github.com/flutter/packages/pull/10533#issuecomment-3590702995. This PR won't be mergable until you sign the CLA: https://cla.developers.google.com
Thank you!
Thanks for your contribution, @celvinren! You checked:
[x] I signed the [CLA].
However the bot can't find that you signed it: #10533 (comment). This PR won't be mergable until you sign the CLA: https://cla.developers.google.com
Thank you!
@jmagman Thanks. Fixed.
could you also please add a test for your changes to prevent potential regressions?
@celvinren check out the tests on the example app: XCTests: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios/example/ios/RunnerTests XCUITests: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios/example/ios/RunnerUITests