-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[ Widget Preview ] Always generate scaffold under $TMP
#179039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
There was a problem hiding this 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 moves the widget preview scaffold to a temporary directory to prevent it from being deleted by flutter clean. This is a solid approach to resolve the issue. The related changes to use absolute paths for dependencies and assets are also correct and necessary. However, the current implementation for creating the temporary directory will lead to orphaned directories on the user's system, as the clean command won't be able to find the directory created by the start command. I've included a review comment with a suggested fix to use a predictable directory name. Other changes, like updating imports to be package-relative and refactoring static methods, are good improvements.
jyameo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
|
Failed to create CP due to merge conflicts. |
1 similar comment
|
Failed to create CP due to merge conflicts. |
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
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/flutter@3f553f6...7b98d50 2025-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fix for win32 embedder failing to send all alt key downs to the flutter app (#179097)" (flutter/flutter#179136) 2025-11-26 [email protected] Fix for win32 embedder failing to send all alt key downs to the flutter app (flutter/flutter#179097) 2025-11-26 [email protected] Modernize framework lints (flutter/flutter#179089) 2025-11-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add framework-side hitTestBehavior support to Semantics (#178817)" (flutter/flutter#179100) 2025-11-25 [email protected] Add framework-side hitTestBehavior support to Semantics (flutter/flutter#178817) 2025-11-25 [email protected] Roll Packages from e019cf9 to cc3dca6 (1 revision) (flutter/flutter#179081) 2025-11-25 [email protected] Add tooltip windows to the windowing API alongside the window positioning logic (flutter/flutter#177404) 2025-11-25 [email protected] FlutterWindowsView::SendWindowMetrics now reliably sends the display_id (flutter/flutter#179053) 2025-11-25 [email protected] Remove semantics geometry shortcircuit (flutter/flutter#178680) 2025-11-25 [email protected] Add an assert message when OverlayEntry.remove is called twice (flutter/flutter#178163) 2025-11-25 [email protected] Roll Fuchsia Linux SDK from pOO9Jl9HTLsEmks6y... to nzuAxCJGeJbkZCTkr... (flutter/flutter#179066) 2025-11-25 [email protected] Dynamically set MinimumOSVersion in App.framework (flutter/flutter#178253) 2025-11-25 [email protected] Roll Skia from d83c30b090f4 to 925c311f4b37 (2 revisions) (flutter/flutter#179060) 2025-11-25 [email protected] Marks Linux build_android_host_app_with_module_aar to be unflaky (flutter/flutter#174864) 2025-11-25 [email protected] Marks Linux_mokey complex_layout__start_up to be unflaky (flutter/flutter#174865) 2025-11-25 [email protected] Manual Dart SDK roll to 3.11.0-169.0.dev (flutter/flutter#179054) 2025-11-25 [email protected] Bump Dart to 3.9 (flutter/flutter#179041) 2025-11-25 [email protected] Roll Skia from e298c2f93ebf to d83c30b090f4 (2 revisions) (flutter/flutter#179058) 2025-11-24 [email protected] updated licenses_cpp readme (flutter/flutter#178874) 2025-11-24 [email protected] Roll Skia from 43d2020be565 to e298c2f93ebf (5 revisions) (flutter/flutter#179046) 2025-11-24 [email protected] Refactor `_isLabel` method in `stepper.dart` to use `any` for better readablity (flutter/flutter#178909) 2025-11-24 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 5 to 6 in the all-github-actions group (flutter/flutter#179049) 2025-11-24 [email protected] Disposes test restoration manager when accessed by bindings (flutter/flutter#176519) 2025-11-24 [email protected] [ Widget Preview ] Always generate scaffold under `$TMP` (flutter/flutter#179039) 2025-11-24 [email protected] Roll Packages from e67b6be to e019cf9 (9 revisions) (flutter/flutter#179035) 2025-11-24 [email protected] Update CHANGELOG.md for Flutter 3.38.3 (flutter/flutter#178935) 2025-11-24 [email protected] Remove unnecessary `String.valueOf` in `SettingsChannel.java` (flutter/flutter#178590) 2025-11-24 [email protected] Roll pub manually, pick up flutter_lints in examples/api (flutter/flutter#179030) 2025-11-24 [email protected] Roll Dart SDK from 24cc9a740bd3 to afca43095efa (1 revision) (flutter/flutter#179019) 2025-11-24 [email protected] Pass EXCLUDED_ARCHS from Xcode project to xcodebuild for macOS builds (flutter/flutter#176948) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
) 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 flutter#179036 to track reverting this behavior when a better solution is found. Fixes flutter#175058
…179039) (#179050) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) 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](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) 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? ### 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? 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 flutter#179036 to track reverting this behavior when a better solution is found. Fixes flutter#175058
Since
flutter cleancan delete the.dart_tool/directory while aflutter widget-preview startcommand is active, it's possible for thewidget_preview_scaffoldto be deleted and cause the preview process to crash.This change works around this issue by always generating the
widget_preview_scaffoldproject 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