-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[CP-stable][ Widget Preview ] Ignore modifications to files in ephemeral directories #178497
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
[CP-stable][ Widget Preview ] Ignore modifications to files in ephemeral directories #178497
Conversation
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
|
@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.
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 introduces a mechanism to ignore file modifications within ephemeral directories for the widget preview feature. This is achieved by adding a new ephemeralDirectories property to FlutterProject and using it in PreviewDetector to filter out file system events. The implementation also includes refactoring to pass the FlutterProject instance to PreviewDetector and adds a new regression test to verify the behavior.
My main feedback is on the implementation of the path checking logic in PreviewDetector, which could be made more robust by using path-aware comparison methods instead of simple string containment. This will prevent potential false positives where valid source files might be ignored.
7e4b2a4
into
flutter:flutter-3.38-candidate.0
…n ephemeral directories (flutter/flutter#178497)
…n ephemeral directories (flutter/flutter#178497)
…n ephemeral directories (flutter/flutter#178497)
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?
#178317
Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples
Running
flutter pub getcan crash the widget previewer when plugin dependencies are added or updated.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 crash when
flutter pub getis run and causes plugins to be updated or added to the project. IDEs regularly runflutter pub getand automatically start up the widget previewer, making this the top tool crasher for 3.38. Also, when an IDE-managed widget previewer crashes, it silently dies without any indication to the user as the preview environment continues to work but will no longer hot reload when the user makes changes to their sources.Workaround:
Is there a workaround for this issue?
flutter pub getRisk:
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 startin a Flutter projectpubspec.yamlflutter pub getin the project, which should not cause theflutter widget-preview startprocess to crash