From cb4eb612f02fb2e21dd8264fb573b73610c53f83 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 6 Mar 2019 09:30:44 -0500 Subject: [PATCH] [canvaskit] Remove additional copies of CanvasKit when testing Speculative fix for flaky test bot. My guess is that since there were 3 .spec.js that were all trying to load CanvasKit at the same time, the browser would fail to compile/process all that WASM and timeout. This cleans it up so there's only one copy of CanvasKit shared by all tests. Bug: skia:8810 Change-Id: I60a77dae93b7c3e5d45923b4af93a223ac26220c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198161 Auto-Submit: Kevin Lubick Reviewed-by: Ben Wagner Commit-Queue: Ben Wagner --- experimental/canvaskit/karma.bench.conf.js | 1 + experimental/canvaskit/karma.conf.js | 1 + .../canvaskit/perf/animation.bench.js | 18 ------------------ experimental/canvaskit/tests/canvas2d.spec.js | 18 ------------------ experimental/canvaskit/tests/canvaskitinit.js | 13 +++++++++++++ experimental/canvaskit/tests/font.spec.js | 19 ------------------- experimental/canvaskit/tests/path.spec.js | 19 ------------------- 7 files changed, 15 insertions(+), 74 deletions(-) create mode 100644 experimental/canvaskit/tests/canvaskitinit.js diff --git a/experimental/canvaskit/karma.bench.conf.js b/experimental/canvaskit/karma.bench.conf.js index f02aa1f17d..18078ec3f9 100644 --- a/experimental/canvaskit/karma.bench.conf.js +++ b/experimental/canvaskit/karma.bench.conf.js @@ -14,6 +14,7 @@ module.exports = function(config) { { pattern: 'perf/assets/*', included:false, served:true}, '../../modules/pathkit/perf/perfReporter.js', 'canvaskit/bin/canvaskit.js', + 'tests/canvaskitinit.js', 'perf/*.bench.js' ], diff --git a/experimental/canvaskit/karma.conf.js b/experimental/canvaskit/karma.conf.js index 1f2b375768..8527465165 100644 --- a/experimental/canvaskit/karma.conf.js +++ b/experimental/canvaskit/karma.conf.js @@ -14,6 +14,7 @@ module.exports = function(config) { { pattern: 'tests/assets/*', included:false, served:true}, '../../modules/pathkit/tests/testReporter.js', 'canvaskit/bin/canvaskit.js', + 'tests/canvaskitinit.js', 'tests/util.js', 'tests/*.spec.js' ], diff --git a/experimental/canvaskit/perf/animation.bench.js b/experimental/canvaskit/perf/animation.bench.js index f3f463e49f..3c94375e6a 100644 --- a/experimental/canvaskit/perf/animation.bench.js +++ b/experimental/canvaskit/perf/animation.bench.js @@ -1,22 +1,4 @@ -// The increased timeout is especially needed with larger binaries -// like in the debug/gpu build -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - describe('CanvasKit\'s Animation', function() { - // Note, don't try to print the CanvasKit object - it can cause Karma/Jasmine to lock up. - var CanvasKit = null; - const LoadCanvasKit = new Promise(function(resolve, reject) { - if (CanvasKit) { - resolve(); - } else { - CanvasKitInit({ - locateFile: (file) => '/canvaskit/'+file, - }).ready().then((_CanvasKit) => { - CanvasKit = _CanvasKit; - resolve(); - }); - } - }); const LOTTIE_ANIMATIONS = ['lego_loader', 'drinks', 'confetti', 'onboarding']; diff --git a/experimental/canvaskit/tests/canvas2d.spec.js b/experimental/canvaskit/tests/canvas2d.spec.js index 411b6ba24a..f19db09cd3 100644 --- a/experimental/canvaskit/tests/canvas2d.spec.js +++ b/experimental/canvaskit/tests/canvas2d.spec.js @@ -1,22 +1,4 @@ -// The increased timeout is especially needed with larger binaries -// like in the debug/gpu build -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - describe('CanvasKit\'s Canvas 2d Behavior', function() { - // Note, don't try to print the CanvasKit object - it can cause Karma/Jasmine to lock up. - var CanvasKit = null; - const LoadCanvasKit = new Promise(function(resolve, reject) { - if (CanvasKit) { - resolve(); - } else { - CanvasKitInit({ - locateFile: (file) => '/canvaskit/'+file, - }).ready().then((_CanvasKit) => { - CanvasKit = _CanvasKit; - resolve(); - }); - } - }); let container = document.createElement('div'); document.body.appendChild(container); diff --git a/experimental/canvaskit/tests/canvaskitinit.js b/experimental/canvaskit/tests/canvaskitinit.js new file mode 100644 index 0000000000..fc976bb6f2 --- /dev/null +++ b/experimental/canvaskit/tests/canvaskitinit.js @@ -0,0 +1,13 @@ +// The increased timeout is especially needed with larger binaries +// like in the debug/gpu build +jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; + +let CanvasKit = null; +const LoadCanvasKit = new Promise(function(resolve, reject) { + CanvasKitInit({ + locateFile: (file) => '/canvaskit/'+file, + }).ready().then((loaded) => { + CanvasKit = loaded; + resolve(); + }); +}); \ No newline at end of file diff --git a/experimental/canvaskit/tests/font.spec.js b/experimental/canvaskit/tests/font.spec.js index 65281118eb..8bc9f52866 100644 --- a/experimental/canvaskit/tests/font.spec.js +++ b/experimental/canvaskit/tests/font.spec.js @@ -1,23 +1,4 @@ -// The increased timeout is especially needed with larger binaries -// like in the debug/gpu build -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - describe('CanvasKit\'s Path Behavior', function() { - // Note, don't try to print the CanvasKit object - it can cause Karma/Jasmine to lock up. - var CanvasKit = null; - const LoadCanvasKit = new Promise(function(resolve, reject) { - if (CanvasKit) { - resolve(); - } else { - CanvasKitInit({ - locateFile: (file) => '/canvaskit/'+file, - }).ready().then((_CanvasKit) => { - CanvasKit = _CanvasKit; - resolve(); - }); - } - }); - let container = document.createElement('div'); document.body.appendChild(container); const CANVAS_WIDTH = 600; diff --git a/experimental/canvaskit/tests/path.spec.js b/experimental/canvaskit/tests/path.spec.js index 35b33540e1..47ed8a1636 100644 --- a/experimental/canvaskit/tests/path.spec.js +++ b/experimental/canvaskit/tests/path.spec.js @@ -1,23 +1,4 @@ -// The increased timeout is especially needed with larger binaries -// like in the debug/gpu build -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - describe('CanvasKit\'s Path Behavior', function() { - // Note, don't try to print the CanvasKit object - it can cause Karma/Jasmine to lock up. - var CanvasKit = null; - const LoadCanvasKit = new Promise(function(resolve, reject) { - if (CanvasKit) { - resolve(); - } else { - CanvasKitInit({ - locateFile: (file) => '/canvaskit/'+file, - }).ready().then((_CanvasKit) => { - CanvasKit = _CanvasKit; - resolve(); - }); - } - }); - let container = document.createElement('div'); document.body.appendChild(container); const CANVAS_WIDTH = 600;