From f7a3566f222074630f10e94473f25cb68cb6bbc8 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Thu, 12 Jan 2023 18:29:29 +0100 Subject: [PATCH] DO NOT MERGE : bad workaroud to remaning bug This adds a sleep in renderReplacedElement so that drawimage works properly when the fix to svg files is used. Without that, it looks like drawImage fires too fast and the fix is not yet done (code is async here) So far I did not find out where I messed up with async code. Any help would be welcome ! --- src/render/canvas/canvas-renderer.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index f2ea6da..9b3c39d 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -265,6 +265,9 @@ export class CanvasRenderer extends Renderer { }); } + sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } async fixSVGImage( container: ReplacedElementContainer, image: HTMLImageElement | HTMLCanvasElement @@ -310,6 +313,7 @@ export class CanvasRenderer extends Renderer { this.path(path); this.ctx.save(); this.ctx.clip(); + await this.sleep(100); this.ctx.drawImage( img, 0,