Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Nov 24, 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?

#175058

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 can crash if flutter clean is run while the widget previewer is running.

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)

The widget previewer can silently crash in IDEs if the user runs flutter clean on the project. There's no indication that the previewer has crashed other than the fact that the previewer no longer hot reloads when the user make changes to their previews.

Workaround:

Is there a workaround for this issue?

Not running flutter clean while the widget previewer is running, or restarting the IDE after flutter clean is run.

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
  2. Run flutter clean and verify the flutter widget-preview start process doesn't crash.

Since `flutter clean` can delete the `.dart_tool/` directory while a
`flutter widget-preview start` command is active, it's possible for the
`widget_preview_scaffold` to be deleted and cause the preview process to
crash.

This change works around this issue by always generating the
`widget_preview_scaffold` project under $TMP on each invocation of the
previewer. This doesn't result in much of a regression in startup times
as we currently aren't launching the previewer using restored state as
this isn't currently possible with the web device targets. Moving the
scaffold under $TMP means Flutter tooling will never accidentally delete
the scaffold while the previewer is running.

Filed #179036 to track
reverting this behavior when a better solution is found.

Fixes #175058
@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 Nov 24, 2025
@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Nov 24, 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 fixes a crash in the widget previewer when flutter clean is run. The fix involves moving the widget preview scaffold project from the project's .dart_tool directory to a system temporary directory, which isolates it from flutter clean. Consequently, several related changes were made to handle absolute paths for assets and project dependencies, and tests were updated accordingly, including a new regression test for the original issue. My review found that this change inadvertently breaks the widget-preview clean command, which no longer cleans up the correct directory. Given that the temporary directory is now auto-cleaned on process exit, the clean command might be obsolete or need a redesign.

@bkonyi bkonyi changed the title [ Widget Preview ] Always generate scaffold under $TMP (#179039) [ CP-Stable ][ Widget Preview ] Always generate scaffold under $TMP (#179039) Nov 25, 2025
@bkonyi bkonyi changed the title [ CP-Stable ][ Widget Preview ] Always generate scaffold under $TMP (#179039) [CP-stable][ Widget Preview ] Always generate scaffold under $TMP (#179039) Nov 25, 2025
bkonyi and others added 4 commits December 2, 2025 13:43
Refactor widget preview test to ensure proper handling of package_config.json and simulate interrupted flutter widget-preview start.
@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 2, 2025
@auto-submit auto-submit bot merged commit 1a5911b into flutter-3.38-candidate.0 Dec 2, 2025
146 checks passed
@auto-submit auto-submit bot deleted the cp_179039 branch December 2, 2025 23:27
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 5, 2025
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.

2 participants