Skip to content

Commit

Permalink
[flutter_tools] re-enable web shader compilation (#118461)
Browse files Browse the repository at this point in the history
* [flutter_tools] re-enable web shader compilation

* update test cases
  • Loading branch information
jonahwilliams authored Jan 13, 2023
1 parent b4d7275 commit 2fd8250
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
31 changes: 13 additions & 18 deletions packages/flutter_tools/lib/src/asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ class ManifestAssetBundle implements AssetBundle {
// For all platforms, include the shaders unconditionally. They are
// small, and whether they're used is determined only by the app source
// code and not by the Flutter manifest.
if (targetPlatform != TargetPlatform.web_javascript)
..._getMaterialShaders(),
..._getMaterialShaders(),
];
for (final _Asset asset in materialAssets) {
final File assetFile = asset.lookupAssetFile(_fileSystem);
Expand Down Expand Up @@ -831,22 +830,18 @@ class ManifestAssetBundle implements AssetBundle {
}
}

// TODO(jonahwilliams): re-enable this feature once
// flutter web is using engine compiled canvaskit.
if (targetPlatform != TargetPlatform.web_javascript) {
for (final Uri shaderUri in flutterManifest.shaders) {
_parseAssetFromFile(
packageConfig,
flutterManifest,
assetBase,
cache,
result,
shaderUri,
packageName: packageName,
attributedPackage: attributedPackage,
assetKind: AssetKind.shader,
);
}
for (final Uri shaderUri in flutterManifest.shaders) {
_parseAssetFromFile(
packageConfig,
flutterManifest,
assetBase,
cache,
result,
shaderUri,
packageName: packageName,
attributedPackage: attributedPackage,
assetKind: AssetKind.shader,
);
}

for (final Uri modelUri in flutterManifest.models) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ flutter:
'--spirv=$outputPath.spirv',
'--input=/$shaderPath',
'--input-type=frag',
'--remap-samplers',
'--include=/$assetsPath',
'--include=$shaderLibDir',
],
Expand Down Expand Up @@ -548,7 +549,7 @@ flutter:
loggerOverride: testLogger,
targetPlatform: TargetPlatform.web_javascript,
);

expect((globals.processManager as FakeProcessManager).hasRemainingExpectations, false);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
FileSystem: () => fileSystem,
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_tools/test/general.shard/asset_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ name: my_package
ProcessManager: () => FakeProcessManager.empty(),
});

testUsingContext('Does not bundles material shaders on web platforms', () async {
testUsingContext('Does bundle material shaders on web platforms', () async {
final String shaderPath = globals.fs.path.join(
Cache.flutterRoot!,
'packages', 'flutter', 'lib', 'src', 'material', 'shaders', 'ink_sparkle.frag'
Expand All @@ -136,7 +136,7 @@ name: my_package

await asset.build(packagesPath: '.packages', targetPlatform: TargetPlatform.web_javascript);

expect(asset.entries.keys, isNot(contains('shaders/ink_sparkle.frag')));
expect(asset.entries.keys, contains('shaders/ink_sparkle.frag'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.empty(),
Expand Down

0 comments on commit 2fd8250

Please sign in to comment.