[web] Change --web-renderer default from auto to canvaskit (#149773)
- When `--web-renderer` is omitted, keep the value `null` until it later materializes to either `canvaskit` or `skwasm`. - No more hardcoded defaults anywhere. We use `WebRendererMode.defaultForJs/defaultForWasm` instead. - When in `--wasm` mode, the JS fallback is now `canvaskit` instead of `auto`. - Add test for defaulting to `skwasm` when `--wasm` is enabled. Fixes https://github.com/flutter/flutter/issues/149826
This commit is contained in:
@@ -274,7 +274,7 @@ void main() {
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('Defaults to web renderer auto mode when no option is specified', () async {
|
||||
testUsingContext('Defaults to web renderer canvaskit mode when no option is specified', () async {
|
||||
final TestWebBuildCommand buildCommand = TestWebBuildCommand(fileSystem: fileSystem);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
|
||||
setupFileSystemForEndToEndTest(fileSystem);
|
||||
@@ -288,7 +288,28 @@ void main() {
|
||||
expect(target, isA<WebServiceWorker>());
|
||||
final List<WebCompilerConfig> configs = (target as WebServiceWorker).compileConfigs;
|
||||
expect(configs.length, 1);
|
||||
expect(configs.first.renderer, WebRendererMode.auto);
|
||||
expect(configs.first.renderer, WebRendererMode.canvaskit);
|
||||
}),
|
||||
});
|
||||
|
||||
testUsingContext('Defaults to web renderer skwasm mode for wasm when no option is specified', () async {
|
||||
final TestWebBuildCommand buildCommand = TestWebBuildCommand(fileSystem: fileSystem);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
|
||||
setupFileSystemForEndToEndTest(fileSystem);
|
||||
await runner.run(<String>['build', 'web', '--no-pub', '--wasm']);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
|
||||
ProcessManager: () => processManager,
|
||||
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true), (Target target, Environment environment) {
|
||||
expect(target, isA<WebServiceWorker>());
|
||||
final List<WebCompilerConfig> configs = (target as WebServiceWorker).compileConfigs;
|
||||
expect(configs.length, 2);
|
||||
expect(configs[0].renderer, WebRendererMode.skwasm);
|
||||
expect(configs[0].compileTarget, CompileTarget.wasm);
|
||||
expect(configs[1].renderer, WebRendererMode.canvaskit);
|
||||
expect(configs[1].compileTarget, CompileTarget.js);
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ void main() {
|
||||
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=true']);
|
||||
});
|
||||
|
||||
test('canvaskit web-renderer with no dart-defines', () {
|
||||
test('canvaskit web-renderer with existing dart-defines', () {
|
||||
dartDefines = <String>['FLUTTER_WEB_USE_SKIA=false'];
|
||||
dartDefines = WebRendererMode.canvaskit.updateDartDefines(dartDefines);
|
||||
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=true']);
|
||||
});
|
||||
|
||||
test('html web-renderer with no dart-defines', () {
|
||||
test('html web-renderer with existing dart-defines', () {
|
||||
dartDefines = <String>['FLUTTER_WEB_USE_SKIA=true'];
|
||||
dartDefines = WebRendererMode.html.updateDartDefines(dartDefines);
|
||||
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=false']);
|
||||
|
||||
@@ -376,7 +376,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -389,7 +390,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -417,7 +419,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -430,7 +433,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -457,7 +461,8 @@ void main() {
|
||||
..._kDart2jsLinuxArgs,
|
||||
'--enable-experiment=non-nullable',
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -471,7 +476,8 @@ void main() {
|
||||
..._kDart2jsLinuxArgs,
|
||||
'--enable-experiment=non-nullable',
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -496,7 +502,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -509,7 +516,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -534,7 +542,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -547,7 +556,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
'-o',
|
||||
@@ -572,7 +582,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--native-null-assertions',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
@@ -586,7 +597,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--native-null-assertions',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -612,7 +624,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -625,7 +638,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-O3',
|
||||
'-o',
|
||||
@@ -650,7 +664,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -666,7 +681,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
'-o',
|
||||
@@ -700,7 +716,8 @@ void main() {
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -715,7 +732,8 @@ void main() {
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
'-o',
|
||||
@@ -740,7 +758,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
'--packages=.dart_tool/package_config.json',
|
||||
@@ -752,7 +771,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.product=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'-O4',
|
||||
'-o',
|
||||
environment.buildDir.childFile('main.dart.js').absolute.path,
|
||||
@@ -777,7 +797,8 @@ void main() {
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -792,7 +813,8 @@ void main() {
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -818,7 +840,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -831,7 +854,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -859,7 +883,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
@@ -872,7 +897,8 @@ void main() {
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=true',
|
||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||
'-DFLUTTER_WEB_USE_SKIA=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
@@ -963,7 +989,7 @@ void main() {
|
||||
JsCompilerConfig(optimizationLevel: 0),
|
||||
JsCompilerConfig(noFrequencyBasedMinification: true),
|
||||
JsCompilerConfig(sourceMaps: false),
|
||||
JsCompilerConfig(renderer: WebRendererMode.canvaskit),
|
||||
JsCompilerConfig(renderer: WebRendererMode.html),
|
||||
|
||||
// All properties non-default
|
||||
JsCompilerConfig(
|
||||
@@ -973,7 +999,7 @@ void main() {
|
||||
optimizationLevel: 0,
|
||||
noFrequencyBasedMinification: true,
|
||||
sourceMaps: false,
|
||||
renderer: WebRendererMode.canvaskit,
|
||||
renderer: WebRendererMode.html,
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ void main() {
|
||||
const WasmCompilerConfig(
|
||||
optimizationLevel: 0,
|
||||
stripWasm: false,
|
||||
renderer: WebRendererMode.skwasm,
|
||||
),
|
||||
const JsCompilerConfig.run(
|
||||
nativeNullAssertions: true,
|
||||
@@ -165,7 +164,7 @@ void main() {
|
||||
BuildInfo.debug,
|
||||
ServiceWorkerStrategy.offlineFirst,
|
||||
compilerConfigs: <WebCompilerConfig>[
|
||||
const JsCompilerConfig.run(nativeNullAssertions: true, renderer: WebRendererMode.auto),
|
||||
const JsCompilerConfig.run(nativeNullAssertions: true, renderer: WebRendererMode.canvaskit),
|
||||
]
|
||||
),
|
||||
throwsToolExit(message: 'Failed to compile application for the Web.'));
|
||||
|
||||
Reference in New Issue
Block a user