Skip to content

Commit bc63dfe

Browse files
authored
[web] Fix loading of fragment shader with space in name. (flutter#180919)
Fixes flutter#180862 ### Description - Adds `assetKey` encoding in `FragmentProgram.fromAsset` in `web_ui` to be consistent with the implementation in `ui` https://github.com/flutter/flutter/blob/7e176f8c3fde96342b2c61e5b4043d53113a2b31/engine/src/flutter/lib/ui/painting.dart#L5354-L5369 - Adds test ## 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/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 916f2c1 commit bc63dfe

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

engine/src/flutter/lib/web_ui/lib/painting.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,12 @@ class ImageDescriptor {
10041004

10051005
abstract class FragmentProgram {
10061006
static Future<FragmentProgram> fromAsset(String assetKey) {
1007-
return engine.renderer.createFragmentProgram(assetKey);
1007+
// The flutter tool converts all asset keys with spaces into URI
1008+
// encoded paths (replacing ' ' with '%20', for example). We perform
1009+
// the same encoding here so that users can load assets with the same
1010+
// key they have written in the pubspec.
1011+
final String encodedKey = Uri(path: Uri.encodeFull(assetKey)).path;
1012+
return engine.renderer.createFragmentProgram(encodedKey);
10081013
}
10091014

10101015
FragmentShader fragmentShader();

engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ Future<void> testMain() async {
417417
}, skip: isWimp); // https://github.com/flutter/flutter/issues/175431
418418
}
419419

420+
// Regression test for https://github.com/flutter/flutter/issues/180862.
421+
test('fragment shader with space in name loads correctly', () async {
422+
assetScope.setAsset('voronoi%20shader', ByteData.sublistView(utf8.encode(kVoronoiShaderSksl)));
423+
await expectLater(ui.FragmentProgram.fromAsset('voronoi shader'), completes);
424+
}, skip: isWimp); // https://github.com/flutter/flutter/issues/175431
425+
420426
test('getUniformFloat works with correct datatype', () async {
421427
final ui.FragmentProgram program = await renderer.createFragmentProgram('ink_sparkle');
422428
final ui.FragmentShader shader = program.fragmentShader();

0 commit comments

Comments
 (0)