-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[image_picker] Transparent pressing on iOS 26 (#173453) #10533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
celvinren
wants to merge
2
commits into
flutter:main
Choose a base branch
from
celvinren:image_picker-transparent-pressing-on-iOS-26-#173453
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,11 @@ name: image_picker_ios | |
| description: iOS implementation of the image_picker plugin. | ||
| repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios | ||
| issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 | ||
| version: 0.8.13+4 | ||
| version: 0.8.13+5 | ||
|
|
||
| environment: | ||
| sdk: ^3.10.0 | ||
| flutter: ">=3.38.0" | ||
| sdk: ^3.9.0 | ||
| flutter: ">=3.35.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why the version downgrade is needed? |
||
|
|
||
| flutter: | ||
| plugin: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a
windowrather than just a view to block the touchesUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @hellohuanlin
We’re using a separate UIWindow instead of dropping a view in the Flutter hierarchy to make the touch blocker reliable:
Flutter’s UI lives in a UIWindow managed by FlutterViewController; UIImagePickerController is presented modally in that same window, layered above Flutter. When dismissing (e.g., Retake/Use Photo), the picker’s view is animating away, and stray taps can leak to the Flutter view underneath.
A view-based blocker (hitTest) would have to be inserted into the host view tree (e.g., FlutterViewController.view), inheriting its bounds/constraints/rotation and any transitions. During modal animations, size/position changes, or if the parent is re-laid out/replaced, the blocker can shift or get removed, letting touches through.
A dedicated UIWindow sits above the presenting window (windowLevel + 1), with its own root VC to swallow touches, and doesn’t depend on the host view hierarchy or transitions. We just restore the previous key window after dismiss, making it less invasive and more reliable for the short dismissal window.
The following 2 screenshots are using view and image picker will replace the flutter view controller. The first one shows we are in flutter view controller, the second one shows when we trigger the camera page from flutter, the flutter view become invisible and image picker takes place all the view.


The following is using a window for camera

In the first 2 hierarchy snapshots, the picker is full screen, so the Flutter view is temporarily out of the visible view tree. In the third snapshot, both the picker stack and FlutterViewController appear under the same key UIWindow, showing they share one window for event delivery. That’s why a blocker tied to the host view can shift or disappear during the modal transition, while a separate window stays put and reliably swallows taps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the detailed reply! for the benefit of future engineers looking at this code, do you think you could at a shortened version of ^ as a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@celvinren is the picker vc presented full screen modally? I assume that's why the flutter view is removed from the view hierarchy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hellohuanlin
Yes. UIImagePickerController is presented full-screen modally by the system.
When the picker is active, it temporarily replaces FlutterViewController’s view
in the view hierarchy during the transition. That’s why a view-based hitTest
blocker is unreliable, and why a separate UIWindow is used to consistently
absorb touches during dismissal animations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. @LouiseHsu is right that we should add some comments for future reference.