[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.
This commit is contained in:
Mouad Debbar
2025-02-13 15:53:37 -05:00
committed by GitHub
parent 4e6e24f729
commit 5fa05ab6df
17 changed files with 45 additions and 611 deletions

View File

@@ -103,21 +103,14 @@ enum HostArtifact {
/// The precompiled SDKs and sourcemaps for web debug builds with the AMD module system.
// TODO(markzipan): delete these when DDC's AMD module system is deprecated, https://github.com/flutter/flutter/issues/142060.
webPrecompiledAmdSdk,
webPrecompiledAmdSdkSourcemaps,
webPrecompiledAmdCanvaskitSdk,
webPrecompiledAmdCanvaskitSdkSourcemaps,
webPrecompiledAmdCanvaskitAndHtmlSdk,
webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps,
/// The precompiled SDKs and sourcemaps for web debug builds with the DDC
/// library bundle module system.
webPrecompiledDdcLibraryBundleSdk,
webPrecompiledDdcLibraryBundleSdkSourcemaps,
/// library bundle module system. Only SDKs built with sound null-safety are
/// provided here.
webPrecompiledDdcLibraryBundleCanvaskitSdk,
webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps,
webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk,
webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps,
iosDeploy,
idevicesyslog,
@@ -263,19 +256,11 @@ String _hostArtifactToFileName(HostArtifact artifact, Platform platform) {
return 'dart2js_platform.dill';
case HostArtifact.flutterWebLibrariesJson:
return 'libraries.json';
case HostArtifact.webPrecompiledAmdSdk:
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
return 'dart_sdk.js';
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
return 'dart_sdk.js.map';
case HostArtifact.impellerc:
return 'impellerc$exe';
@@ -459,15 +444,6 @@ class CachedArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdSdk:
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -477,24 +453,6 @@ class CachedArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -504,15 +462,6 @@ class CachedArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.idevicesyslog:
case HostArtifact.idevicescreenshot:
final String artifactFileName = _hostArtifactToFileName(artifact, _platform);
@@ -1162,15 +1111,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdSdk:
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -1180,24 +1120,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -1207,15 +1129,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.idevicesyslog:
case HostArtifact.idevicescreenshot:
final String artifactFileName = _hostArtifactToFileName(artifact, _platform);
@@ -1569,15 +1482,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdSdk:
case HostArtifact.webPrecompiledAmdSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitSdk:
case HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -1587,24 +1491,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'amd-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps:
final String path = _fileSystem.path.join(
@@ -1614,15 +1500,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk:
case HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps:
final String path = _fileSystem.path.join(
_getFlutterWebSdkPath(),
'kernel',
'ddcLibraryBundle-canvaskit-html',
_hostArtifactToFileName(artifact, _platform),
);
return _fileSystem.file(path);
case HostArtifact.iosDeploy:
case HostArtifact.idevicesyslog:
case HostArtifact.idevicescreenshot:

View File

@@ -169,9 +169,6 @@ class BuildWebCommand extends BuildSubCommand {
final bool sourceMaps = boolArg('source-maps');
final List<WebCompilerConfig> compilerConfigs;
if (webRenderer.isDeprecated) {
globals.logger.printWarning(webRenderer.deprecationWarning);
}
if (useWasm) {
if (webRenderer != WebRendererMode.getDefault(useWasm: true)) {

View File

@@ -672,10 +672,6 @@ class RunCommand extends RunCommandBase {
throwToolExit('--wasm is only supported on the web platform');
}
if (webRenderer.isDeprecated) {
globals.logger.printWarning(webRenderer.deprecationWarning);
}
if (webRenderer == WebRendererMode.skwasm && !useWasm) {
throwToolExit('Skwasm renderer requires --wasm');
}

View File

@@ -592,10 +592,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
throwToolExit('Skwasm renderer requires --wasm');
}
if (webRenderer.isDeprecated) {
globals.logger.printWarning(webRenderer.deprecationWarning);
}
Device? integrationTestDevice;
if (_isIntegrationTest) {
integrationTestDevice = await findTargetDevice();

View File

@@ -17,7 +17,6 @@ import 'package:shelf_web_socket/shelf_web_socket.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test_core/src/platform.dart'; // ignore: implementation_imports
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' hide StackTrace;
import '../artifacts.dart';
import '../base/common.dart';
@@ -451,49 +450,12 @@ class FlutterWebPlatform extends PlatformPlugin {
json.decode(await request.readAsString()) as Map<String, Object?>;
final Uri goldenKey = Uri.parse(body['key']! as String);
final Uri testUri = Uri.parse(body['testUri']! as String);
final num? width = body['width'] as num?;
final num? height = body['height'] as num?;
Uint8List bytes;
if (body.containsKey('bytes')) {
bytes = base64.decode(body['bytes']! as String);
} else {
// TODO(hterkelsen): Do not use browser screenshots for testing on the
// web once we transition off the HTML renderer. See:
// https://github.com/flutter/flutter/issues/135700
try {
final ChromeTab chromeTab =
(await getChromeTabGuarded(_browserManager!._browser.chromeConnection, (
ChromeTab tab,
) {
return tab.url.contains(_browserManager!._browser.url!);
}))!;
final WipConnection connection = await chromeTab.connect();
final WipResponse response = await connection.sendCommand(
'Page.captureScreenshot',
<String, Object>{
// Clip the screenshot to include only the element.
// Prior to taking a screenshot, we are calling `window.render()` in
// `_matchers_web.dart` to only render the element on screen. That
// will make sure that the element will always be displayed on the
// origin of the screen.
'clip': <String, Object>{
'x': 0.0,
'y': 0.0,
'width': width!.toDouble(),
'height': height!.toDouble(),
'scale': 1.0,
},
},
);
bytes = base64.decode(response.result!['data'] as String);
} on WipError catch (ex) {
_logger.printError('Caught WIPError: $ex');
return shelf.Response.ok('WIP error: $ex');
} on FormatException catch (ex) {
_logger.printError('Caught FormatException: $ex');
return shelf.Response.ok('Caught exception: $ex');
}
return shelf.Response.ok('Request must contain bytes in the body.');
}
if (updateGoldens) {
return switch (await _testGoldenComparator.update(testUri, bytes, goldenKey)) {

View File

@@ -160,30 +160,19 @@ class WebBuilder {
/// Web rendering backend mode.
enum WebRendererMode {
/// Auto detects which rendering backend to use.
auto,
/// Always uses canvaskit.
canvaskit,
/// Always uses html.
html,
/// Always use skwasm.
skwasm;
factory WebRendererMode.fromDartDefines(Iterable<String> defines, {required bool useWasm}) {
if (defines.contains('FLUTTER_WEB_AUTO_DETECT=true')) {
return auto;
} else if (defines.contains('FLUTTER_WEB_USE_SKIA=false') &&
if (defines.contains('FLUTTER_WEB_USE_SKIA=false') &&
defines.contains('FLUTTER_WEB_USE_SKWASM=true')) {
return skwasm;
} else if (defines.contains('FLUTTER_WEB_USE_SKIA=true') &&
defines.contains('FLUTTER_WEB_USE_SKWASM=false')) {
return canvaskit;
} else if (defines.contains('FLUTTER_WEB_USE_SKIA=false') &&
defines.contains('FLUTTER_WEB_USE_SKWASM=false')) {
return html; // The horror!
}
return getDefault(useWasm: useWasm);
}
@@ -195,30 +184,6 @@ enum WebRendererMode {
static const WebRendererMode defaultForJs = WebRendererMode.canvaskit;
static const WebRendererMode defaultForWasm = WebRendererMode.skwasm;
/// Returns whether the WebRendererMode is considered deprecated or not.
///
/// Deprecated modes: auto, html.
bool get isDeprecated => switch (this) {
auto => true,
canvaskit => false,
html => true,
skwasm => false,
};
/// Returns a consistent deprecation warning for the WebRendererMode.
String get deprecationWarning =>
'The HTML Renderer is deprecated and will be removed. Please, stop using it.'
'\nSee: https://docs.flutter.dev/to/web-html-renderer-deprecation';
String get helpText => switch (this) {
auto => 'Use the HTML renderer on mobile devices, and CanvasKit on desktop devices.',
canvaskit =>
'Always use the CanvasKit renderer. This renderer uses WebGL and WebAssembly to render graphics.',
html =>
'Always use the HTML renderer. This renderer uses a combination of HTML, CSS, SVG, 2D Canvas, and WebGL.',
skwasm => 'Always use the experimental skwasm renderer.',
};
/// Returns [dartDefines] in a way usable from the CLI.
///
/// This is used to start integration tests.
@@ -226,9 +191,7 @@ enum WebRendererMode {
dartDefines.map((String define) => '--dart-define=$define');
Iterable<String> get dartDefines => switch (this) {
auto => const <String>{'FLUTTER_WEB_AUTO_DETECT=true'},
canvaskit => const <String>{'FLUTTER_WEB_USE_SKIA=true', 'FLUTTER_WEB_USE_SKWASM=false'},
html => const <String>{'FLUTTER_WEB_USE_SKIA=false', 'FLUTTER_WEB_USE_SKWASM=false'},
skwasm => const <String>{'FLUTTER_WEB_USE_SKIA=false', 'FLUTTER_WEB_USE_SKWASM=true'},
};
@@ -238,9 +201,7 @@ enum WebRendererMode {
dartDefinesSet
..removeWhere((String d) {
return d.startsWith('FLUTTER_WEB_AUTO_DETECT=') ||
d.startsWith('FLUTTER_WEB_USE_SKIA=') ||
d.startsWith('FLUTTER_WEB_USE_SKWASM=');
return d.startsWith('FLUTTER_WEB_USE_SKIA=') || d.startsWith('FLUTTER_WEB_USE_SKWASM=');
})
..addAll(dartDefines);
@@ -251,37 +212,28 @@ enum WebRendererMode {
/// The correct precompiled artifact to use for each build and render mode for DDC with AMD modules.
// TODO(markzipan): delete this when DDC's AMD module system is deprecated, https://github.com/flutter/flutter/issues/142060.
const Map<WebRendererMode, HostArtifact> kAmdDartSdkJsArtifactMap = <WebRendererMode, HostArtifact>{
WebRendererMode.auto: HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdk,
WebRendererMode.canvaskit: HostArtifact.webPrecompiledAmdCanvaskitSdk,
WebRendererMode.html: HostArtifact.webPrecompiledAmdSdk,
};
/// The correct source map artifact to use for each build and render mode for DDC with AMD modules.
// TODO(markzipan): delete this when DDC's AMD module system is deprecated, https://github.com/flutter/flutter/issues/142060.
const Map<WebRendererMode, HostArtifact> kAmdDartSdkJsMapArtifactMap =
<WebRendererMode, HostArtifact>{
WebRendererMode.auto: HostArtifact.webPrecompiledAmdCanvaskitAndHtmlSdkSourcemaps,
WebRendererMode.canvaskit: HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps,
WebRendererMode.html: HostArtifact.webPrecompiledAmdSdkSourcemaps,
};
/// The correct precompiled artifact to use for each build and render mode for
/// DDC with DDC library bundle module format.
const Map<WebRendererMode, HostArtifact> kDdcLibraryBundleDartSdkJsArtifactMap =
<WebRendererMode, HostArtifact>{
WebRendererMode.auto: HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdk,
WebRendererMode.canvaskit: HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdk,
WebRendererMode.html: HostArtifact.webPrecompiledDdcLibraryBundleSdk,
};
/// The correct source map artifact to use for each build and render mode for
/// DDC with DDC library bundle module format.
const Map<WebRendererMode, HostArtifact> kDdcLibraryBundleDartSdkJsMapArtifactMap =
<WebRendererMode, HostArtifact>{
WebRendererMode.auto:
HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitAndHtmlSdkSourcemaps,
WebRendererMode.canvaskit: HostArtifact.webPrecompiledDdcLibraryBundleCanvaskitSdkSourcemaps,
WebRendererMode.html: HostArtifact.webPrecompiledDdcLibraryBundleSdkSourcemaps,
};
String _buildEventAnalyticsSettings({required List<WebCompilerConfig> configs}) {