diff --git a/DEPS b/DEPS index 5b2e06389c0b1..28183e13ae142 100644 --- a/DEPS +++ b/DEPS @@ -20,10 +20,6 @@ vars = { 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', 'skia_revision': 'c55605969a599681f4a5530ba84402f67f55bfa1', - # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY - # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. - 'canvaskit_cipd_instance': '61aeJQ9laGfEFF_Vlc_u0MCkqB6xb2hAYHRBxKH-Uw4C', - # Do not download the Emscripten SDK by default. # This prevents us from downloading the Emscripten toolchain for builds # which do not build for the web. This toolchain is needed to build CanvasKit @@ -723,16 +719,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/web_dependencies': { - 'packages': [ - { - 'package': 'flutter/web/canvaskit_bundle', - 'version': Var('canvaskit_cipd_instance') - } - ], - 'dep_type': 'cipd', - }, - 'src/third_party/java/openjdk': { 'packages': [ { diff --git a/lib/web_ui/dev/steps/compile_tests_step.dart b/lib/web_ui/dev/steps/compile_tests_step.dart index 54abf19191ed8..ba7202cb81554 100644 --- a/lib/web_ui/dev/steps/compile_tests_step.dart +++ b/lib/web_ui/dev/steps/compile_tests_step.dart @@ -4,15 +4,22 @@ import 'dart:convert' show JsonEncoder; import 'dart:io' as io; +import 'dart:typed_data'; +import 'package:http/http.dart' as http; import 'package:path/path.dart' as pathlib; import 'package:pool/pool.dart'; +import '../common.dart'; import '../environment.dart'; import '../exceptions.dart'; import '../pipeline.dart'; import '../utils.dart'; +// TODO(het): : We are using this hack while we wait for the built CanvasKit +// artifacts to be available on all platforms we test on, https://github.com/flutter/flutter/issues/119036. +const String _goodCanvasKitRevision = 'cc060144e81bff619f9c94bfeecf2a2987f166bb'; + /// Compiles web tests and their dependencies into web_ui/build/. /// /// Outputs of this step: @@ -21,19 +28,16 @@ import '../utils.dart'; /// * assets/ - test fonts /// * host/ - compiled test host page and static artifacts /// * test/ - compiled test code -/// * test_images/ - test images copied from Skis sources. +/// * test_images/ - test images copied from Skia sources. class CompileTestsStep implements PipelineStep { CompileTestsStep({ this.testFiles, - this.useLocalCanvasKit = false, this.isWasm = false }); final List? testFiles; final bool isWasm; - final bool useLocalCanvasKit; - @override String get description => 'compile_tests'; @@ -52,7 +56,7 @@ class CompileTestsStep implements PipelineStep { await copyDart2WasmTestScript(); await copySkwasm(); } - await copyCanvasKitFiles(useLocalCanvasKit: useLocalCanvasKit); + await copyCanvasKitFiles(); await buildHostPage(); await copyTestFonts(); await copySkiaTestImages(); @@ -179,13 +183,10 @@ final io.File _localCanvasKitWasm = io.File(pathlib.join( 'canvaskit.wasm', )); -Future copyCanvasKitFiles({bool useLocalCanvasKit = false}) async { - // If CanvasKit has been built locally, use that instead of the CIPD version. +Future copyCanvasKitFiles() async { final bool localCanvasKitExists = _localCanvasKitWasm.existsSync(); - if (useLocalCanvasKit && !localCanvasKitExists) { - throw ArgumentError('Requested to use local CanvasKit but could not find the ' - 'built CanvasKit at ${_localCanvasKitWasm.path}. Falling back to ' - 'CanvasKit from CIPD.'); + if (!localCanvasKitExists && !isLuci) { + throw ArgumentError('Could not find the local CanvasKit build. Try running `felt build`'); } final io.Directory targetDir = io.Directory(pathlib.join( @@ -193,43 +194,36 @@ Future copyCanvasKitFiles({bool useLocalCanvasKit = false}) async { 'canvaskit', )); - if (useLocalCanvasKit) { - final Iterable canvasKitFiles = - _localCanvasKitDir.listSync(recursive: true).whereType(); - for (final io.File file in canvasKitFiles) { - if (!file.path.endsWith('.wasm') && !file.path.endsWith('.js')) { - // We only need the .wasm and .js files. - continue; - } - final String relativePath = - pathlib.relative(file.path, from: _localCanvasKitDir.path); - final io.File normalTargetFile = - io.File(pathlib.join(targetDir.path, relativePath)); - await normalTargetFile.create(recursive: true); - await file.copy(normalTargetFile.path); - } - } else { - final io.Directory canvasKitDir = io.Directory(pathlib.join( - environment.engineSrcDir.path, - 'third_party', - 'web_dependencies', - 'canvaskit', - )); + // TODO(het): Remove this hack once we are able to share build artifacts + // across multiple builders on LUCI. + if (!localCanvasKitExists) { + // If we're running on LUCI then we should temporarily just download + // a known good version of CanvasKit if we didn't already build one. + const String canvasKitBaseUrl = 'https://www.gstatic.com/flutter-canvaskit/$_goodCanvasKitRevision/'; + final Uint8List canvasKitJs = (await http.get(Uri.parse('${canvasKitBaseUrl}canvaskit.js'))).bodyBytes; + final Uint8List canvasKitWasm = (await http.get(Uri.parse('${canvasKitBaseUrl}canvaskit.wasm'))).bodyBytes; + final io.File targetJsFile = io.File(pathlib.join(targetDir.path, 'canvaskit.js')); + final io.File targetWasmFile = io.File(pathlib.join(targetDir.path, 'canvaskit.wasm')); + await targetJsFile.create(recursive: true); + await targetWasmFile.create(recursive: true); + await targetJsFile.writeAsBytes(canvasKitJs); + await targetWasmFile.writeAsBytes(canvasKitWasm); + return; + } - final Iterable canvasKitFiles = canvasKitDir - .listSync(recursive: true) - .whereType(); - - for (final io.File file in canvasKitFiles) { - final String relativePath = - pathlib.relative(file.path, from: canvasKitDir.path); - final io.File targetFile = io.File(pathlib.join( - targetDir.path, - relativePath, - )); - await targetFile.create(recursive: true); - await file.copy(targetFile.path); + final Iterable canvasKitFiles = + _localCanvasKitDir.listSync(recursive: true).whereType(); + for (final io.File file in canvasKitFiles) { + if (!file.path.endsWith('.wasm') && !file.path.endsWith('.js')) { + // We only need the .wasm and .js files. + continue; } + final String relativePath = + pathlib.relative(file.path, from: _localCanvasKitDir.path); + final io.File normalTargetFile = + io.File(pathlib.join(targetDir.path, relativePath)); + await normalTargetFile.create(recursive: true); + await file.copy(normalTargetFile.path); } } diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index f3756a82ba480..07e040956b5bd 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -80,8 +80,7 @@ class TestCommand extends Command with ArgUtils { ) ..addFlag( 'use-local-canvaskit', - help: 'Optional. Whether or not to use the locally built version of ' - 'CanvasKit in the tests.', + help: 'Deprecated. Has no effect. The local CanvasKit is always used.' ); } @@ -126,9 +125,6 @@ class TestCommand extends Command with ArgUtils { /// Path to a CanvasKit build. Overrides the default CanvasKit. String? get overridePathToCanvasKit => argResults!['canvaskit-path'] as String?; - /// Whether or not to use the locally built version of CanvasKit. - bool get useLocalCanvasKit => boolArg('use-local-canvaskit'); - @override Future run() async { final List testFiles = runAllTests @@ -139,7 +135,6 @@ class TestCommand extends Command with ArgUtils { if (isWatchMode) ClearTerminalScreenStep(), CompileTestsStep( testFiles: testFiles, - useLocalCanvasKit: useLocalCanvasKit, isWasm: isWasm ), RunTestsStep(