π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Restore queue
Manav Rathi632c5b5acf19
diff --git a/web/packages/new/photos/services/ffmpeg/web.ts b/web/packages/new/photos/services/ffmpeg/web.tsindex cec054a78c..7678c93269 100644--- a/web/packages/new/photos/services/ffmpeg/web.ts+++ b/web/packages/new/photos/services/ffmpeg/web.ts@@ -6,10 +6,14 @@ import {inputPathPlaceholder,outputPathPlaceholder,} from "./constants";+import QueueProcessor from "@ente/shared/utils/queueProcessor";/** Lazily initialized and loaded FFmpeg instance. */let _ffmpeg: Promise<FFmpeg> | undefined;+/** Queue of in-flight requests. */+const _ffmpegTaskQueue = new QueueProcessor<Uint8Array>();+/*** Return the shared {@link FFmpeg} instance, lazily creating and loading it if* needed.@@ -46,8 +50,18 @@ export const ffmpegExecWeb = async (command: string[],blob: Blob,outputFileExtension: string,-): Promise<Uint8Array> =>- ffmpegExec(await ffmpegLazy(), command, outputFileExtension, blob);+): Promise<Uint8Array> => {+ const ffmpeg = await ffmpegLazy();+ // Interleaving multiple ffmpeg.execs causes errors like+ //+ // > "Out of bounds memory access (evaluating 'Module["_malloc"](len)')"+ //+ // So serialize them using a promise queue.+ const request = _ffmpegTaskQueue.queueUpRequest(() =>+ ffmpegExec(ffmpeg, command, outputFileExtension, blob),+ );+ return await request.promise;+};const ffmpegExec = async (ffmpeg: FFmpeg,