Skip to content

[stable] [flutter_tools] Report preview reload timing analytics in LspPreviewDetector - #192256

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-192120-to-stable
Sep 9, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-192120-to-stable

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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:

#192120

Impact Description:

In Flutter 3.44 (#184473), LspPreviewDetector became the default preview detector, but did not instrument preview reload timing analytics (previewAnalytics.startPreviewReloadStopwatch() and previewAnalytics.reportPreviewReloadTiming()). This caused a severe drop in reported preview-reload-time telemetry events for the widget previewer. This cherry-pick restores reporting of reload timing metrics and filters out non-Dart file edits to avoid spurious reload timing events.

Changelog Description:

[flutter/192120] Fixes missing preview reload timing analytics in LspPreviewDetector across all platforms.

Workaround:

None. Telemetry for widget preview reload timing is omitted unless instrumented.

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:

Run packages/flutter_tools unit tests:
dart test test/commands.shard/hermetic/widget_preview/lsp_preview_detector_test.dart

…etector (flutter#192120)

In Flutter 3.44
([flutter#184473](flutter#184473)),
`LspPreviewDetector` became the default preview detector, but did not
instrument `previewAnalytics.startPreviewReloadStopwatch()` or
`previewAnalytics.reportPreviewReloadTiming()`. This caused a severe
drop in reported `preview-reload-time` telemetry events.

This change instruments `LspPreviewDetector` to start the reload
stopwatch on file changes, report reload timings after change detection
completes, and reset the stopwatch on errors. Non-Dart file edits are
also filtered out to avoid unnecessary reload events.

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Sep 3, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 3, 2026
@flutter-dashboard

Copy link
Copy Markdown

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 Sep 3, 2026

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

Copy link
Copy Markdown
Contributor

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 file type filtering to ignore non-Dart files and adds stopwatch-based analytics timing for preview reloads in LspPreviewDetector. It also includes a comprehensive unit test suite to verify these changes. The review feedback points out a redundant and unreachable return; statement after a rethrow; inside the catch block of LspPreviewDetector.

@walley892

Copy link
Copy Markdown
Contributor

@bkonyi, same here :)

@bkonyi
bkonyi requested a review from srawlins September 9, 2026 18:39

@srawlins srawlins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test!

@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 9, 2026
@auto-submit
auto-submit Bot merged commit 4c685f8 into flutter:flutter-3.47-candidate.0 Sep 9, 2026
12 checks passed
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 CICD Run CI/CD 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