Open Bug 1124060 Opened 10 years ago Updated 2 years ago

Premultiplication destroys some alpha images in web content use cases

Categories

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

defect

Tracking

()

People

(Reporter: noel.gordon, Unassigned)

Details

(Keywords: parity-safari, reproducible, testcase, Whiteboard: [gfx-noted])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36

Steps to reproduce:

For example, encoding <canvas> content via toDataURL as image/png (lossless) into a new Image(), where the canvas contains alpha values near 0.5, and then drawing that Image() onto a new canvas with drawImage(), and repeating this process over and over, should be idempotent.  For some alpha values, the image is slowly destroyed.

Test case attached: for Firefox, set alpha=0.498 for example, and keep pressing the test button.


Actual results:

The canvas image slowly fades to gray with each test button press.

Other browsers:
  IE9+: works.
  Chrome 39 stable: broken.
  Firefox 33.0.3: broken.
  Safari 6: broken.
  Safari 7: works.



Expected results:

The canvas image should not fade away for any alpha in the neigbourhood of 0.5.
Attached image firefox-33.0.3.png
Test-case result for alpha=0.498 on Firefox 33.0.3
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Product: Firefox → Core
Hardware: x86_64 → All
Whiteboard: [parity-Safari]
Version: 33 Branch → Trunk
Seth, can you help place/prioritize/find-a-someone for this? Not sure if this is canvas, imagelib, gfx, or somewhere in the middle. :-)
Flags: needinfo?(seth)
This probably exists at the intersection of canvas and ImageLib, which is good news since I'm about to start focusing on canvas work once I get the recent ImageLib regressions cleaned up.

I'll come back to this once I switch over to canvas.
I believe that Gecko uses (or once used) a table-driven method to compute pixel alpha pre-multiplication. Perhaps the table data was computed from a truncating pre-multiply routine?

Perhaps try a rounding one.  That was the problem in Chrome a least - a truncating premultiply in the image decoders. I changed the decoders to use a rounding pre-multiply and the alpha channel instability was gone.

HTH.
Component: Untriaged → ImageLib
I actually suspect this is more likely to be in the Canvas code. We should probably just fix this.
Whiteboard: [parity-Safari] → [parity-Safari][gfx-noted]
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Keywords: parity-safari
Whiteboard: [parity-Safari][gfx-noted] → [gfx-noted]

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit auto_nag documentation.

Flags: needinfo?(seth.bugzilla)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: