Closed Bug 2010125 Opened 3 months ago Closed 2 months ago

createImageBitmap() ignores sx,sy,sw,sh parameters when using resize option

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 147
defect

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr140 --- wontfix
firefox147 --- wontfix
firefox148 --- wontfix
firefox149 --- fixed

People

(Reporter: serguei.ivantsov, Assigned: lsalzman)

References

(Regression)

Details

(Keywords: dev-doc-complete, regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0

Steps to reproduce:

Using the sample 50x50 image from the manual, let's try to crop it:

createImageBitmap(image, 40, 40, 10, 10, {
        resizeWidth: 50,
        resizeHeight: 50,
        resizeQuality: 'pixelated',
    })

Actual results:

resulting image is original image

Expected results:

resulting image should be cropped using 10x10px from the right-bottom of original image and scaled to 50x50px

this works properly in Safari and Chrome

Attached file test.html
Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core

Hello, thank you for the bug report!
I managed to reproduce this issue on:

  • Firefox Nightly 149.0a1;
  • Firefox 148.0b5;

Tested and reproduced on:

  • Windows 10;
  • Ubuntu 22;
  • macOS 15;

Setting as NEW.

Status: UNCONFIRMED → NEW
Ever confirmed: true

The severity field is not set for this bug.
:lsalzman, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)

The severity field is not set for this bug.
:lsalzman, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)
Severity: -- → S3
Flags: needinfo?(lsalzman)
Keywords: regression
Regressed by: 1733559

Set release status flags based on info from the regressing bug 1733559

Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Pushed by lsalzman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e252b0e324b1 https://hg.mozilla.org/integration/autoland/rev/78b2902cb1ef Use crop rect and resize quality when resizing ImageBitmap. r=aosmond,webidl,saschanaz
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch

FF149 MDN docs for this can be tracked in https://github.com/mdn/content/issues/43429

Looking at the discussion and changes, what I think this delivers is full support for the options.resizeQuality in Window.createImageBitmap() and WorkerGlobalScope.createImageBitmap(). Previously if a value was set for this property the function just returned the original bitmap. Is that right?

Is there a particular release note you would like? Note that the compatibility data appears to already have been updated.

Flags: needinfo?(lsalzman)

(In reply to Hamish Willee from comment #9)

Looking at the discussion and changes, what I think this delivers is full support for the options.resizeQuality in Window.createImageBitmap() and [WorkerGlobalScope.createImageBitmap()]

Hi, not exactly. Before either (sx, sy, sw, sh) or options.resize* parameters worked, i.e. not simultaneously.

Hi @Serguei, So I the reason I assumed that this added support for options.resizeQuality was because:

  1. The WebIDL seems to have added this option in this issue, which also added the Enum for the options and so on - see https://github.com/mozilla-firefox/firefox/commit/e252b0e324b1#diff-2d17dae6ae7be7746e1db91d27dd55a017a97823d7e6a7c79d4d0f3130cef30c
  2. The compatibility tests spotted the existance of this option for the first time https://github.com/mdn/browser-compat-data/pull/29135/changes#diff-0c05570d9108608f1e8895adaba621feb7ab86f1f793195f329273c40cd798e9R284

So just to be very clear the browser compat data is wrong? You could always specify options.resizeQuality and it would be used - just not with (sx, sy, sw, sh) also used? (I ask, because I'll need to get the compatibility data looked at).

Worries me a bit. I thought I knew how to interpret IDL updates :-(

Sorry for confusion.
Original report was about (sx, sy, sw, sh) and options.resize* did not work together.
I.e. it was not possible crop and resize in a single call. Regardless of resizeQuality.
But I just checked the commit, and found that resizeQuality is also fixed - before it was ignored.
So there are two fixes here.
Maybe @lsalzman can explain better.

@Serguei - thanks very much. That is consistent with what I was seeing (i.e. a good explanation). I'll proceed with this, but leave the request open for @lsalzman just in case there is more to add.

(In reply to Serguei Ivantsov from comment #12)

Sorry for confusion.
Original report was about (sx, sy, sw, sh) and options.resize* did not work together.
I.e. it was not possible crop and resize in a single call. Regardless of resizeQuality.
But I just checked the commit, and found that resizeQuality is also fixed - before it was ignored.
So there are two fixes here.
Maybe @lsalzman can explain better.

So I did indeed fix resizeWidth and resizeHeight to work properly. But during testing, resizeQuality being broken was also preventing me from testing it properly. Given that fixing resizeQuality to thus work was such a small change, I just went ahead and fixed it to get the tests passing.

Flags: needinfo?(lsalzman)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: