Skip to content

[CP-beta]Fix sdfs being enabled for MacOS regardless of FLTEnableSDFs value#185680

Merged
auto-submit[bot] merged 3 commits into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-beta-b457aa44c48e2a6336a7a6b77b350cb3996ca433
Apr 28, 2026
Merged

[CP-beta]Fix sdfs being enabled for MacOS regardless of FLTEnableSDFs value#185680
auto-submit[bot] merged 3 commits into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-beta-b457aa44c48e2a6336a7a6b77b350cb3996ca433

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#185562

Impact Description:

All MacOS apps using Impeller inadvertently have SDF rendering enabled. SDF rendering is only partially implemented and was intended to be behind a default-false flag. These users will experience rendering artifacts when certain shapes are rendered.

Changelog Description:

Explain this cherry pick:

  • In one line that is accessible to most Flutter developers.
  • That describes the state prior to the fix.
  • That includes which platforms are impacted.
    See best practices for examples.

< Replace with changelog description here >
[flutter/185562] When Impeller is enabled on MacOS, SDF rendering is unintentionally enabled

Workaround:

If the app does not require Impeller, building it for MacOS with Impeller disabled will work around this issue.

If the app requires Impeller, then there is no workaround.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

What are the steps to validate that this fix works?

Building and running an app with "flutter run" for MacOS should show the debug message "Using the Impeller rendering backend (Metal)" rather than "Using the Impeller rendering backend (MetalSDF)".

…lutter#185565)

This changes the `_project.enableSDFs` check in the MacOS
FlutterEngine.mm to be the same as the checks for
`_project.enableImpeller` and `_project.enableFlutterGPU` next to it.

Instead of setting `--impeller-use-sdfs=true` or
`--impeller-use-sdfs=false` depending on `_project.enableSDFs`, only set
`--impeller-use-sdfs=true` for true, and leave the flag out when it is
false.

The flag is checked by

https://github.com/flutter/flutter/blob/d3757dafb0f28934fe2312fd3d50a721b03bfd8b/engine/src/flutter/shell/common/switches.cc#L553-L560
which uses `command_line.HasOption()`. This checks only for the
existence of the flag. The value of the flag (true or false) is entirely
ignored. So this would enable SDFs whether we passed in
`--impeller-use-sdfs=true` or `--impeller-use-sdfs=false`.

If we actually wanted to check the value of the flag, we should use
`CommandLine::GetOptionValue()` or
`CommandLine::GetOptionValueWithDefault()` instead. It's misleading to
pass the flag with a true/false value that is ignored and make the
switch get set to true for either one. For consistency with the other
flag's I'm leaving this behavior as-is.

Also for consistency with the other flags, I'm leaving the `||
std::find(switches.begin(), switches.end(), "--impeller-use-sdfs=true")
!= switches.end()` check. But this check seems completely
redundant/useless to me.

Fixes flutter#185562


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@flutteractionsbot flutteractionsbot requested a review from a team as a code owner April 28, 2026 15:12
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Apr 28, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@b-luk please fill out the PR description above, afterwards the release team will review this request.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically a: desktop Running on desktop team-macos Owned by the macOS platform team labels Apr 28, 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 introduces a new devicelab test for Impeller SDFS on macOS and updates the macOS engine to handle the --impeller-use-sdfs flag. The review feedback identifies naming inconsistencies in .ci.yaml and TESTOWNERS where the task name and file path do not match the actual filename of the newly created test script, which would lead to CI execution failures.

Comment thread .ci.yaml Outdated
Comment thread TESTOWNERS Outdated
gaaclarke
gaaclarke previously approved these changes Apr 28, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Apr 28, 2026

@camsim99 camsim99 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.

@b-luk I think the Gemini bot is right. I don't think that the devicelab test is currently running: https://ci.chromium.org/ui/p/flutter/builders/luci.flutter.staging/Mac%20hello_world_impeller_macos_sdfs. You'll need to fix this on master too.

@b-luk

b-luk commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

@b-luk I think the Gemini bot is right. I don't think that the devicelab test is currently running: https://ci.chromium.org/ui/p/flutter/builders/luci.flutter.staging/Mac%20hello_world_impeller_macos_sdfs. You'll need to fix this on master too.

There's a fix for this on master that's currently in the merge queue: #185681

What's the guideline for what to do about this in this release branch?

  • Should I manually update this PR to include this fix? Or would this potentially cause merge issues later?
  • Or should I wait until the fix is in master and do a second cherrypick request for the fix?
  • Or is it not an issue that this test doesn't run properly for the release branch, as long as it's running and passing on master?

@gaaclarke gaaclarke requested a review from camsim99 April 28, 2026 17:53
@camsim99

Copy link
Copy Markdown
Contributor

There's a fix for this on master that's currently in the merge queue: #185681

What's the guideline for what to do about this in this release branch?

Ok great! Since the fix is straightforward and the cherry-pick seems low risk, I think it's fine to just update this PR and then we can land it. I'll make sure not to publish the release until the fix lands in master and the test successfully runs.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@b-luk

b-luk commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

/gemini review

@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 adds a new macOS device lab test for Impeller Signed Distance Fields (SDFs) and updates the macOS engine to handle the --impeller-use-sdfs flag. A filename mismatch was identified in the TESTOWNERS file, where the entry incorrectly references an iOS test instead of the new macOS test file.

Comment thread TESTOWNERS Outdated
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 28, 2026
@b-luk

b-luk commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

/gemini review

@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 introduces a new device lab test to verify Impeller's Signed Distance Field (SDF) support on macOS and updates the engine to handle the --impeller-use-sdfs flag. Feedback includes a recommendation to improve the robustness of the Info.plist XML parsing in the test and a suggestion to prevent duplicate command-line switches in the engine initialization logic.

// Step 2: Modify Info.plist to enable SDFS
final String xmlStr = plistFile.readAsStringSync();
final xmlDoc = XmlDocument.parse(xmlStr);
final XmlElement dictNode = xmlDoc.findAllElements('dict').first;

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.

medium

Using findAllElements('dict').first to find the root dictionary in Info.plist might be fragile if the file contains nested dictionaries (e.g., within other keys). While it works for the current hello_world example, a more robust approach would be to target the root dictionary specifically.

Comment on lines +681 to +684
if (_project.enableSDFs ||
std::find(switches.begin(), switches.end(), "--impeller-use-sdfs=true") != switches.end()) {
switches.push_back("--impeller-use-sdfs=true");
}

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.

medium

The logic for adding the --impeller-use-sdfs=true switch will result in duplicate entries in the switches vector if the flag is already present. While the engine typically handles duplicate flags by taking the last one, it would be cleaner to only append the switch if it's not already present or if the project setting needs to override a previous value.

  if (_project.enableSDFs) {
    switches.push_back("--impeller-use-sdfs=true");
  } else if (std::find(switches.begin(), switches.end(), "--impeller-use-sdfs=true") != switches.end()) {
    // The flag is already present in switches, no need to add it again.
  }

@b-luk

b-luk commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

@camsim99

Copy link
Copy Markdown
Contributor

Great, thanks for the heads up! Let's land this :)

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2026
@auto-submit auto-submit Bot merged commit 6229ad2 into flutter:flutter-3.44-candidate.0 Apr 28, 2026
175 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically team-macos Owned by the macOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants