Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Replaces the code that attempted to find the topmost presented view controller as the context for presenting a Safari view controller with a call to the new registrar API to get the Flutter view's controller.

Since it's now possible for there not to be a view controller, adds an exception for that case. This should only be possible in an add-to-app scenario where someone tries to show an in-app URL from a Flutter view that is not being displayed, which is an unlikely enough scenario that I'm not going to consider this a breaking change.

Fixes flutter/flutter#174415

Pre-Review Checklist

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 3

Replaces the code that attempted to find the topmost presented view
controller as the context for presenting a Safari view controller with
a call to the new registrar API to get the Flutter view's controller.

Since it's now possible for there not to be a view controller, adds
an exception for that case. This should only be possible in an
add-to-app scenario where someone tries to show an in-app URL from a
Flutter view that is not being displayed, which is an unlikely enough
scenario that I'm not going to consider this a breaking change.

Fixes flutter/flutter#174415
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is copied directly from the recent file_selector_ios PR to adopt UIScene, since we have the same DI needs here.

/// a stub implementation of FlutterPluginRegistrar for tests would break any time something was
/// added to that protocol.
protocol ViewPresenterProvider {
/// Returns the view controller associated with the Flutter content.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Returns the view presenter [...]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

private var currentSession: URLLaunchSession?
private let launcher: Launcher
/// The view controller provider, for showing a Safari view controller.
private let viewPresenterProvider: ViewPresenterProvider
Copy link
Contributor

Choose a reason for hiding this comment

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

The view controller provider

Should we call this a ViewControllerPresenterProvider then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to "The view presenter provider". Because it's just a testability abstraction around a view controller it was hard not to default to calling it a view controller.

}
}

final class StubViewPresenterProvider: ViewPresenterProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we use the same prefix "Test-" above and "Stub-" here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They don't do the same things; StubViewPresenterProvider is a stub, in that it just returns a fixed value, while TestViewPresenter tracks calls and updates its state (more like a mock).

@@ -1,3 +1,8 @@
## 6.4.0

* Improves compatibility with `UIScene`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This refers to the removal of UIApplication.shared.keyWindow?.rootViewController?.topViewController right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, that's the substantive change here; the rest is testability.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 3, 2025
@auto-submit auto-submit bot merged commit 0b3a6b4 into flutter:main Dec 3, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Dec 4, 2025
flutter/packages@8cb4903...d39e481

2025-12-04 10687576+bparrishMines@users.noreply.github.com [pigeon]
Fixes crash that occurs when an object that is removed from the instance
manager calls to Dart (flutter/packages#10552)
2025-12-04 10687576+bparrishMines@users.noreply.github.com [pigeon]
Fixes error from constructor parameter sharing name with attached field
for a ProxyApi (flutter/packages#10541)
2025-12-04 okorohelijah@google.com fix[image_picker_ios]: Prevent
transcoding on video selection (flutter/packages#10559)
2025-12-04 10687576+bparrishMines@users.noreply.github.com
[webview_flutter_wkwebview] Fixes crash when running
`WKNavigationResponse` tests on Xcode 26 (flutter/packages#10316)
2025-12-03 15619084+vashworth@users.noreply.github.com Redistribute iOS
CODEOWNERS (flutter/packages#10520)
2025-12-03 stuartmorgan@google.com [url_launcher] Update for UIScene
compatibility (flutter/packages#10549)
2025-12-03 engine-flutter-autoroll@skia.org Roll Flutter from
e274574 to 69d8710 (5 revisions) (flutter/packages#10558)
2025-12-03 engine-flutter-autoroll@skia.org Roll Flutter from
5545bb3 to e274574 (17 revisions) (flutter/packages#10554)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com 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 p: url_launcher platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[url_launcher_ios][UIScene] Migrate to scene APIs

2 participants