Update src/client/lazy-app/util/index.ts

Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
This commit is contained in:
Surma
2021-05-24 16:26:05 +01:00
committed by GitHub
parent 96b6dc8e6e
commit cbfa503fcb

View File

@@ -249,15 +249,13 @@ export async function builtinDecode(
return await WebCodecs.decode(blob, mimeType); return await WebCodecs.decode(blob, mimeType);
} catch (e) {} } catch (e) {}
} }
if (signal.aborted) return Promise.reject('Aborted'); assertSignal(signal);
// Prefer createImageBitmap as it's the off-thread option for Firefox. // Prefer createImageBitmap as it's the off-thread option for Firefox.
const drawable = const drawable = await abortable(
'createImageBitmap' in self signal,
? await createImageBitmap(blob) 'createImageBitmap' in self ? createImageBitmap(blob) : blobToImg(blob),
: await blobToImg(blob); );
if (signal.aborted) return Promise.reject('Aborted');
return drawableToImageData(drawable); return drawableToImageData(drawable);
} }