From e0e5a5e168ae368052b42b17a00444e4fc2feb3f Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Fri, 5 Feb 2021 14:21:46 -0800 Subject: [PATCH 1/6] Roll CanvasKit to 0.23. --- .../lib/src/engine/canvaskit/initialization.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/web_ui/lib/src/engine/canvaskit/initialization.dart b/lib/web_ui/lib/src/engine/canvaskit/initialization.dart index da7204a953b86..af4212eb939db 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/initialization.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/initialization.dart @@ -75,10 +75,12 @@ const bool canvasKitForceCpuOnly = bool.fromEnvironment( /// NPM, update this URL to `https://unpkg.com/canvaskit-wasm@0.34.0/bin/`. const String canvasKitBaseUrl = String.fromEnvironment( 'FLUTTER_WEB_CANVASKIT_URL', - defaultValue: 'https://unpkg.com/canvaskit-wasm@0.22.0/bin/', + defaultValue: 'https://unpkg.com/canvaskit-wasm@0.23.0/bin/', ); -final String canvasKitBuildUrl = canvasKitBaseUrl + (kProfileMode ? 'profiling/' : ''); -final String canvasKitJavaScriptBindingsUrl = canvasKitBuildUrl + 'canvaskit.js'; +final String canvasKitBuildUrl = + canvasKitBaseUrl + (kProfileMode ? 'profiling/' : ''); +final String canvasKitJavaScriptBindingsUrl = + canvasKitBuildUrl + 'canvaskit.js'; String canvasKitWasmModuleUrl(String file) => canvasKitBuildUrl + file; /// Initialize CanvasKit. @@ -89,8 +91,10 @@ Future initializeCanvasKit() { late StreamSubscription loadSubscription; loadSubscription = domRenderer.canvasKitScript!.onLoad.listen((_) { loadSubscription.cancel(); - final CanvasKitInitPromise canvasKitInitPromise = CanvasKitInit(CanvasKitInitOptions( - locateFile: js.allowInterop((String file, String unusedBase) => canvasKitWasmModuleUrl(file)), + final CanvasKitInitPromise canvasKitInitPromise = + CanvasKitInit(CanvasKitInitOptions( + locateFile: js.allowInterop( + (String file, String unusedBase) => canvasKitWasmModuleUrl(file)), )); canvasKitInitPromise.then(js.allowInterop((CanvasKit ck) { canvasKit = ck; From d3cffc65ff8022736bea28e1fb1174140db38431 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Mon, 8 Feb 2021 16:50:20 -0800 Subject: [PATCH 2/6] Update goldens lock --- lib/web_ui/dev/goldens_lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/dev/goldens_lock.yaml b/lib/web_ui/dev/goldens_lock.yaml index 4574022fa25e4..1ca56a94b1c9e 100644 --- a/lib/web_ui/dev/goldens_lock.yaml +++ b/lib/web_ui/dev/goldens_lock.yaml @@ -1,2 +1,2 @@ repository: https://github.com/flutter/goldens.git -revision: 6839c709f859a1abe50e6322dfee17a3a3817c5c +revision: 342b0f3a6cdbe7fcbeadfa176bd04a344bb6059d From 3c998079b01ed0e836e7425eaf54b654b15f72e6 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 9 Feb 2021 11:04:58 -0800 Subject: [PATCH 3/6] Touch up tests --- .../test/canvaskit/canvaskit_api_test.dart | 2 +- lib/web_ui/test/canvaskit/surface_test.dart | 40 +++++++++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart index dea114a7b0282..2bc13f045ab8f 100644 --- a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart +++ b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart @@ -1313,7 +1313,7 @@ void _paragraphTests() { expect(paragraph.getIdeographicBaseline(), within(distance: 0.5, from: 28)); expect(paragraph.getLongestLine(), 50); expect(paragraph.getMaxIntrinsicWidth(), 50); - expect(paragraph.getMinIntrinsicWidth(), 0); + expect(paragraph.getMinIntrinsicWidth(), 50); expect(paragraph.getMaxWidth(), 55); expect(paragraph.getRectsForRange(1, 3, canvasKit.RectHeightStyle.Tight, canvasKit.RectWidthStyle.Max), []); expect(paragraph.getRectsForPlaceholders(), hasLength(1)); diff --git a/lib/web_ui/test/canvaskit/surface_test.dart b/lib/web_ui/test/canvaskit/surface_test.dart index ddf45c1f9c926..3b8f387eac44e 100644 --- a/lib/web_ui/test/canvaskit/surface_test.dart +++ b/lib/web_ui/test/canvaskit/surface_test.dart @@ -20,9 +20,14 @@ void testMain() { group('CanvasKit', () { setUpCanvasKitTest(); + setUp(() { + window.debugOverrideDevicePixelRatio(1); + }); + test('Surface allocates canvases efficiently', () { final Surface surface = Surface(HtmlViewEmbedder()); - final CkSurface original = surface.acquireFrame(ui.Size(9, 19)).skiaSurface; + final CkSurface original = + surface.acquireFrame(ui.Size(9, 19)).skiaSurface; // Expect exact requested dimensions. expect(original.width(), 9); @@ -38,7 +43,8 @@ void testMain() { // The first increase will allocate a new surface, but will overallocate // by 40% to accommodate future increases. - final CkSurface firstIncrease = surface.acquireFrame(ui.Size(10, 20)).skiaSurface; + final CkSurface firstIncrease = + surface.acquireFrame(ui.Size(10, 20)).skiaSurface; expect(firstIncrease, isNot(same(original))); // Expect overallocated dimensions @@ -48,7 +54,8 @@ void testMain() { expect(surface.htmlCanvas!.style.height, '28px'); // Subsequent increases within 40% reuse the old surface. - final CkSurface secondIncrease = surface.acquireFrame(ui.Size(11, 22)).skiaSurface; + final CkSurface secondIncrease = + surface.acquireFrame(ui.Size(11, 22)).skiaSurface; expect(secondIncrease, same(firstIncrease)); // Increases beyond the 40% limit will cause a new allocation. @@ -62,7 +69,8 @@ void testMain() { expect(surface.htmlCanvas!.style.height, '56px'); // Shrink again. Reuse the last allocated surface. - final CkSurface shrunk2 = surface.acquireFrame(ui.Size(5, 15)).skiaSurface; + final CkSurface shrunk2 = + surface.acquireFrame(ui.Size(5, 15)).skiaSurface; expect(shrunk2, same(huge)); }); @@ -71,25 +79,30 @@ void testMain() { () async { final Surface surface = Surface(HtmlViewEmbedder()); expect(surface.debugForceNewContext, isTrue); - final CkSurface before = surface.acquireFrame(ui.Size(9, 19)).skiaSurface; + final CkSurface before = + surface.acquireFrame(ui.Size(9, 19)).skiaSurface; expect(surface.debugForceNewContext, isFalse); // Pump a timer to flush any microtasks. await Future.delayed(Duration.zero); - final CkSurface afterAcquireFrame = surface.acquireFrame(ui.Size(9, 19)).skiaSurface; + final CkSurface afterAcquireFrame = + surface.acquireFrame(ui.Size(9, 19)).skiaSurface; // Existing context is reused. expect(afterAcquireFrame, same(before)); // Emulate WebGL context loss. - final html.CanvasElement canvas = surface.htmlElement.children.single as html.CanvasElement; + final html.CanvasElement canvas = + surface.htmlElement.children.single as html.CanvasElement; final dynamic ctx = canvas.getContext('webgl2'); - final dynamic loseContextExtension = ctx.getExtension('WEBGL_lose_context'); + final dynamic loseContextExtension = + ctx.getExtension('WEBGL_lose_context'); loseContextExtension.loseContext(); // Pump a timer to allow the "lose context" event to propagate. await Future.delayed(Duration.zero); expect(surface.debugForceNewContext, isTrue); - final CkSurface afterContextLost = surface.acquireFrame(ui.Size(9, 19)).skiaSurface; + final CkSurface afterContextLost = + surface.acquireFrame(ui.Size(9, 19)).skiaSurface; // A new cotext is created. expect(afterContextLost, isNot(same(before))); }, @@ -100,7 +113,8 @@ void testMain() { // Regression test for https://github.com/flutter/flutter/issues/75286 test('updates canvas logical size when device-pixel ratio changes', () { final Surface surface = Surface(HtmlViewEmbedder()); - final CkSurface original = surface.acquireFrame(ui.Size(10, 16)).skiaSurface; + final CkSurface original = + surface.acquireFrame(ui.Size(10, 16)).skiaSurface; expect(original.width(), 10); expect(original.height(), 16); @@ -110,7 +124,8 @@ void testMain() { // Increase device-pixel ratio: this makes CSS pixels bigger, so we need // fewer of them to cover the browser window. window.debugOverrideDevicePixelRatio(2.0); - final CkSurface highDpr = surface.acquireFrame(ui.Size(10, 16)).skiaSurface; + final CkSurface highDpr = + surface.acquireFrame(ui.Size(10, 16)).skiaSurface; expect(highDpr.width(), 10); expect(highDpr.height(), 16); expect(surface.htmlCanvas!.style.width, '5px'); @@ -119,7 +134,8 @@ void testMain() { // Decrease device-pixel ratio: this makes CSS pixels smaller, so we need // more of them to cover the browser window. window.debugOverrideDevicePixelRatio(0.5); - final CkSurface lowDpr = surface.acquireFrame(ui.Size(10, 16)).skiaSurface; + final CkSurface lowDpr = + surface.acquireFrame(ui.Size(10, 16)).skiaSurface; expect(lowDpr.width(), 10); expect(lowDpr.height(), 16); expect(surface.htmlCanvas!.style.width, '20px'); From b12b331273ae12365f75de8522ba7ad544a21034 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 9 Feb 2021 12:22:52 -0800 Subject: [PATCH 4/6] Skip the golden failure test on LUCI --- lib/web_ui/dev/test_runner.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index e9a555fcf9e4a..ea944e154b205 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -552,7 +552,8 @@ class TestCommand extends Command with ArgUtils { if (isUnitTestsScreenshotsAvailable) { // This test returns a non-zero exit code on purpose. Run it separately. - if (io.Platform.environment['CIRRUS_CI'] != 'true') { + if (io.Platform.environment['CIRRUS_CI'] != 'true' || + io.Platform.environment['LUCI_CONTEXT'] != null) { await _runTestBatch( [failureSmokeTestPath], concurrency: 1, From d81bd47c8aade3b0a018762d9a8287e05affe090 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Wed, 10 Feb 2021 09:04:31 -0800 Subject: [PATCH 5/6] Try tests again with goldens reverted --- lib/web_ui/dev/goldens_lock.yaml | 2 +- lib/web_ui/dev/test_runner.dart | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/web_ui/dev/goldens_lock.yaml b/lib/web_ui/dev/goldens_lock.yaml index 1ca56a94b1c9e..f82ce8252aa3a 100644 --- a/lib/web_ui/dev/goldens_lock.yaml +++ b/lib/web_ui/dev/goldens_lock.yaml @@ -1,2 +1,2 @@ repository: https://github.com/flutter/goldens.git -revision: 342b0f3a6cdbe7fcbeadfa176bd04a344bb6059d +revision: 96e75232531e336309895fd20cea0cccafa20462 diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index ea944e154b205..e9a555fcf9e4a 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -552,8 +552,7 @@ class TestCommand extends Command with ArgUtils { if (isUnitTestsScreenshotsAvailable) { // This test returns a non-zero exit code on purpose. Run it separately. - if (io.Platform.environment['CIRRUS_CI'] != 'true' || - io.Platform.environment['LUCI_CONTEXT'] != null) { + if (io.Platform.environment['CIRRUS_CI'] != 'true') { await _runTestBatch( [failureSmokeTestPath], concurrency: 1, From 8c3607b4d2df78486bd6b3d48ffbccdd5e410e36 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Fri, 12 Feb 2021 14:28:23 -0800 Subject: [PATCH 6/6] Update goldens lock file --- lib/web_ui/dev/goldens_lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/dev/goldens_lock.yaml b/lib/web_ui/dev/goldens_lock.yaml index 9f569f3ce3d6d..58668c5d830e9 100644 --- a/lib/web_ui/dev/goldens_lock.yaml +++ b/lib/web_ui/dev/goldens_lock.yaml @@ -1,2 +1,2 @@ repository: https://github.com/flutter/goldens.git -revision: 578ecb91ea33004cd0ba0af513884cc28ba88cf4 +revision: 1c6b4fcf242ef6c4475340d30aadad754b8a0c54