Repository navigation
iOS: Migrate the unit test host app to UIScene - #190646
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
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
force-pushed
the
migrate-tests-to-uiscene
branch
from
August 6, 2026 09:42
f486ea4 to
80bdc9d
Compare
LongCatIsLooong
approved these changes
Aug 6, 2026
This was referenced Aug 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Apps that haven't adopted the UIScene life cycle will not launch on iOS
27. The
IosUnitTestshost app was still using the pre-sceneUIApplicationMainplusUIMainStoryboardFilesetup, and failed withwhen run with on an iOS 27 simulator.
This adds a
UIApplicationSceneManifestto the host app'sInfo.plistand aSceneDelegate.Migrating to scenes changes a couple things the tests were relying on.
FlutterSharedApplication.hasSceneDelegatenow returnsYESin the host app, which suppresses forwarding of app lifecycle notifications to plugins. TheFlutterPluginAppLifeCycleDelegatetests covering the pre-migration case stub this back out toNO.[[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 withinitWithWindowScene:instead. Without this we trip anFML_DCHECK(self.screen)inFlutterView 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-assistbot 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.