Unverified Commit ac9b501d authored by Jackson Gardner's avatar Jackson Gardner Committed by GitHub

Remove the old canvaskit artifacts to not confuse the web runner. (#124641)

Remove the old canvaskit artifacts to not confuse the web runner.
parent e68086e9
...@@ -38,6 +38,7 @@ class FlutterCache extends Cache { ...@@ -38,6 +38,7 @@ class FlutterCache extends Cache {
registerArtifact(AndroidInternalBuildArtifacts(this)); registerArtifact(AndroidInternalBuildArtifacts(this));
registerArtifact(IOSEngineArtifacts(this, platform: platform)); registerArtifact(IOSEngineArtifacts(this, platform: platform));
registerArtifact(FlutterWebSdk(this)); registerArtifact(FlutterWebSdk(this));
registerArtifact(LegacyCanvasKitRemover(this));
registerArtifact(FlutterSdk(this, platform: platform)); registerArtifact(FlutterSdk(this, platform: platform));
registerArtifact(WindowsEngineArtifacts(this, platform: platform)); registerArtifact(WindowsEngineArtifacts(this, platform: platform));
registerArtifact(MacOSEngineArtifacts(this, platform: platform)); registerArtifact(MacOSEngineArtifacts(this, platform: platform));
...@@ -184,6 +185,38 @@ class FlutterWebSdk extends CachedArtifact { ...@@ -184,6 +185,38 @@ class FlutterWebSdk extends CachedArtifact {
} }
} }
// In previous builds, CanvasKit artifacts were stored in a different location
// than they are now. Leaving those old artifacts in the cache confuses the
// in-memory filesystem that the web runner uses, so this artifact will evict
// them from our cache if they are there.
class LegacyCanvasKitRemover extends ArtifactSet {
LegacyCanvasKitRemover(this.cache) : super(DevelopmentArtifact.web);
final Cache cache;
@override
String get name => 'legacy_canvaskit_remover';
Directory _getLegacyCanvasKitDirectory(FileSystem fileSystem) =>
fileSystem.directory(fileSystem.path.join(
cache.getRoot().path,
'canvaskit',
));
@override
Future<bool> isUpToDate(FileSystem fileSystem) async =>
!(await _getLegacyCanvasKitDirectory(fileSystem).exists());
@override
Future<void> update(
ArtifactUpdater artifactUpdater,
Logger logger,
FileSystem fileSystem,
OperatingSystemUtils operatingSystemUtils,
{bool offline = false}
) => _getLegacyCanvasKitDirectory(fileSystem).delete(recursive: true);
}
/// A cached artifact containing the dart:ui source code. /// A cached artifact containing the dart:ui source code.
class FlutterSdk extends EngineCachedArtifact { class FlutterSdk extends EngineCachedArtifact {
FlutterSdk(Cache cache, { FlutterSdk(Cache cache, {
......
...@@ -880,6 +880,31 @@ void main() { ...@@ -880,6 +880,31 @@ void main() {
)); ));
}); });
testWithoutContext('LegacyCanvasKitRemover removes old canvaskit artifacts if they exist', () async {
final FileExceptionHandler handler = FileExceptionHandler();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(opHandle: handler.opHandle);
final Cache cache = Cache.test(processManager: FakeProcessManager.any(), fileSystem: fileSystem);
final File canvasKitWasm = fileSystem.file(fileSystem.path.join(
cache.getRoot().path,
'canvaskit',
'canvaskit.wasm',
));
canvasKitWasm.createSync(recursive: true);
canvasKitWasm.writeAsStringSync('hello world');
final LegacyCanvasKitRemover remover = LegacyCanvasKitRemover(cache);
expect(await remover.isUpToDate(fileSystem), false);
await remover.update(
FakeArtifactUpdater(),
BufferLogger.test(),
fileSystem,
FakeOperatingSystemUtils(),
);
expect(await remover.isUpToDate(fileSystem), true);
expect(canvasKitWasm.existsSync(), isFalse);
});
testWithoutContext('Cache handles exception thrown if stamp file cannot be parsed', () { testWithoutContext('Cache handles exception thrown if stamp file cannot be parsed', () {
final FileExceptionHandler exceptionHandler = FileExceptionHandler(); final FileExceptionHandler exceptionHandler = FileExceptionHandler();
final FileSystem fileSystem = MemoryFileSystem.test(opHandle: exceptionHandler.opHandle); final FileSystem fileSystem = MemoryFileSystem.test(opHandle: exceptionHandler.opHandle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment