Skip to content

Commit 1835e08

Browse files
committed
Fix image loading in BitmaskRegion
Refactors image loading to use the onload event as a fallback, ensuring region finalization. Calls onload manually after successful decode to maintain consistent behavior. The Bug is known for Chromium: https://issues.chromium.org/issues/40792189 This change fixes the problem by using onload as seperate call.
1 parent a9122d0 commit 1835e08

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

web/libs/editor/src/regions/BitmaskRegion.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,19 @@ const Model = types
176176

177177
image.src = self.imageDataURL;
178178

179-
try {
180-
await image.decode();
179+
// Fallback onload
180+
image.onload = () => {
181181
context.canvas.width = image.naturalWidth;
182182
context.canvas.height = image.naturalHeight;
183183
bitmask.width = image.naturalWidth;
184184
bitmask.height = image.naturalHeight;
185-
186185
context.drawImage(image, 0, 0);
187-
188186
self.finalizeRegion();
187+
};
188+
189+
try {
190+
await image.decode();
191+
image.onload(); // on success of decode() onload() get called manually
189192
} catch (err) {
190193
console.log(err);
191194
}

0 commit comments

Comments
 (0)