Closed Bug 1850871 Opened 1 years ago Closed 1 year ago

BitmapRenderer draws contents the wrong size

Categories

(Core :: Graphics: Canvas2D, defect, P3)

Firefox 119
defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox120 --- fixed

People

(Reporter: mozilla2, Assigned: aosmond)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Steps to reproduce:

Run https://jsgist.org/?src=7dd4869ec2e14cfc1c3a62cb9c14741e or the attached file

Actual results:

Only the top 300x150 pixels of the 2000x1000 image are displayed

Expected results:

The 2000x1000 image should have been scaled to fit the canvas (300x150)

Run the same example in Chrome or Safari for comparison

Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core

Thanks for the bug report! In Chrome I see what you describe as the expected result, with the full image scaled to 300x150. And in Firefox I indeed see only the top-left 300x150 pixels.

In Safari, however, I see the canvas size is updated to 2000x1000 pixels and the bitmap is displayed at full size.

My feeling is that both Firefox and Chrome have it wrong, and Safari does the right thing. See this discussion

Andrew, I know you had to figure out lots of canvas spec things for offscreen canvas, does that seem right to you?

Flags: needinfo?(aosmond)

you are probably right. an img tag with no width and height attributes wipp change it's display size when the src image changes. this seems similar

Assignee: nobody → aosmond
Severity: -- → S3
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(aosmond)
Priority: -- → P3

A more recent discussion of this issue is https://github.com/whatwg/html/issues/7833. I'm happy to implement this once we achieve consensus, but the discussion still seems to be unresolved. FWIW, there don't appear to be any WPT tests impacted by the behaviour so this isn't an issue for interop-2023.

Severity: S3 → S4

I just posted what our most recent consensus was to whatwg/html#7833, from when we talked about this extensively in the WebGL WG. (last talk 2023-01-12, though I'm looking at the text pulled from the 2023-05-04 minutes)

This patch makes it so that when a new ImageBitmap is provided to an
ImageBitmapRenderingContext, we resize its owning canvas rather than
crop or scale the given ImageBitmap to fit inside the canvas dimensions.

See discussion in https://github.com/whatwg/html/issues/7833.

Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cbd593a4819d Resize canvas in ImageBitmapRenderingContext::TransferFromImageBitmap. r=gfx-reviewers,lsalzman
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: