Skip to content

[CP-stable][ Widget Preview ] Pass DTD URI as a constant in a generated file#179887

Merged
auto-submit[bot] merged 1 commit intoflutter:flutter-3.38-candidate.0from
flutteractionsbot:cp-stable-a78aefa9bc74101e75be223d2c9cff0a02c64dbe
Dec 16, 2025
Merged

[CP-stable][ Widget Preview ] Pass DTD URI as a constant in a generated file#179887
auto-submit[bot] merged 1 commit intoflutter:flutter-3.38-candidate.0from
flutteractionsbot:cp-stable-a78aefa9bc74101e75be223d2c9cff0a02c64dbe

Conversation

@flutteractionsbot
Copy link

@flutteractionsbot flutteractionsbot commented Dec 15, 2025

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:

What is the link to the issue this cherry-pick is addressing?

#179139

Changelog Description:

Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples

flutter widget-preview start creates new cached build artifacts on each run, resulting in increasing disk usage after each run.

Impact Description:

What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

This can result in disk usage slowly creeping up ~50 MiB for each execution of flutter widget-preview start. A reboot will currently clear this build artifacts on MacOS and Linux, but not on Windows.

Workaround:

Is there a workaround for this issue?

Reboot on MacOS / Linux, clear temporary files manually on Windows.

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?

  1. Run flutter widget-preview start --verbose
  2. Find the location of the generated widget_preview_scaffold in $TMP
  3. Check that there's only a cache.dill.track.dill under build/. If there's a file of the form 32637b821e3cedec3d78f27cf3f3bc35.cache.dill.track.dill, this fix wasn't successful.

…utter#179821)

Passing the DTD URI via a Dart define results in a new
`<hash>.cache.dill.track.dill` being created on each run as the DTD URI
is never the same and the `cache.dill.track.dill` hash is partly based
on the set of Dart defines. These files are not cleaned up
automatically, so they could take up a significant amount of memory over
time.

This change adds an additional code generation step to the widget
previewer which populates
`widget_preview_scaffold/lib/src/dtd/dtd_connection_info.dart` with a
constant containing the DTD URI provided by the tool.

Fixes flutter#179139
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Dec 15, 2025
@flutteractionsbot
Copy link
Author

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

@flutter-dashboard
Copy link

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.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 how the Dart Tooling Daemon (DTD) URI is communicated to the widget preview scaffold. Instead of passing the DTD URI as a Dart define during the build process, the WidgetPreviewStartCommand now uses a new populateDtdConnectionInfo method in PreviewCodeGenerator to dynamically generate a dtd_connection_info.dart file. This generated file contains the DTD URI as a constant string. The dtd_services.dart in the widget preview scaffold is updated to import and read the DTD URI from this new file, replacing the previous reliance on an environment variable. The changes include adding a new template file for dtd_connection_info.dart, updating the template manifest, and modifying relevant test cases to reflect this new mechanism.

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 16, 2025
@auto-submit auto-submit bot merged commit 8ea0615 into flutter:flutter-3.38-candidate.0 Dec 16, 2025
140 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
This was referenced Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants