Skip to content

Commit 2efeeb4

Browse files
Revert Dual Web Compile changes (#143175)
Dual Web Compile has had some issues where `flutter test` is not respecting the `--web-renderer` flag for some reason. I haven't gotten entirely to the bottom of the issue, but for now we need to rever these changes while I investigate. This reverts the following PRs: flutter/flutter#143128 flutter/flutter#141396 While doing this revert, I had a few merge conflicts with flutter/flutter#142760, and I tried to resolve the merge conflicts within the spirit of that PR's change, but @chingjun I might need your input on whether the imports I have modified are okay with regards to the change you were making.
1 parent 8d3c7b6 commit 2efeeb4

32 files changed

+414
-794
lines changed

dev/benchmarks/macrobenchmarks/web/index.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
<head>
77
<meta charset="UTF-8">
88
<title>Web Benchmarks</title>
9-
<script src="flutter.js"></script>
109
</head>
1110
<body>
12-
<script>
13-
{{flutter_build_config}}
14-
_flutter.loader.load();
15-
</script>
11+
<script src="main.dart.js" type="application/javascript"></script>
1612
</body>
1713
</html>

dev/devicelab/lib/tasks/web_benchmarks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
3939
'--omit-type-checks',
4040
],
4141
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
42-
if (!benchmarkOptions.useWasm) '--web-renderer=${benchmarkOptions.webRenderer}',
42+
'--web-renderer=${benchmarkOptions.webRenderer}',
4343
'--profile',
4444
'--no-web-resources-cdn',
4545
'-t',
@@ -125,7 +125,7 @@ Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
125125
return Response.internalServerError(body: '$error');
126126
}
127127
}).add(createBuildDirectoryHandler(
128-
path.join(macrobenchmarksDirectory, 'build', 'web'),
128+
path.join(macrobenchmarksDirectory, 'build', benchmarkOptions.useWasm ? 'web_wasm' : 'web'),
129129
));
130130

131131
server = await io.HttpServer.bind('localhost', benchmarkServerPort);

dev/integration_tests/web_e2e_tests/web/index.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
<html>
66
<head>
77
<title>Web Integration Tests</title>
8-
<script src="flutter.js"></script>
8+
<script>
9+
// Use the local CanvasKit bundle instead of the CDN to reduce test flakiness.
10+
window.flutterConfiguration = {
11+
canvasKitBaseUrl: "/canvaskit/"
12+
};
13+
</script>
914
</head>
1015
<body>
11-
<script>
12-
{{flutter_build_config}}
13-
_flutter.loader.load({
14-
config: {
15-
// Use the local CanvasKit bundle instead of the CDN to reduce test flakiness.
16-
canvasKitBaseUrl: "/canvaskit/",
17-
},
18-
});
19-
</script>
16+
<script src="main.dart.js"></script>
2017
</body>
2118
</html>

packages/flutter_tools/lib/src/build_info.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'base/os.dart';
1212
import 'base/utils.dart';
1313
import 'convert.dart';
1414
import 'globals.dart' as globals;
15+
import 'web/compile.dart';
1516

1617
/// Whether icon font subsetting is enabled by default.
1718
const bool kIconTreeShakerEnabledDefault = true;
@@ -35,6 +36,7 @@ class BuildInfo {
3536
List<String>? dartDefines,
3637
this.bundleSkSLPath,
3738
List<String>? dartExperiments,
39+
this.webRenderer = WebRendererMode.auto,
3840
required this.treeShakeIcons,
3941
this.performanceMeasurementFile,
4042
this.packagesPath = '.dart_tool/package_config.json', // TODO(zanderso): make this required and remove the default.
@@ -128,6 +130,9 @@ class BuildInfo {
128130
/// A list of Dart experiments.
129131
final List<String> dartExperiments;
130132

133+
/// When compiling to web, which web renderer mode we are using (html, canvaskit, auto)
134+
final WebRendererMode webRenderer;
135+
131136
/// The name of a file where flutter assemble will output performance
132137
/// information in a JSON format.
133138
///
@@ -793,6 +798,10 @@ HostPlatform getCurrentHostPlatform() {
793798
return HostPlatform.linux_x64;
794799
}
795800

801+
FileSystemEntity getWebPlatformBinariesDirectory(Artifacts artifacts, WebRendererMode webRenderer) {
802+
return artifacts.getHostArtifact(HostArtifact.webPlatformKernelFolder);
803+
}
804+
796805
/// Returns the top-level build output directory.
797806
String getBuildDirectory([Config? config, FileSystem? fileSystem]) {
798807
// TODO(johnmccutchan): Stop calling this function as part of setting
@@ -835,8 +844,8 @@ String getMacOSBuildDirectory() {
835844
}
836845

837846
/// Returns the web build output directory.
838-
String getWebBuildDirectory() {
839-
return globals.fs.path.join(getBuildDirectory(), 'web');
847+
String getWebBuildDirectory([bool isWasm = false]) {
848+
return globals.fs.path.join(getBuildDirectory(), isWasm ? 'web_wasm' : 'web');
840849
}
841850

842851
/// Returns the Linux build output directory.

packages/flutter_tools/lib/src/build_system/build_system.dart

Lines changed: 37 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,6 @@ abstract class Target {
136136
/// A list of zero or more depfiles, located directly under {BUILD_DIR}.
137137
List<String> get depfiles => const <String>[];
138138

139-
/// A string that differentiates different build variants from each other
140-
/// with regards to build flags or settings on the target. This string should
141-
/// represent each build variant as a different unique value. If this value
142-
/// changes between builds, the target will be invalidated and rebuilt.
143-
///
144-
/// By default, this returns null, which indicates there is only one build
145-
/// variant, and the target won't invalidate or rebuild due to this property.
146-
String? get buildKey => null;
147-
148139
/// Whether this target can be executed with the given [environment].
149140
///
150141
/// Returning `true` will cause [build] to be skipped. This is equivalent
@@ -165,7 +156,6 @@ abstract class Target {
165156
<Node>[
166157
for (final Target target in dependencies) target._toNode(environment),
167158
],
168-
buildKey,
169159
environment,
170160
inputsFiles.containsNewDepfile,
171161
);
@@ -191,11 +181,9 @@ abstract class Target {
191181
for (final File output in outputs) {
192182
outputPaths.add(output.path);
193183
}
194-
final String? key = buildKey;
195184
final Map<String, Object> result = <String, Object>{
196185
'inputs': inputPaths,
197186
'outputs': outputPaths,
198-
if (key != null) 'buildKey': key,
199187
};
200188
if (!stamp.existsSync()) {
201189
stamp.createSync();
@@ -230,7 +218,6 @@ abstract class Target {
230218
/// This requires constants from the [Environment] to resolve the paths of
231219
/// inputs and the output stamp.
232220
Map<String, Object> toJson(Environment environment) {
233-
final String? key = buildKey;
234221
return <String, Object>{
235222
'name': name,
236223
'dependencies': <String>[
@@ -242,7 +229,6 @@ abstract class Target {
242229
'outputs': <String>[
243230
for (final File file in resolveOutputs(environment).sources) file.path,
244231
],
245-
if (key != null) 'buildKey': key,
246232
'stamp': _findStampFile(environment).absolute.path,
247233
};
248234
}
@@ -994,85 +980,49 @@ void verifyOutputDirectories(List<File> outputs, Environment environment, Target
994980

995981
/// A node in the build graph.
996982
class Node {
997-
factory Node(
998-
Target target,
999-
List<File> inputs,
1000-
List<File> outputs,
1001-
List<Node> dependencies,
1002-
String? buildKey,
983+
Node(
984+
this.target,
985+
this.inputs,
986+
this.outputs,
987+
this.dependencies,
1003988
Environment environment,
1004-
bool missingDepfile,
989+
this.missingDepfile,
1005990
) {
1006991
final File stamp = target._findStampFile(environment);
1007-
Map<String, Object?>? stampValues;
1008992

1009993
// If the stamp file doesn't exist, we haven't run this step before and
1010994
// all inputs were added.
1011-
if (stamp.existsSync()) {
1012-
final String content = stamp.readAsStringSync();
1013-
if (content.isEmpty) {
1014-
stamp.deleteSync();
1015-
} else {
1016-
try {
1017-
stampValues = castStringKeyedMap(json.decode(content));
1018-
} on FormatException {
1019-
// The json is malformed in some way.
1020-
}
1021-
}
995+
if (!stamp.existsSync()) {
996+
// No stamp file, not safe to skip.
997+
_dirty = true;
998+
return;
1022999
}
1023-
if (stampValues != null) {
1024-
final String? previousBuildKey = stampValues['buildKey'] as String?;
1025-
final Object? stampInputs = stampValues['inputs'];
1026-
final Object? stampOutputs = stampValues['outputs'];
1027-
if (stampInputs is List<Object?> && stampOutputs is List<Object?>) {
1028-
final Set<String> previousInputs = stampInputs.whereType<String>().toSet();
1029-
final Set<String> previousOutputs = stampOutputs.whereType<String>().toSet();
1030-
return Node.withStamp(
1031-
target,
1032-
inputs,
1033-
previousInputs,
1034-
outputs,
1035-
previousOutputs,
1036-
dependencies,
1037-
buildKey,
1038-
previousBuildKey,
1039-
missingDepfile,
1040-
);
1041-
}
1000+
final String content = stamp.readAsStringSync();
1001+
// Something went wrong writing the stamp file.
1002+
if (content.isEmpty) {
1003+
stamp.deleteSync();
1004+
// Malformed stamp file, not safe to skip.
1005+
_dirty = true;
1006+
return;
10421007
}
1043-
return Node.withNoStamp(
1044-
target,
1045-
inputs,
1046-
outputs,
1047-
dependencies,
1048-
buildKey,
1049-
missingDepfile,
1050-
);
1051-
}
1052-
1053-
Node.withNoStamp(
1054-
this.target,
1055-
this.inputs,
1056-
this.outputs,
1057-
this.dependencies,
1058-
this.buildKey,
1059-
this.missingDepfile,
1060-
) : previousInputs = <String>{},
1061-
previousOutputs = <String>{},
1062-
previousBuildKey = null,
1008+
Map<String, Object?>? values;
1009+
try {
1010+
values = castStringKeyedMap(json.decode(content));
1011+
} on FormatException {
1012+
// The json is malformed in some way.
10631013
_dirty = true;
1064-
1065-
Node.withStamp(
1066-
this.target,
1067-
this.inputs,
1068-
this.previousInputs,
1069-
this.outputs,
1070-
this.previousOutputs,
1071-
this.dependencies,
1072-
this.buildKey,
1073-
this.previousBuildKey,
1074-
this.missingDepfile,
1075-
) : _dirty = false;
1014+
return;
1015+
}
1016+
final Object? inputs = values?['inputs'];
1017+
final Object? outputs = values?['outputs'];
1018+
if (inputs is List<Object?> && outputs is List<Object?>) {
1019+
inputs.cast<String?>().whereType<String>().forEach(previousInputs.add);
1020+
outputs.cast<String?>().whereType<String>().forEach(previousOutputs.add);
1021+
} else {
1022+
// The json is malformed in some way.
1023+
_dirty = true;
1024+
}
1025+
}
10761026

10771027
/// The resolved input files.
10781028
///
@@ -1084,11 +1034,6 @@ class Node {
10841034
/// These files may not yet exist if the target hasn't run yet.
10851035
final List<File> outputs;
10861036

1087-
/// The current build key of the target
1088-
///
1089-
/// See `buildKey` in the `Target` class for more information.
1090-
final String? buildKey;
1091-
10921037
/// Whether this node is missing a depfile.
10931038
///
10941039
/// This requires an additional pass of source resolution after the target
@@ -1102,15 +1047,10 @@ class Node {
11021047
final List<Node> dependencies;
11031048

11041049
/// Output file paths from the previous invocation of this build node.
1105-
final Set<String> previousOutputs;
1050+
final Set<String> previousOutputs = <String>{};
11061051

11071052
/// Input file paths from the previous invocation of this build node.
1108-
final Set<String> previousInputs;
1109-
1110-
/// The buildKey from the previous invocation of this build node.
1111-
///
1112-
/// See `buildKey` in the `Target` class for more information.
1113-
final String? previousBuildKey;
1053+
final Set<String> previousInputs = <String>{};
11141054

11151055
/// One or more reasons why a task was invalidated.
11161056
///
@@ -1134,10 +1074,6 @@ class Node {
11341074
FileSystem fileSystem,
11351075
Logger logger,
11361076
) {
1137-
if (buildKey != previousBuildKey) {
1138-
_invalidate(InvalidatedReasonKind.buildKeyChanged);
1139-
_dirty = true;
1140-
}
11411077
final Set<String> currentOutputPaths = <String>{
11421078
for (final File file in outputs) file.path,
11431079
};
@@ -1237,8 +1173,7 @@ class InvalidatedReason {
12371173
InvalidatedReasonKind.inputChanged => 'The following inputs have updated contents: ${data.join(',')}',
12381174
InvalidatedReasonKind.outputChanged => 'The following outputs have updated contents: ${data.join(',')}',
12391175
InvalidatedReasonKind.outputMissing => 'The following outputs were missing: ${data.join(',')}',
1240-
InvalidatedReasonKind.outputSetChanged => 'The following outputs were removed from the output set: ${data.join(',')}',
1241-
InvalidatedReasonKind.buildKeyChanged => 'The target build key changed.',
1176+
InvalidatedReasonKind.outputSetChanged => 'The following outputs were removed from the output set: ${data.join(',')}'
12421177
};
12431178
}
12441179
}
@@ -1260,7 +1195,4 @@ enum InvalidatedReasonKind {
12601195

12611196
/// The set of expected output files changed.
12621197
outputSetChanged,
1263-
1264-
/// The build key changed
1265-
buildKeyChanged,
12661198
}

packages/flutter_tools/lib/src/build_system/build_targets.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import '../base/file_system.dart';
6-
import '../web/compiler_config.dart';
6+
import '../web/compile.dart';
77
import './build_system.dart';
88

99
/// Commonly used build [Target]s.
@@ -14,7 +14,11 @@ abstract class BuildTargets {
1414
Target get releaseCopyFlutterBundle;
1515
Target get generateLocalizationsTarget;
1616
Target get dartPluginRegistrantTarget;
17-
Target webServiceWorker(FileSystem fileSystem, List<WebCompilerConfig> compileConfigs);
17+
Target webServiceWorker(
18+
FileSystem fileSystem, {
19+
required WebRendererMode webRenderer,
20+
required bool isWasm
21+
});
1822
}
1923

2024
/// BuildTargets that return NoOpTarget for every action.
@@ -34,7 +38,11 @@ class NoOpBuildTargets extends BuildTargets {
3438
Target get dartPluginRegistrantTarget => const _NoOpTarget();
3539

3640
@override
37-
Target webServiceWorker(FileSystem fileSystem, List<WebCompilerConfig> compileConfigs) => const _NoOpTarget();
41+
Target webServiceWorker(
42+
FileSystem fileSystem, {
43+
required WebRendererMode webRenderer,
44+
required bool isWasm,
45+
}) => const _NoOpTarget();
3846
}
3947

4048
/// A [Target] that does nothing.

0 commit comments

Comments
 (0)