feat(canvas): move image pipeline rendering off main thread with worker fallback

This commit is contained in:
2026-04-03 19:17:42 +02:00
parent 7e1a77c38c
commit 7e87a74df9
9 changed files with 652 additions and 25 deletions

View File

@@ -93,7 +93,9 @@ function resolveMimeType(format: RenderFormat): string {
}
export async function renderFull(options: RenderFullOptions): Promise<RenderFullResult> {
const bitmap = await loadSourceBitmap(options.sourceUrl);
const { signal } = options;
const bitmap = await loadSourceBitmap(options.sourceUrl, { signal });
const resolvedSize = resolveRenderSize({
sourceWidth: bitmap.width,
sourceHeight: bitmap.height,
@@ -111,7 +113,15 @@ export async function renderFull(options: RenderFullOptions): Promise<RenderFull
options.steps,
resolvedSize.width,
resolvedSize.height,
{
shouldAbort: () => Boolean(signal?.aborted),
},
);
if (signal?.aborted) {
throw new DOMException("The operation was aborted.", "AbortError");
}
context.putImageData(imageData, 0, 0);
const mimeType = resolveMimeType(options.render.format);