From 452d0e037c694ba061e57c8b2c73ac35ecfe3729 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Tue, 3 Sep 2024 18:19:46 +0000 Subject: [PATCH] web/webcodecs: instantiate polyfill once per lifetime --- web/src/lib/libav/webcodecs.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/lib/libav/webcodecs.ts b/web/src/lib/libav/webcodecs.ts index fc841f34..3023b858 100644 --- a/web/src/lib/libav/webcodecs.ts +++ b/web/src/lib/libav/webcodecs.ts @@ -6,12 +6,12 @@ const has = (obj: T, key: string) => { } export default class WebCodecsWrapper { - #ready?: Promise; + static #ready?: Promise; async load() { LibAV.base = '/_libav'; - if (typeof this.#ready === 'undefined') { - this.#ready = LibAVPolyfill.load({ + if (typeof WebCodecsWrapper.#ready === 'undefined') { + WebCodecsWrapper.#ready = LibAVPolyfill.load({ polyfill: true, LibAV, libavOptions: { @@ -21,7 +21,7 @@ export default class WebCodecsWrapper { }); } - await this.#ready; + await WebCodecsWrapper.#ready; } // FIXME: save me generics. generics save me