Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ function addImageMenuOptions(
theOneCanvasElementManager.setActiveElement(
bgImageCe,
);
theOneCanvasElementManager.expandImageToFillSpace();
});
Comment on lines 1915 to 1919
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Potential race between expandImageToFillSpace and deferred adjustBackgroundImageSize from updateCanvasElementForChangedImage

When haveRealBgImage is true, updateCanvasElementForChangedImage(bgImg) at line 1904 calls adjustBackgroundImageSize with useSizeOfNewImage=true, which sets up a deferred adjustment (~100ms timeout or image load listener) at CanvasElementManager.ts:7276-7312. Then expandImageToFillSpace() runs in the next animation frame (~16ms). If expandImageToFillSpace succeeds first (setting bgCanvasElement to fill the canvas), the deferred adjustment computes imgAspectRatio from the now-filled canvas element dimensions (CanvasElementManager.ts:7317-7319), which equals the container aspect ratio, so it re-sets the same dimensions — effectively a no-op. The cropping adjustment at CanvasElementManager.ts:7424 also computes a scale of ~1, preserving the fill. So the race resolves correctly. If expandImageToFillSpace fails (image not loaded), the deferred adjustment puts the image in 'contain' mode (not 'fill'), meaning the fill intent of this PR wouldn't take effect for the haveRealBgImage case. This is unlikely since the image was previously displayed as an overlay and should be browser-cached.

(Refers to lines 1904-1919)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a classic Devin "if something changed you might have a problem". I don't think it's worth addressing.

};
activateConvertedBackground();
Expand Down