Sitelet https://github.com/flutter/flutter/pull/190646
Skip to content

iOS: Migrate the unit test host app to UIScene - #190646

Merged
cbracken merged 2 commits into
flutter:masterfrom
cbracken:migrate-tests-to-uiscene
Aug 6, 2026
Merged

cbracken merged 2 commits into
flutter:masterfrom
cbracken:migrate-tests-to-uiscene

Conversation

@cbracken

@cbracken cbracken commented Aug 6, 2026

Copy link
Copy Markdown
Member

Apps that haven't adopted the UIScene life cycle will not launch on iOS
27. The IosUnitTests host app was still using the pre-scene UIApplicationMain plus UIMainStoryboardFile setup, and failed with

"Early unexpected exit ... The test runner crashed before establishing connection"

when run with on an iOS 27 simulator.

This adds a UIApplicationSceneManifest to the host app's Info.plist and a SceneDelegate.

Migrating to scenes changes a couple things the tests were relying on. FlutterSharedApplication.hasSceneDelegate now returns YES in the host app, which suppresses forwarding of app lifecycle notifications to plugins. The FlutterPluginAppLifeCycleDelegate tests covering the pre-migration case stub this back out to NO.

[[UIWindow alloc] init] no longer picks up a window scene so the window no longer has a screen. There were a few tests that need a screen, which now build their window with initWithWindowScene: instead. Without this we trip an FML_DCHECK(self.screen) in FlutterView isWideGamutSupported]. I'll send a followup to handle this more gracefully.

Issue: #188336

Pre-launch Checklist

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

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

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.

@cbracken
cbracken requested a review from a team as a code owner August 6, 2026 07:48
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 6, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team labels Aug 6, 2026

@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 configures the iOS unit tests to support the UIScene lifecycle by introducing a SceneDelegate, updating Info.plist, and modifying window initializations to use the connected window scene. The review feedback recommends explicitly stopping class mocks in FlutterPluginAppLifeCycleDelegateTest to prevent test pollution, and adding non-nil assertions for the retrieved window scenes in FlutterViewControllerTest and FlutterViewTest to avoid cryptic test failures.

Comment thread engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm Outdated
Apps that haven't adopted the UIScene life cycle will not launch on iOS
27. The `IosUnitTests` host app was still using the pre-scene
`UIApplicationMain` plus `UIMainStoryboardFile` setup, and
failed with

    "Early unexpected exit ... The test runner crashed before establishing connection"

when run with on an iOS 27 simulator.

This adds a `UIApplicationSceneManifest` to the host app's `Info.plist`
and a `SceneDelegate`.

Migrating to scenes changes a couple things the tests were relying on.
`FlutterSharedApplication.hasSceneDelegate` now returns `YES` in the
host app, which suppresses forwarding of app lifecycle notifications to
plugins. The `FlutterPluginAppLifeCycleDelegate` tests covering the
pre-migration case stub this back out to `NO`.

`[[UIWindow alloc] init]` no longer picks up a window scene so the
window no longer has a screen. There were a few tests that need a
screen, which now build their window with `initWithWindowScene:`
instead. Without this we trip an `FML_DCHECK(self.screen)` in
`FlutterView isWideGamutSupported]`. I'll send a followup to handle this
more gracefully.

Issue: flutter#188336
The tests that build their own window now assert that the host app has a
connected scene before using it. Passing a nil scene to
`initWithWindowScene:` produces a window with no screen. This shows up
as either an `FML_DCHECK(self.screen)` abort or an unexplained missing
`surfaceUpdated:` call rather than pointing at the missing scene.
@cbracken
cbracken force-pushed the migrate-tests-to-uiscene branch from f486ea4 to 80bdc9d Compare August 6, 2026 09:42
@cbracken
cbracken added this pull request to the merge queue Aug 6, 2026
Merged via the queue into flutter:master with commit d38554a Aug 6, 2026
16 of 17 checks passed
@cbracken
cbracken deleted the migrate-tests-to-uiscene branch August 6, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants