[web, tool] Support recompiling shaders and unify asset processing#185534
Conversation
There was a problem hiding this comment.
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.
a92263a to
cbeae8d
Compare
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
cbeae8d to
c4073d5
Compare
|
/gemini review |
There was a problem hiding this comment.
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.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
harryterkelsen
left a comment
There was a problem hiding this comment.
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
|
/gemini review |
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
|
@harryterkelsen – PTAL |
harryterkelsen
left a comment
There was a problem hiding this comment.
This mostly LGTM but I have some nits
|
A reason for requesting a revert of flutter/flutter/185534 could |
|
Reason for revert: cause test flakes |
…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]>
…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.
…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]>
…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
User-visible fixes:
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,
WebDevFSused a custom asset loop that bypassed thetransformer step and silently ignored shader compilation failures.
Changes:
DevFS.updateto use the newDevFS.updateBundlehelper.WebDevFSto leverageDevFS.updateBundleandLocalDevFSWriter.WebDevFSwhere assets were resolvingto incorrect nested paths.
devfs_web_test.dartfor shaderrecompilation, asset transformers, and failure handling.
failure in the FS report.