Closed Bug 1639574 Opened 5 years ago Closed 5 years ago

getImageData returns incorrect pixel information

Categories

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

77 Branch
Desktop
All
defect

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox-esr68 --- unaffected
firefox76 --- unaffected
firefox77 --- fixed
firefox78 --- fixed

People

(Reporter: lavrton, Assigned: aosmond)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

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

Steps to reproduce:

Try to getImageData of the red rectangle.

const ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(255, 0, 0)';
ctx.fillRect(0, 0, 100, 100);
const data = ctx.getImageData(50, 50, 1, 1).data;
console.log(data[0], data[1], data[2]);

https://jsbin.com/jaqaqeboro/edit?js,console,output

Actual results:

getImageData returns incorrect pixel information. For me, it was (252, 13, 27).

Expected results:

The expected result is (255, 0, 0).

The same happening with any color I tried.
Online demo: https://jsbin.com/jaqaqeboro/edit?js,console,output

Hi Anton,

I was able to reproduce the issue on Firefox Nightly 78.0a1 and Firefox Beta 77.0b9 however Firefox 76.0.1 returns (255.0.0) correctly.

I've ran mozregression and got the following pushlog:

https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=ad3f58c996e59bc5ca0a0e6aac61c8f6a7e51096&tochange=6392325ec39e5cb10edd4aaaa4afb7a9f061b0b2

Bug 455077 seems to have introduced this issue.
Andrew, could you take a look?

Thank you for reporting!

Severity: -- → S3
Status: UNCONFIRMED → NEW
Component: Untriaged → Canvas: 2D
Ever confirmed: true
Flags: needinfo?(aosmond)
OS: Unspecified → macOS
Product: Firefox → Core
Regressed by: mode-one
Hardware: Unspecified → All
Version: 77 Branch → Trunk
Has Regression Range: --- → yes
Priority: -- → P1

Andrew, could that be the same problem as I noticed with the drawSnapshot() API over on bug 1631089?

Assignee: nobody → aosmond
Status: NEW → ASSIGNED
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fc441aa39120 Disable color management for CSS due to issues with canvas. r=jrmuizel
Severity: S3 → S1
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7f7e74f8b2e3 Disable color management for CSS due to issues with canvas. r=jrmuizel

Comment on attachment 9151777 [details]
Bug 1639574 - Disable color management for CSS due to issues with canvas.

Beta/Release Uplift Approval Request

  • User impact if declined: Canvas color management will be broken.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This simply reverts our behaviour to what it was in the previous release. The pref is used in very few places, and the branches done as a result are very small (massages CSS colors to be more correct for display). There is very good test coverage on this.
  • String changes made/needed:
Flags: needinfo?(aosmond)
Attachment #9151777 - Flags: approval-mozilla-release?
Severity: S3 → S1
OS: macOS → All
Hardware: All → Desktop
Version: Trunk → 77 Branch
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78

I assume we should reopen this bug and should keep it blocking bug 455077? Or where should the remaining work for canvas be tracked?

Flags: needinfo?(aosmond)

Comment on attachment 9151777 [details]
Bug 1639574 - Disable color management for CSS due to issues with canvas.

Driver for RC2, approved for uplift.

Attachment #9151777 - Flags: approval-mozilla-release? → approval-mozilla-release+
See Also: → 1641229

I filed bug 1641229 to track the canvas issues.

Flags: needinfo?(aosmond)
Attachment #9152135 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: