Skip to content

[stable] [tool] Fix Windows hot reload mtime truncation issue - #191599

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-c6b98166f1a43251e38ba287c08978d5e7f3a52a
Aug 24, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-c6b98166f1a43251e38ba287c08978d5e7f3a52a

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Issue Link:

#191198

Impact Description:

On Windows, file modification timestamps (mtime) reported by dart:io are truncated to whole-second precision. When files are edited rapidly (e.g. IDE format/save on change or quick successive edits within the same wall-clock second as the previous compilation), ProjectFileInvalidator.findInvalidated compares milliseconds against truncated seconds and falsely concludes that zero files have changed. Hot reload/restart silently skips compiling the changes, leaving running apps on stale code.

Changelog Description:

[flutter/191198] On Windows, truncate lastCompiled timestamp to whole seconds in ProjectFileInvalidator so rapid consecutive file modifications within the same second are not silently ignored by hot reload.

Workaround:

Wait at least 1-2 seconds after saving before triggering hot reload or hot restart.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

  1. On Windows, run a Flutter app with flutter run.
  2. Save a change to lib/main.dart and trigger hot reload.
  3. Immediately edit lib/main.dart again within < 1 second and trigger hot reload.
  4. Verify that Flutter recompiles and applies the second change rather than reporting Compiling dart to kernel with 0 updated files.

On Windows, `dart:io` reports `FileStat.modified` truncated to second
precision (via `GetFileAttributesExW`). When
`ProjectFileInvalidator.findInvalidated` compares file modification
times with `lastCompiled` (which is recorded with millisecond
precision), files edited in the same second as the previous compilation
are ignored because `updatedAt.isAfter(lastCompiled)` returns `false`.

This PR fixes the issue by truncating `lastCompiled` to second precision
on Windows and using `!updatedAt.isBefore(lastCompiledTruncated)` to
ensure files modified within the same second as the compilation start
time are marked as invalidated.

Fixes flutter#191198

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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].
- [x] 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
[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/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Loïc Sharma <[email protected]>
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 24, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 24, 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 Aug 24, 2026
@bkonyi bkonyi changed the title [CP-stable][tool] Fix Windows hot reload mtime truncation issue [stable] [tool] Fix Windows hot reload mtime truncation issue Aug 24, 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 updates ProjectFileInvalidator to address file modification time truncation on Windows. On Windows, lastCompiled is truncated to second precision to match FileStat.modified, and files are invalidated if their modification time is not before this truncated timestamp. On other platforms, the original millisecond-precision comparison is preserved. Unit tests have been added to verify this platform-specific invalidation logic. There are no review comments, and I have no feedback to provide.

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 24, 2026
@auto-submit
auto-submit Bot merged commit 2c72122 into flutter:flutter-3.47-candidate.0 Aug 24, 2026
10 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-c6b98166f1a43251e38ba287c08978d5e7f3a52a branch August 24, 2026 23:18
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