diff --git a/src/client/lazy-app/util/web-codecs/index.ts b/src/client/lazy-app/util/web-codecs/index.ts index 76441d71..7f2b1949 100644 --- a/src/client/lazy-app/util/web-codecs/index.ts +++ b/src/client/lazy-app/util/web-codecs/index.ts @@ -1,12 +1,19 @@ import { drawableToImageData } from '../canvas'; const hasImageDecoder = typeof ImageDecoder !== 'undefined'; + export async function isTypeSupported(mimeType: string): Promise { - if (!hasImageDecoder) { + if (!hasImageDecoder) return false; + // Some old versions of this API threw here. + // It only impacted folks with experimental web platform flags enabled in Chrome 90. + // The API was updated in Chrome 91. + try { + return await ImageDecoder.isTypeSupported(mimeType); + } catch (err) { return false; } - return ImageDecoder.isTypeSupported(mimeType); } + export async function decode( blob: Blob | File, mimeType: string,