Closed Bug 2074107 Opened 2 months ago Closed 2 months ago

Setting canvas.filter="hue-rotate(0deg)" causes incorrect rendering of subsequent draws when the canvas filter is set to a non-zero hue-rotation.

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 156
defect

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox-esr153 --- fixed
firefox156 --- wontfix
firefox157 --- wontfix
firefox158 --- fixed
firefox159 --- fixed

People

(Reporter: tcathcartburn, Assigned: lsalzman)

References

(Regression)

Details

(Keywords: nightly-community, regression)

Attachments

(1 file, 3 external files)

Attached file hue-rotate-0.html —

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:156.0) Gecko/20100101 Firefox/156.0

Steps to reproduce:

View the attached file. It runs the same rendering code on 2 canvases (drawing a horizontal rectangle, then setting the filter to "hue-rotate(45deg)", then drawing a vertical rectangle and a png). The left canvas first has the filter set to "hue-rotate(0deg)" which should be equivalent to having no filter set.

Actual results:

The renderings look different. Exact behavior varies across Firefox versions - for my current version of Firefox, the vertical rectangle is not drawn on the left canvas and the image is drawn with something close to a hue-rotate by the negation of the specified angle. In other versions of Firefox with the bug, the vertical rectangle exhibits some transparency, is drawn partially, and/or behaves nondeterministically, changing between refreshes of the page.

Expected results:

The two canvases should be rendered identically.

If the code is stepped through in the javascript debugger, the bug does not manifest. If the canvas is any smaller than 128x128, the bug does not manifest

The bug first appears with https://phabricator.services.mozilla.com/D267531; my further investigation is based on the repository at that point in time.

In /gfx/src/FilterSupport.cpp, if the return value mozilla::gfx::ComputeColorMatrix (which indicates whether it has computed the identity matrix) is ignored, removing the conditional check for early return, then the bug goes away. However, this feels like the wrong fix, since it removes the useful optimization of doing less work when a filter shouldn't have any effect.

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

:lsalzman, since you are the author of the regressor, bug 1947364, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)
Severity: -- → S3
Flags: needinfo?(lsalzman)

When an identity color matrix is supplied, this may generate a filter sequence of premul-crop-unpremul
instead of the expected premul-crop-colormatrix-unpremul. This caused a fallback to a software filter
that failed to read back from an A8 accelerated textures.

This fixes the A8 readback to work and plumbs the necessary pathway through FilterNodeWebgl::Draw to
avoid the fallback.

Assignee: nobody → lsalzman
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

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

Pushed by lsalzman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ef3da716dc4d https://hg.mozilla.org/integration/autoland/rev/0879644e88e9 Properly support an identity color matrix with accelerated filters. r=gfx-reviewers,aosmond

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

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch

The patch landed in nightly and beta is affected, along with ESR.

:lsalzman, please make an uplift decision for each affected release:

  • For beta, nominate the patch for beta uplift approval if the fix should be included in this release, or set status-firefox158 to wontfix if the fix can wait for the next release.
  • For ESR, nominate the patch for the appropriate ESR uplift approval if the fix should be included in ESR, or set the ESR status flag(s) to wontfix if an uplift isn't needed. Each affected ESR release needs a decision.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)
Flags: needinfo?(lsalzman)

When an identity color matrix is supplied, this may generate a filter sequence of premul-crop-unpremul
instead of the expected premul-crop-colormatrix-unpremul. This caused a fallback to a software filter
that failed to read back from an A8 accelerated textures.

This fixes the A8 readback to work and plumbs the necessary pathway through FilterNodeWebgl::Draw to
avoid the fallback.

Original Revision: https://phabricator.services.mozilla.com/D328744

Attachment #9648644 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Incorrect rendering of filters with accelerated canvas
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Fixes handling of certain filter combinations
  • String changes made/needed?: None
  • Is Android affected?: yes

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: Incorrect rendering of filters with accelerated canvas
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Fixes handling of certain filter combinations
  • String changes made/needed?: None
  • Is Android affected?: yes
Attachment #9648645 - Flags: approval-mozilla-esr153?

When an identity color matrix is supplied, this may generate a filter sequence of premul-crop-unpremul
instead of the expected premul-crop-colormatrix-unpremul. This caused a fallback to a software filter
that failed to read back from an A8 accelerated textures.

This fixes the A8 readback to work and plumbs the necessary pathway through FilterNodeWebgl::Draw to
avoid the fallback.

Original Revision: https://phabricator.services.mozilla.com/D328744

Attachment #9648644 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9648645 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
QA Whiteboard: [qa-triage-done-c160/b159]
See Also: → 2094571
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: