Skip to content

Commit 5fa05ab

Browse files
authored
[web] Cleanup everything HTML from the flutter tool and test harness (#162836)
- Delete code paths that handle screenshots for the HTML renderer - Delete artifact enums for the HTML/AUTO renderers (and all their usages). - Remove HTML/AUTO renderers warnings. - Delete the HTML/AUTO renderer enums (and all their usages). - Delete tests for all the above.
1 parent 4e6e24f commit 5fa05ab

File tree

17 files changed

+45
-611
lines changed

17 files changed

+45
-611
lines changed

packages/flutter_test/lib/src/_matchers_web.dart

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -59,69 +59,37 @@ class MatchesGoldenFile extends AsyncMatcher {
5959
return 'matched too many widgets';
6060
}
6161
final Element element = elements.single;
62-
final RenderObject renderObject = _findRepaintBoundary(element);
63-
final Size size = renderObject.paintBounds.size;
64-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.instance;
65-
final ui.FlutterView view = binding.platformDispatcher.implicitView!;
66-
final RenderView renderView = binding.renderViews.firstWhere(
67-
(RenderView r) => r.flutterView == view,
68-
);
6962

70-
if (isSkiaWeb) {
71-
// In CanvasKit and Skwasm, use Layer.toImage to generate the screenshot.
72-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.instance;
73-
return binding.runAsync<String?>(() async {
74-
assert(element.renderObject != null);
75-
RenderObject renderObject = element.renderObject!;
76-
while (!renderObject.isRepaintBoundary) {
77-
renderObject = renderObject.parent!;
78-
}
79-
assert(!renderObject.debugNeedsPaint);
80-
final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer;
81-
final ui.Image image = await layer.toImage(renderObject.paintBounds);
82-
try {
83-
final ByteData? bytes = await image.toByteData(format: ui.ImageByteFormat.png);
84-
if (bytes == null) {
85-
return 'could not encode screenshot.';
86-
}
87-
if (autoUpdateGoldenFiles) {
88-
await goldenFileComparator.update(key, bytes.buffer.asUint8List());
89-
return null;
90-
}
91-
try {
92-
final bool success = await goldenFileComparator.compare(
93-
bytes.buffer.asUint8List(),
94-
key,
95-
);
96-
return success ? null : 'does not match';
97-
} on TestFailure catch (ex) {
98-
return ex.message;
99-
}
100-
} finally {
101-
image.dispose();
63+
// In CanvasKit and Skwasm, use Layer.toImage to generate the screenshot.
64+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.instance;
65+
return binding.runAsync<String?>(() async {
66+
assert(element.renderObject != null);
67+
RenderObject renderObject = element.renderObject!;
68+
while (!renderObject.isRepaintBoundary) {
69+
renderObject = renderObject.parent!;
70+
}
71+
assert(!renderObject.debugNeedsPaint);
72+
final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer;
73+
final ui.Image image = await layer.toImage(renderObject.paintBounds);
74+
try {
75+
final ByteData? bytes = await image.toByteData(format: ui.ImageByteFormat.png);
76+
if (bytes == null) {
77+
return 'could not encode screenshot.';
10278
}
103-
});
104-
} else {
105-
// In the HTML renderer, we don't have the ability to render an element
106-
// to an image directly. Instead, we will use `window.render()` to render
107-
// only the element being requested, and send a request to the test server
108-
// requesting it to take a screenshot through the browser's debug interface.
109-
_renderElement(view, renderObject);
110-
final String? result = await binding.runAsync<String?>(() async {
11179
if (autoUpdateGoldenFiles) {
112-
await webGoldenComparator.update(size.width, size.height, key);
80+
await goldenFileComparator.update(key, bytes.buffer.asUint8List());
11381
return null;
11482
}
11583
try {
116-
final bool success = await webGoldenComparator.compare(size.width, size.height, key);
84+
final bool success = await goldenFileComparator.compare(bytes.buffer.asUint8List(), key);
11785
return success ? null : 'does not match';
11886
} on TestFailure catch (ex) {
11987
return ex.message;
12088
}
121-
});
122-
_renderElement(view, renderView);
123-
return result;
124-
}
89+
} finally {
90+
image.dispose();
91+
}
92+
});
12593
}
12694

12795
@override
@@ -130,27 +98,3 @@ class MatchesGoldenFile extends AsyncMatcher {
13098
return description.add('one widget whose rasterized image matches golden image "$testNameUri"');
13199
}
132100
}
133-
134-
RenderObject _findRepaintBoundary(Element element) {
135-
assert(element.renderObject != null);
136-
RenderObject renderObject = element.renderObject!;
137-
while (!renderObject.isRepaintBoundary) {
138-
renderObject = renderObject.parent!;
139-
}
140-
return renderObject;
141-
}
142-
143-
void _renderElement(ui.FlutterView window, RenderObject renderObject) {
144-
assert(renderObject.debugLayer != null);
145-
final Layer layer = renderObject.debugLayer!;
146-
final ui.SceneBuilder sceneBuilder = ui.SceneBuilder();
147-
if (layer is OffsetLayer) {
148-
sceneBuilder.pushOffset(-layer.offset.dx, -layer.offset.dy);
149-
}
150-
// ignore: invalid_use_of_visible_for_testing_member, invalid_use_of_protected_member
151-
layer.updateSubtreeNeedsAddToScene();
152-
// ignore: invalid_use_of_protected_member
153-
layer.addToScene(sceneBuilder);
154-
sceneBuilder.pop();
155-
window.render(sceneBuilder.build());
156-
}

packages/flutter_tools/lib/src/artifacts.dart

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,14 @@ enum HostArtifact {
103103

104104
/// The precompiled SDKs and sourcemaps for web debug builds with the AMD module system.
105105
// TODO(markzipan): delete these when DDC's AMD module system is deprecated, https://github.com/flutter/flutter/issues/142060.
106-
webPrecompiledAmdSdk,
107-
webPrecompiledAmdSdkSourcemaps,
108106
webPrecompiledAmdCanvaskitSdk,
109107
webPrecompiledAmdCanvaskitSdkSourcemaps,
110-
webPrecompiledAmdCanvaskitAndHtmlSdk,
111-
webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps,
112108

113109
/// The precompiled SDKs and sourcemaps for web debug builds with the DDC
114-
/// library bundle module system.
115-
webPrecompiledDdcLibraryBundleSdk,
116-
webPrecompiledDdcLibraryBundleSdkSourcemaps,
110+
/// library bundle module system. Only SDKs built with sound null-safety are
111+
/// provided here.
117112
webPrecompiledDdcLibraryBundleCanvaskitSdk,
118113
webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps,
119-
webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk,
120-
webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps,
121114

122115
iosDeploy,
123116
idevicesyslog,
@@ -263,19 +256,11 @@ String _hostArtifactToFileName(HostArtifact artifact, Platform platform) {
263256
return 'dart2js_platform.dill';
264257
case HostArtifact.flutterWebLibrariesJson:
265258
return 'libraries.json';
266-
case HostArtifact.webPrecompiledAmdSdk:
267259
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
268-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
269-
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
270260
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
271-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
272261
return 'dart_sdk.js';
273-
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
274262
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
275-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
276-
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
277263
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
278-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
279264
return 'dart_sdk.js.map';
280265
case HostArtifact.impellerc:
281266
return 'impellerc$exe';
@@ -459,15 +444,6 @@ class CachedArtifacts implements Artifacts {
459444
_hostArtifactToFileName(artifact, _platform),
460445
);
461446
return _fileSystem.file(path);
462-
case HostArtifact.webPrecompiledAmdSdk:
463-
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
464-
final String path = _fileSystem.path.join(
465-
_getFlutterWebSdkPath(),
466-
'kernel',
467-
'amd',
468-
_hostArtifactToFileName(artifact, _platform),
469-
);
470-
return _fileSystem.file(path);
471447
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
472448
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
473449
final String path = _fileSystem.path.join(
@@ -477,24 +453,6 @@ class CachedArtifacts implements Artifacts {
477453
_hostArtifactToFileName(artifact, _platform),
478454
);
479455
return _fileSystem.file(path);
480-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
481-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
482-
final String path = _fileSystem.path.join(
483-
_getFlutterWebSdkPath(),
484-
'kernel',
485-
'amd-canvaskit-html',
486-
_hostArtifactToFileName(artifact, _platform),
487-
);
488-
return _fileSystem.file(path);
489-
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
490-
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
491-
final String path = _fileSystem.path.join(
492-
_getFlutterWebSdkPath(),
493-
'kernel',
494-
'ddcLibraryBundle',
495-
_hostArtifactToFileName(artifact, _platform),
496-
);
497-
return _fileSystem.file(path);
498456
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
499457
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
500458
final String path = _fileSystem.path.join(
@@ -504,15 +462,6 @@ class CachedArtifacts implements Artifacts {
504462
_hostArtifactToFileName(artifact, _platform),
505463
);
506464
return _fileSystem.file(path);
507-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
508-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
509-
final String path = _fileSystem.path.join(
510-
_getFlutterWebSdkPath(),
511-
'kernel',
512-
'ddcLibraryBundle-canvaskit-html',
513-
_hostArtifactToFileName(artifact, _platform),
514-
);
515-
return _fileSystem.file(path);
516465
case HostArtifact.idevicesyslog:
517466
case HostArtifact.idevicescreenshot:
518467
final String artifactFileName = _hostArtifactToFileName(artifact, _platform);
@@ -1162,15 +1111,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
11621111
_hostArtifactToFileName(artifact, _platform),
11631112
);
11641113
return _fileSystem.file(path);
1165-
case HostArtifact.webPrecompiledAmdSdk:
1166-
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
1167-
final String path = _fileSystem.path.join(
1168-
_getFlutterWebSdkPath(),
1169-
'kernel',
1170-
'amd',
1171-
_hostArtifactToFileName(artifact, _platform),
1172-
);
1173-
return _fileSystem.file(path);
11741114
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
11751115
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
11761116
final String path = _fileSystem.path.join(
@@ -1180,24 +1120,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
11801120
_hostArtifactToFileName(artifact, _platform),
11811121
);
11821122
return _fileSystem.file(path);
1183-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
1184-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
1185-
final String path = _fileSystem.path.join(
1186-
_getFlutterWebSdkPath(),
1187-
'kernel',
1188-
'amd-canvaskit-html',
1189-
_hostArtifactToFileName(artifact, _platform),
1190-
);
1191-
return _fileSystem.file(path);
1192-
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
1193-
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
1194-
final String path = _fileSystem.path.join(
1195-
_getFlutterWebSdkPath(),
1196-
'kernel',
1197-
'ddcLibraryBundle',
1198-
_hostArtifactToFileName(artifact, _platform),
1199-
);
1200-
return _fileSystem.file(path);
12011123
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
12021124
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
12031125
final String path = _fileSystem.path.join(
@@ -1207,15 +1129,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
12071129
_hostArtifactToFileName(artifact, _platform),
12081130
);
12091131
return _fileSystem.file(path);
1210-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
1211-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
1212-
final String path = _fileSystem.path.join(
1213-
_getFlutterWebSdkPath(),
1214-
'kernel',
1215-
'ddcLibraryBundle-canvaskit-html',
1216-
_hostArtifactToFileName(artifact, _platform),
1217-
);
1218-
return _fileSystem.file(path);
12191132
case HostArtifact.idevicesyslog:
12201133
case HostArtifact.idevicescreenshot:
12211134
final String artifactFileName = _hostArtifactToFileName(artifact, _platform);
@@ -1569,15 +1482,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
15691482
_hostArtifactToFileName(artifact, _platform),
15701483
);
15711484
return _fileSystem.file(path);
1572-
case HostArtifact.webPrecompiledAmdSdk:
1573-
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
1574-
final String path = _fileSystem.path.join(
1575-
_getFlutterWebSdkPath(),
1576-
'kernel',
1577-
'amd',
1578-
_hostArtifactToFileName(artifact, _platform),
1579-
);
1580-
return _fileSystem.file(path);
15811485
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
15821486
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
15831487
final String path = _fileSystem.path.join(
@@ -1587,24 +1491,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
15871491
_hostArtifactToFileName(artifact, _platform),
15881492
);
15891493
return _fileSystem.file(path);
1590-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
1591-
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
1592-
final String path = _fileSystem.path.join(
1593-
_getFlutterWebSdkPath(),
1594-
'kernel',
1595-
'amd-canvaskit-html',
1596-
_hostArtifactToFileName(artifact, _platform),
1597-
);
1598-
return _fileSystem.file(path);
1599-
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
1600-
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
1601-
final String path = _fileSystem.path.join(
1602-
_getFlutterWebSdkPath(),
1603-
'kernel',
1604-
'ddcLibraryBundle',
1605-
_hostArtifactToFileName(artifact, _platform),
1606-
);
1607-
return _fileSystem.file(path);
16081494
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
16091495
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
16101496
final String path = _fileSystem.path.join(
@@ -1614,15 +1500,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
16141500
_hostArtifactToFileName(artifact, _platform),
16151501
);
16161502
return _fileSystem.file(path);
1617-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
1618-
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
1619-
final String path = _fileSystem.path.join(
1620-
_getFlutterWebSdkPath(),
1621-
'kernel',
1622-
'ddcLibraryBundle-canvaskit-html',
1623-
_hostArtifactToFileName(artifact, _platform),
1624-
);
1625-
return _fileSystem.file(path);
16261503
case HostArtifact.iosDeploy:
16271504
case HostArtifact.idevicesyslog:
16281505
case HostArtifact.idevicescreenshot:

packages/flutter_tools/lib/src/commands/build_web.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ class BuildWebCommand extends BuildSubCommand {
169169
final bool sourceMaps = boolArg('source-maps');
170170

171171
final List<WebCompilerConfig> compilerConfigs;
172-
if (webRenderer.isDeprecated) {
173-
globals.logger.printWarning(webRenderer.deprecationWarning);
174-
}
175172

176173
if (useWasm) {
177174
if (webRenderer != WebRendererMode.getDefault(useWasm: true)) {

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,6 @@ class RunCommand extends RunCommandBase {
672672
throwToolExit('--wasm is only supported on the web platform');
673673
}
674674

675-
if (webRenderer.isDeprecated) {
676-
globals.logger.printWarning(webRenderer.deprecationWarning);
677-
}
678-
679675
if (webRenderer == WebRendererMode.skwasm && !useWasm) {
680676
throwToolExit('Skwasm renderer requires --wasm');
681677
}

packages/flutter_tools/lib/src/commands/test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
592592
throwToolExit('Skwasm renderer requires --wasm');
593593
}
594594

595-
if (webRenderer.isDeprecated) {
596-
globals.logger.printWarning(webRenderer.deprecationWarning);
597-
}
598-
599595
Device? integrationTestDevice;
600596
if (_isIntegrationTest) {
601597
integrationTestDevice = await findTargetDevice();

0 commit comments

Comments
 (0)