Skip to content

[web, tool] Support recompiling shaders and unify asset processing#185534

Merged
auto-submit[bot] merged 25 commits into
flutter:masterfrom
kevmoo:web_shader_reload
May 20, 2026
Merged

[web, tool] Support recompiling shaders and unify asset processing#185534
auto-submit[bot] merged 25 commits into
flutter:masterfrom
kevmoo:web_shader_reload

Conversation

@kevmoo

@kevmoo kevmoo commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

User-visible fixes:

  • Hot RESTART: should reload for all assets.
  • Hot RELOAD: should reload all assets EXCEPT shaders. Will need to do that in a follow-up.

Addresses SOME of #137265 (Images, JSON, Text, Data Files)

Extracted core asset sync logic (incremental checks, transformers, and
shader recompilation) into a shared static method DevFS.updateBundle.
This aligns the web asset path with other platforms and correctly
enables support for asset transformers during web hot reload/restart.

Previously, WebDevFS used a custom asset loop that bypassed the
transformer step and silently ignored shader compilation failures.

Changes:

  • Refactored DevFS.update to use the new DevFS.updateBundle helper.
  • Updated WebDevFS to leverage DevFS.updateBundle and LocalDevFSWriter.
  • Fixed a path resolution bug in WebDevFS where assets were resolving
    to incorrect nested paths.
  • Added comprehensive tests in devfs_web_test.dart for shader
    recompilation, asset transformers, and failure handling.
  • Ensured that shader compilation failures correctly report an update
    failure in the FS report.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 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 implements shader recompilation and eviction tracking within the web DevFS by updating the update method to process modified shader assets and configuring the shader compiler in ResidentWebRunner. Feedback suggests clearing the _shaderPathsToEvict set during updates to prevent accumulation, ensuring the logic handles initial bundle uploads, and extending the asset loop to process non-shader modified assets. Additionally, a suggestion was made to use asynchronous file writing to improve performance.

Comment thread packages/flutter_tools/lib/src/isolated/devfs_web.dart
Comment thread packages/flutter_tools/lib/src/isolated/devfs_web.dart Outdated
Comment thread packages/flutter_tools/lib/src/isolated/devfs_web.dart Outdated
Comment thread packages/flutter_tools/lib/src/isolated/devfs_web.dart Outdated
@kevmoo kevmoo force-pushed the web_shader_reload branch from a92263a to cbeae8d Compare April 24, 2026 16:51
@kevmoo kevmoo changed the title [web, tool] Support recompiling shaders [web, tool] Support reloading assets (including shaders) Apr 24, 2026
Extracted core asset sync logic (incremental checks, transformers, and
shader recompilation) into a shared static method `DevFS.updateBundle`.
This aligns the web asset path with other platforms and correctly
enables support for asset transformers during web hot reload/restart.

Previously, `WebDevFS` used a custom asset loop that bypassed the
transformer step and silently ignored shader compilation failures.

Changes:
- Refactored `DevFS.update` to use the new `DevFS.updateBundle` helper.
- Updated `WebDevFS` to leverage `DevFS.updateBundle` and `LocalDevFSWriter`.
- Fixed a path resolution bug in `WebDevFS` where assets were resolving
  to incorrect nested paths.
- Added comprehensive tests in `devfs_web_test.dart` for shader
  recompilation, asset transformers, and failure handling.
- Ensured that shader compilation failures correctly report an update
  failure in the FS report.

Fixed flutter#137265
@kevmoo kevmoo force-pushed the web_shader_reload branch from cbeae8d to c4073d5 Compare April 25, 2026 01:28
@kevmoo kevmoo changed the title [web, tool] Support reloading assets (including shaders) [web, tool] Support recompiling shaders and unify asset processing Apr 25, 2026
@kevmoo

kevmoo commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors asset bundle synchronization by extracting the logic into a static DevFS.updateBundle method, which is now utilized by both DevFS and WebDevFS. The changes enable shader recompilation and asset transformation for web platforms and include comprehensive tests for these scenarios. Review feedback identifies a race condition in the asynchronous processing of assets within updateBundle, where side effects in .then callbacks may not complete before the method returns.

Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Side effects like populating dirtyEntries and updating eviction sets
are now performed directly within the awaited asynchronous closures
to ensure they are complete before updateBundle returns.
@kevmoo

kevmoo commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors asset synchronization by extracting the updateBundle logic into a static method in DevFS, allowing WebDevFS to share the implementation. It introduces DevelopmentAssetTransformer to the web runner, implements shader eviction for web, and adds regression tests for asset updates and race conditions. Feedback highlights a potential performance regression in asset skipping logic, an unused logger parameter, duplicated path normalization code, and non-idiomatic asynchronous closure patterns.

Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated

@harryterkelsen harryterkelsen 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.

I also agree with all of the review comments from Gemini. This changes the logic for which assets to recompile on first hot reload. If it is really required to reprocess and bundle every asset on the first hot reload for web to work, we should change the tooling so web doesn't require that and have it work like the other platforms. We shouldn't change the logic for updateBundle

Comment thread packages/flutter_tools/lib/src/isolated/devfs_web.dart Outdated
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 7, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 7, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 7, 2026
@kevmoo

kevmoo commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors asset and shader processing by extracting logic into a shared static updateBundle method, enabling incremental asset updates for web platforms. Feedback identifies a high-severity null safety issue where entry.kind is treated as non-nullable, which could lead to runtime failures, and notes that the corresponding switch statement is no longer exhaustive.

Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label May 7, 2026
@kevmoo

kevmoo commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors asset and shader processing into a shared static method, DevFS.updateBundle, and integrates it into WebDevFS to support incremental updates. A regression was identified in the new updateBundle implementation where the switch statement on entry.kind misses the null case, which previously handled assets as regular assets.

Comment thread packages/flutter_tools/lib/src/devfs.dart
@kevmoo

kevmoo commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@harryterkelsen – PTAL

@kevmoo kevmoo requested a review from harryterkelsen May 7, 2026 16:10

@harryterkelsen harryterkelsen 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.

This mostly LGTM but I have some nits

Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart Outdated
Comment thread packages/flutter_tools/lib/src/devfs.dart
Comment thread packages/flutter_tools/test/general.shard/web/devfs_web_test.dart Outdated
@harryterkelsen harryterkelsen added the CICD Run CI/CD label May 20, 2026
@harryterkelsen harryterkelsen self-requested a review May 20, 2026 17:45

@harryterkelsen harryterkelsen 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.

LGTM!

@auto-submit auto-submit Bot added this pull request to the merge queue May 20, 2026
Merged via the queue into flutter:master with commit f15c3a3 May 20, 2026
161 of 162 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 20, 2026
@kevmoo kevmoo deleted the web_shader_reload branch May 20, 2026 21:49
@chunhtai chunhtai added the revert Autorevert PR (with "Reason for revert:" comment) label May 20, 2026
@auto-submit

auto-submit Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

A reason for requesting a revert of flutter/flutter/185534 could
not be found or the reason was not properly formatted. Begin a comment with 'Reason for revert:' to tell the bot why
this issue is being reverted.

@auto-submit auto-submit Bot removed the revert Autorevert PR (with "Reason for revert:" comment) label May 20, 2026
@chunhtai

Copy link
Copy Markdown
Contributor

Reason for revert: cause test flakes

@chunhtai chunhtai added the revert Autorevert PR (with "Reason for revert:" comment) label May 20, 2026
@auto-submit auto-submit Bot removed the revert Autorevert PR (with "Reason for revert:" comment) label May 20, 2026
victorsanni pushed a commit to puneetkukreja98/flutter that referenced this pull request May 21, 2026
…essing (flutter#185534)" (flutter#186837)

<!-- start_original_pr_link -->
Reverts: flutter#185534
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chunhtai
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: cause test flakes
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: kevmoo
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {harryterkelsen}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
User-visible fixes:

- Hot RESTART: should reload for all assets.
- Hot RELOAD: should reload all assets EXCEPT shaders. Will need to do
that in a follow-up.

Addresses SOME of flutter#137265 (Images, JSON, Text, Data Files)

Extracted core asset sync logic (incremental checks, transformers, and
shader recompilation) into a shared static method `DevFS.updateBundle`.
This aligns the web asset path with other platforms and correctly
enables support for asset transformers during web hot reload/restart.

Previously, `WebDevFS` used a custom asset loop that bypassed the
transformer step and silently ignored shader compilation failures.

Changes:
- Refactored `DevFS.update` to use the new `DevFS.updateBundle` helper.
- Updated `WebDevFS` to leverage `DevFS.updateBundle` and
`LocalDevFSWriter`.
- Fixed a path resolution bug in `WebDevFS` where assets were resolving
to incorrect nested paths.
- Added comprehensive tests in `devfs_web_test.dart` for shader
recompilation, asset transformers, and failure handling.
- Ensured that shader compilation failures correctly report an update
failure in the FS report.


<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
matthewhendrix pushed a commit to matthewhendrix/flutter that referenced this pull request May 23, 2026
…lutter#185534)

User-visible fixes:

- Hot RESTART: should reload for all assets.
- Hot RELOAD: should reload all assets EXCEPT shaders. Will need to do
that in a follow-up.

Addresses SOME of flutter#137265 (Images, JSON, Text, Data Files)

Extracted core asset sync logic (incremental checks, transformers, and
shader recompilation) into a shared static method `DevFS.updateBundle`.
This aligns the web asset path with other platforms and correctly
enables support for asset transformers during web hot reload/restart.

Previously, `WebDevFS` used a custom asset loop that bypassed the
transformer step and silently ignored shader compilation failures.

Changes:
- Refactored `DevFS.update` to use the new `DevFS.updateBundle` helper.
- Updated `WebDevFS` to leverage `DevFS.updateBundle` and
`LocalDevFSWriter`.
- Fixed a path resolution bug in `WebDevFS` where assets were resolving
to incorrect nested paths.
- Added comprehensive tests in `devfs_web_test.dart` for shader
recompilation, asset transformers, and failure handling.
- Ensured that shader compilation failures correctly report an update
failure in the FS report.
matthewhendrix pushed a commit to matthewhendrix/flutter that referenced this pull request May 23, 2026
…essing (flutter#185534)" (flutter#186837)

<!-- start_original_pr_link -->
Reverts: flutter#185534
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chunhtai
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: cause test flakes
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: kevmoo
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {harryterkelsen}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
User-visible fixes:

- Hot RESTART: should reload for all assets.
- Hot RELOAD: should reload all assets EXCEPT shaders. Will need to do
that in a follow-up.

Addresses SOME of flutter#137265 (Images, JSON, Text, Data Files)

Extracted core asset sync logic (incremental checks, transformers, and
shader recompilation) into a shared static method `DevFS.updateBundle`.
This aligns the web asset path with other platforms and correctly
enables support for asset transformers during web hot reload/restart.

Previously, `WebDevFS` used a custom asset loop that bypassed the
transformer step and silently ignored shader compilation failures.

Changes:
- Refactored `DevFS.update` to use the new `DevFS.updateBundle` helper.
- Updated `WebDevFS` to leverage `DevFS.updateBundle` and
`LocalDevFSWriter`.
- Fixed a path resolution bug in `WebDevFS` where assets were resolving
to incorrect nested paths.
- Added comprehensive tests in `devfs_web_test.dart` for shader
recompilation, asset transformers, and failure handling.
- Ensured that shader compilation failures correctly report an update
failure in the FS report.


<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
pull Bot pushed a commit to Budda0ne/flutter that referenced this pull request May 27, 2026
…nd try) (flutter#186902)

This reverts commit 7ed7e21 
Which reverted
flutter@f15c3a3

Effectively re-lands flutter#185534

This brings back the shader compilation support and unified web asset
syncing path
which was previously reverted due to devicelab test flakes on Chrome.
The flakes have been resolved by defensively handling DWDS unregistered
service
extension errors in the previous commit.

Towards flutter#137265
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.

5 participants