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

[stable] [Flutter GPU] Add a project-level Flutter GPU setting to the Linux and Windows embedders - #190872

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bdero:bdero/cp-3.47-flutter-gpu-desktop-setting
Aug 18, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bdero:bdero/cp-3.47-flutter-gpu-desktop-setting

Conversation

@bdero

@bdero bdero commented Aug 10, 2026

Copy link
Copy Markdown
Member

Cherry-pick of #190684 (4ff86d444fb94c39c38111f4b9be649bb716dff7) onto flutter-3.47-candidate.0. It applies cleanly with no conflicts.

The 3.47.0 cherry-pick window is already closed, so this is a request to reopen the conversation rather than a routine cherry-pick. The reasoning is under "Why this is requested after the window closed" below, and I am happy to take a no.

Issue Link:

#190871

Why this is requested after the window closed:

This is an API addition rather than a regression fix, so it does not meet the usual bar. Three things make it worth asking about anyway.

Flutter GPU already has a permanent, project-level opt-in on every other platform (FLTEnableFlutterGPU in Info.plist on iOS and macOS, the EnableFlutterGPU manifest key on Android). Linux and Windows are the only platforms with no equivalent, so this closes a parity gap rather than adding new capability.

Release-mode desktop builds compile out GetSwitchesFromEnvironment (engine_switches.cc guards it with #ifndef FLUTTER_RELEASE), so --enable-flutter-gpu reaches the engine only under flutter run. Without a project-level setter there is no way at all to ship a released Linux or Windows app that uses package:flutter_gpu.

It landed on master on August 7, two days after flutter-3.48-candidate.0 branched on August 5, so it missed both this branch and the next beta branch. If it is not picked up here, the first beta carrying it is 3.49 and the first stable is roughly a quarter out.

Impacted Users:

Developers shipping Flutter desktop apps on Linux and Windows that use package:flutter_gpu, either directly or through a package built on top of it. Issue #167734 has been open since April 2025 with users repeatedly asking how to enable Flutter GPU on Windows, and the most recent comment describes exactly this case, that the command line flag works under flutter run but a packaged executable has no way to set it.

Impact Description:

Production apps on Linux and Windows cannot ship Flutter GPU at all. A release build throws on the first Flutter GPU call with "Flutter GPU must be enabled via the Flutter GPU manifest setting", and that message names only the iOS and Android opt-ins because the desktop ones did not exist. This does not affect development, since flutter run --enable-flutter-gpu works, which is what makes it easy to discover the problem only at packaging time.

Changelog Description:

[flutter/190871] Flutter GPU could not be enabled in release builds on Linux and Windows, since those embedders had no project-level opt-in and release builds ignore engine switches from the environment.

Workaround:

No practical one. Shipping the app in debug or profile mode is the only way to get the environment switches honored, and neither is shippable. The alternative is patching the embedder and building a custom engine.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

The change is additive and defaults to off. Both embedders append --enable-flutter-gpu only when the project setting is true, and skip it when an environment switch already carries it, so an app that does not opt in produces a byte-identical switch list. Nothing in the engine, Impeller, or the rendering path changes. The Linux side also hoists a repeated GetSwitchesFromEnvironment() call into a local, which is behavior neutral.

One caveat worth naming. A bool enable_flutter_gpu field is appended to FlutterDesktopEngineProperties in the public flutter_windows.h, which changes that struct's layout. The header and flutter_windows.dll ship together in the SDK artifact cache so they stay consistent, but it is a public C struct change, and once it ships in a stable the shape of the API is locked in.

Test Coverage:

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

  • Yes
  • No

Unit tests cover both embedders. On Linux, fl_dart_project_test.cc covers the getter, setter, and default, and fl_engine_test.cc covers switch forwarding and the environment switch deduplication. On Windows, dart_project_unittests.cc, flutter_project_bundle_unittests.cc, and flutter_windows_engine_unittests.cc cover the client wrapper, the project bundle, and the engine switch assembly.

Validation Steps:

  1. Create a Flutter app that calls into package:flutter_gpu and run it in release mode on Linux or Windows without the new setting. Confirm it throws "Flutter GPU must be enabled via the Flutter GPU manifest setting".
  2. On Linux, add fl_dart_project_set_enable_flutter_gpu(project, TRUE); in linux/runner/my_application.cc. On Windows, add project.set_enable_flutter_gpu(true); in windows/runner/main.cpp.
  3. Build in release mode and launch the packaged binary directly rather than through flutter run. Confirm Flutter GPU initializes and renders.
  4. Confirm an app that does not set the flag behaves exactly as before.
  5. Run the Linux and Windows embedder unit tests.

Pre-launch Checklist

…d Windows embedders (flutter#190684)

Adds `fl_dart_project_set_enable_flutter_gpu` (Linux) and
`DartProject::set_enable_flutter_gpu` (Windows), forwarding
`--enable-flutter-gpu` to the engine the same way the existing
project-level Impeller settings do. Release desktop builds ignore engine
switches from the environment, so this is the only way a released app on
these platforms can enable Flutter GPU, matching the permanent opt-ins
the other platforms already have (`FLTEnableFlutterGPU` in Info.plist on
iOS and macOS, the `EnableFlutterGPU` manifest flag on Android).

## 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].
- [ ] 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.
- [ ] All existing and new tests are passing.

<!-- 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/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md

(cherry picked from commit 4ff86d4)
@bdero
bdero requested review from a team as code owners August 10, 2026 20:00
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 10, 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.

@bdero bdero added cp: review Cherry-picks in the review queue engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically platform-windows Building on or for Windows specifically a: desktop Running on desktop labels Aug 10, 2026
@github-actions github-actions Bot added team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Aug 10, 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 adds programmatic support for enabling the Flutter GPU API on both Linux and Windows platforms by introducing configuration fields, getters, setters, and command-line argument forwarding, along with corresponding unit tests. Feedback points out that adding the enable_flutter_gpu field to the public FlutterDesktopEngineProperties struct on Windows is an ABI-breaking change because the struct is client-allocated and lacks a size or version field, which could lead to out-of-bounds reads or crashes.

Comment thread engine/src/flutter/shell/platform/windows/public/flutter_windows.h

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Windows / Linux changes LGTM from technical standpoint

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

One sanity check that I punted to Loic, but looks good overall

Comment thread engine/src/flutter/shell/platform/windows/public/flutter_windows.h
@bdero

bdero commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Alrighty, thanks for the reviews. Is there any other action I should take here in order to help shepherd this into 3.47.1? It's been quite a while since I've last participated in the stable cherry-pick process. :P

@loic-sharma

loic-sharma commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

@bdero It's in the cherrypick queue, so the release engineer should pick this up when they start the 3.47.1 release :)

See: https://github.com/flutter/flutter/blob/master/docs/releases/Flutter-Cherrypick-Process.md#lifecycle-of-a-cherry-pick

@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2026
@auto-submit
auto-submit Bot merged commit 0c94720 into flutter:flutter-3.47-candidate.0 Aug 18, 2026
13 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-linux Building on or for Linux specifically platform-windows Building on or for Windows specifically team-linux Owned by the Linux platform team team-windows Owned by the Windows platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants