From 823a7abebf5c77a9eae9226043e71e601c8ea08d Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Sun, 18 Aug 2019 14:14:11 +0200 Subject: [PATCH] fix(workers/blurhash): Don't use OffscreenCanvas (#1398) --- src/routes/_workers/blurhash.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/_workers/blurhash.js b/src/routes/_workers/blurhash.js index 81238780..08b70a76 100644 --- a/src/routes/_workers/blurhash.js +++ b/src/routes/_workers/blurhash.js @@ -2,7 +2,11 @@ import { decode as decodeBlurHash } from 'blurhash' import registerPromiseWorker from 'promise-worker/register' import { BLURHASH_RESOLUTION as RESOLUTION } from '../_static/blurhash' -const OFFSCREEN_CANVAS = typeof OffscreenCanvas === 'function' +const isChrome = /Chrome/.test(navigator.userAgent) + +// Disabled in Chrome because convertToBlob() is slow +// https://github.com/nolanlawson/pinafore/issues/1396 +const OFFSCREEN_CANVAS = !isChrome && typeof OffscreenCanvas === 'function' ? new OffscreenCanvas(RESOLUTION, RESOLUTION) : null const OFFSCREEN_CANVAS_CONTEXT_2D = OFFSCREEN_CANVAS ? OFFSCREEN_CANVAS.getContext('2d') : null