Skip to content

[iOS] Split FlutterEngine setUpShell into orthogonal helpers - #192808

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
cbracken:refactor-setupshell
Sep 15, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
cbracken:refactor-setupshell

Conversation

@cbracken

@cbracken cbracken commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

-setUpShell:withVMServicePublication: did three things:

  • shell mechanics: taking ownership of the shell and building the two FlutterFMLTaskRunner wrappers
  • engine configuration: channels, locales, displays, the VM Service publisher, and the platform view channels
  • additional shell configuration: write GPU availability.

It turns out that after recent refactoring, we already set GPU availability during Shell construction, so the write was redundant and had no effect:

  • -createShell: passes _isGpuDisabled to Shell::Create, and the Shell constructor initialises the switch from it.
  • Shell::Spawn reads the spawning engine's switch and passes it to the spawned engine's constructor. -spawnWithEntrypoint: copies the spawning engine's _isGpuDisabled into the child engine. Both the engine flag and the switch will always match since they're both set in -setIsGpuDisabled:.

This deletes the GPU avaialability call and splits the reset into separate methods:

  • -adoptShell:
  • -configureForRunningShellWithVMServicePublication:

This is preparation for extracting the shell-ownership parts of FlutterEngine into a separate backend class.

This is a refactor with no behavioural change, covered by existing tests.

Issue: #112232

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 September 15, 2026 14:39
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 15, 2026
@flutter-dashboard

Copy link
Copy Markdown

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.

@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 Sep 15, 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 refactors the setUpShell:withVMServicePublication: method in FlutterEngine.mm by splitting its functionality into two helper methods: adoptShell: and configureForRunningShellWithVMServicePublication:. Feedback suggests adding an FML_DCHECK assertion in adoptShell: to verify that the shell parameter is not null before it is dereferenced, preventing potential crashes.

`-setUpShell:withVMServicePublication:` did three things:
* shell mechanics: taking ownership of the shell and building the two
  `FlutterFMLTaskRunner` wrappers
* engine configuration: channels, locales, displays, the VM Service
  publisher, and the platform view channels
* additional shell configuration: write GPU availability.

It turns out that after recent refactoring, we already set GPU
availability during Shell construction, so the write was redundant and
had no effect:
* `-createShell:` passes `_isGpuDisabled` to `Shell::Create`, and the
  `Shell` constructor initialises the switch from it.
* `Shell::Spawn` reads the spawning engine's switch and passes it to the
  spawned engine's constructor. `-spawnWithEntrypoint:` copies the
  spawning engine's `_isGpuDisabled` into the child engine. Both the engine
  flag and the switch will always match since they're both set in
  `-setIsGpuDisabled:`.

This deletes the GPU avaialability call and splits the reset into
separate methods:
* `-adoptShell:`
* `-configureForRunningShellWithVMServicePublication:`

This is preparation for extracting the shell-ownership parts of
`FlutterEngine` into a separate backend class.

This is a refactor with no behavioural change, covered by existing tests.

Issue: flutter#112232
@stuartmorgan-g

Copy link
Copy Markdown
Contributor

test-exempt: code refactor with no semantic change

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.

3 participants