Revert "[web:tools] always use CanvasKit from the cache when building web apps (#93002)"
This commit is contained in:
@@ -51,14 +51,12 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
required Logger logger,
|
||||
required Artifacts? artifacts,
|
||||
required ProcessManager processManager,
|
||||
required Cache cache,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_flutterToolPackageConfig = flutterToolPackageConfig,
|
||||
_chromiumLauncher = chromiumLauncher,
|
||||
_logger = logger,
|
||||
_artifacts = artifacts,
|
||||
_cache = cache {
|
||||
_artifacts = artifacts {
|
||||
final shelf.Cascade cascade = shelf.Cascade()
|
||||
.add(_webSocketHandler.handler)
|
||||
.add(createStaticHandler(
|
||||
@@ -98,7 +96,6 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
final OneOffHandler _webSocketHandler = OneOffHandler();
|
||||
final AsyncMemoizer<void> _closeMemo = AsyncMemoizer<void>();
|
||||
final String _root;
|
||||
final Cache _cache;
|
||||
|
||||
/// Allows only one test suite (typically one test file) to be loaded and run
|
||||
/// at any given point in time. Loading more than one file at a time is known
|
||||
@@ -121,7 +118,6 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
required ChromiumLauncher chromiumLauncher,
|
||||
required Artifacts? artifacts,
|
||||
required ProcessManager processManager,
|
||||
required Cache cache,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
}) async {
|
||||
final shelf_io.IOServer server = shelf_io.IOServer(await HttpMultiServer.loopback(0));
|
||||
@@ -151,7 +147,6 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
logger: logger,
|
||||
nullAssertions: nullAssertions,
|
||||
processManager: processManager,
|
||||
cache: cache,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
);
|
||||
}
|
||||
@@ -226,17 +221,12 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
));
|
||||
|
||||
File _canvasKitFile(String relativePath) {
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/52588
|
||||
//
|
||||
// Update this when we start building CanvasKit from sources. In the
|
||||
// meantime, get the Web SDK directory from cache rather than through
|
||||
// Artifacts. The latter is sensitive to `--local-engine`, which changes
|
||||
// the directory to point to ENGINE/src/out. However, CanvasKit is not yet
|
||||
// built as part of the engine, but fetched from CIPD, and so it won't be
|
||||
// found in ENGINE/src/out.
|
||||
final Directory webSdkDirectory = _cache.getWebSdkDirectory();
|
||||
final String canvasKitPath = _artifacts!.getArtifactPath(
|
||||
Artifact.canvasKitPath,
|
||||
platform: TargetPlatform.web_javascript,
|
||||
);
|
||||
final File canvasKitFile = _fileSystem.file(_fileSystem.path.join(
|
||||
webSdkDirectory.path,
|
||||
canvasKitPath,
|
||||
relativePath,
|
||||
));
|
||||
return canvasKitFile;
|
||||
@@ -388,12 +378,13 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
/// Serves a local build of CanvasKit, replacing the CDN build, which can
|
||||
/// cause test flakiness due to reliance on network.
|
||||
shelf.Response _localCanvasKitHandler(shelf.Request request) {
|
||||
final String path = _fileSystem.path.fromUri(request.url);
|
||||
if (!path.startsWith('canvaskit/')) {
|
||||
final String fullPath = _fileSystem.path.fromUri(request.url);
|
||||
if (!fullPath.startsWith('canvaskit/')) {
|
||||
return shelf.Response.notFound('Not a CanvasKit file request');
|
||||
}
|
||||
|
||||
final String extension = _fileSystem.path.extension(path);
|
||||
final String relativePath = fullPath.replaceFirst('canvaskit/', '');
|
||||
final String extension = _fileSystem.path.extension(relativePath);
|
||||
String contentType;
|
||||
switch (extension) {
|
||||
case '.js':
|
||||
@@ -409,7 +400,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
}
|
||||
|
||||
return shelf.Response.ok(
|
||||
_canvasKitFile(path).openRead(),
|
||||
_canvasKitFile(relativePath).openRead(),
|
||||
headers: <String, Object>{
|
||||
HttpHeaders.contentTypeHeader: contentType,
|
||||
},
|
||||
|
||||
@@ -176,7 +176,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
browserFinder: findChromeExecutable,
|
||||
logger: globals.logger,
|
||||
),
|
||||
cache: globals.cache,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user