[CP-stable][ Widget Preview ] Pass DTD URI as a constant in a generated file#179887
Conversation
…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
|
@bkonyi please fill out the PR description above, afterwards the release team will review this request. |
|
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. |
There was a problem hiding this comment.
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.
8ea0615
into
flutter:flutter-3.38-candidate.0
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 startcreates 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?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
flutter widget-preview start --verbosewidget_preview_scaffoldin $TMPcache.dill.track.dillunderbuild/. If there's a file of the form32637b821e3cedec3d78f27cf3f3bc35.cache.dill.track.dill, this fix wasn't successful.