Skip to content

[flutter_tools] Watch transitive #include headers for FragmentProgram hot reload#187945

Open
bkonyi wants to merge 5 commits into
flutter:masterfrom
bkonyi:shader-hot-reload-includes
Open

[flutter_tools] Watch transitive #include headers for FragmentProgram hot reload#187945
bkonyi wants to merge 5 commits into
flutter:masterfrom
bkonyi:shader-hot-reload-includes

Conversation

@bkonyi

@bkonyi bkonyi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #186343

This PR enables hot reloading of shaders when their transitive #include dependencies are modified.

Changes:

  • Pass --depfile to impellerc to generate dependency files.
  • Track shader dependencies in DevelopmentShaderCompiler using DepfileService.
  • Check if dependencies are modified during DevFS sync to trigger recompilation.
  • Added extensive test coverage for edge cases (missing depfile, malformed depfile, non-file content).

… hot reload

Pass --depfile to impellerc and track dependencies in DevelopmentShaderCompiler to trigger hot reload when transitive includes are modified.

Fixes flutter#186343
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 12, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 12, 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 tracking of transitive shader dependencies in DevelopmentShaderCompiler to determine if shaders need recompilation during DevFS syncs. It parses depfiles generated by impellerc and exposes areDependenciesModified to check for modified dependencies. Feedback highlights a potential FileSystemException when calling dep.statSync() in areDependenciesModified, which could crash the sync process and should be wrapped in a try-catch block.

Comment on lines +125 to +132
for (final File dep in deps) {
if (!dep.existsSync()) {
return true;
}
if (dep.statSync().modified.isAfter(lastCompiled)) {
return true;
}
}

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.

medium

Calling dep.statSync() can throw a FileSystemException if the file is inaccessible, has permission issues, or is deleted between the existsSync() check and the statSync() call. Since this method is called during the DevFS sync process, an unhandled exception here will crash the sync and fail the hot reload.

We should wrap the check in a try-catch block to handle FileSystemException gracefully, log it as a trace, and safely assume the dependency has been modified to trigger a recompile.

    for (final File dep in deps) {
      try {
        if (!dep.existsSync()) {
          return true;
        }
        if (dep.statSync().modified.isAfter(lastCompiled)) {
          return true;
        }
      } on FileSystemException catch (e) {
        _logger.printTrace('Error checking shader dependency modification time for ${dep.path}: $e');
        return true;
      }
    }

@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 12, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 4aa826b5ba779a1fd90b4406815cfaf6ff5ba06e, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 15, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 15, 2026
Wrap dependency existence and stat checks in a try-catch block in areDependenciesModified to prevent crashing the DevFS sync process if a FileSystemException occurs.
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 19, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 19, 2026
@bkonyi bkonyi requested a review from chingjun June 19, 2026 19:50
chingjun
chingjun previously approved these changes Jun 20, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit

auto-submit Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/187945, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 23, 2026
@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Jun 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit

auto-submit Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/187945, Failed to enqueue flutter/flutter/187945 with HTTP 400: No merge queue found for branch 'main'.

@bkonyi bkonyi changed the base branch from main to master June 23, 2026 17:11
@bkonyi bkonyi dismissed chingjun’s stale review June 23, 2026 17:11

The base branch was changed.

@bkonyi bkonyi requested a review from chingjun June 23, 2026 17:11
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 23, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 53e8ca93e01b12045b668c8694e3e7b161ba01f2, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 23, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flutter_tools] FragmentProgram hot reload doesn't watch transitive #include headers

3 participants