Closed Bug 1642549 Opened 4 years ago Closed 4 years ago

Incorrect rendering for scaled mix-blend pictures with non-zero content offset

Categories

(Core :: Graphics: WebRender, defect)

defect

Tracking

()

VERIFIED FIXED
mozilla79
Tracking Status
firefox-esr68 --- unaffected
firefox76 --- unaffected
firefox77 --- unaffected
firefox78 --- verified
firefox79 --- verified

People

(Reporter: cbrewster, Assigned: cbrewster)

References

(Regression)

Details

(Keywords: correctness, regression)

Attachments

(3 files)

Attached file test-case.html

While looking into bug 1642072 I noticed some textures were rendering incorrectly on the demo at https://keithclark.co.uk/labs/css-fps/nojs/

I was able to narrow it down to smaller test-case, we incorrectly render elements that have a perspective transform, background-blend-mode, and are partially clipped by the viewport bounds.

This is a regression from bug 1559861 which changes surface device pixel scaling on the fly.

This also occurs when using a filter effect or opacity instead of background-blend-mode. The intermediate targets appear to be rendering correctly, so I suspect this means that the brush_opacity, brush_blend, and brush_mix_blend shaders don't handle the perspective transform + scaling factor case quite right.

Edit: This happens with any of the brush shaders rendering a perspective transformed picture with a different device pixel scale than the surface being rendered into.

Flags: needinfo?(gwatson)
Flags: needinfo?(bpeers)
Severity: -- → S2
Flags: needinfo?(jbonisteel)

I've narrowed this down a bit more. The incorrect rendering happens when (1) a picture task has a different device pixel scale than the parent surface it will be composited into and (2) the picture task has a non-zero content offset (due to viewport clipping or inflation from blur/drop-shadow).

I think part of the problem is that when we composite a picture into a parent picture, we assume that both pictures share the same "device space", but this is not always the case (either due to my scaling patch, or the 4096x4096 max picture size check).

Summary: Rendering artifacts when rendering elements with background-blend-mode and perspective transforms → Incorrect rendering for scaled picture tasks with non-zero content offset

Thanks for investigating! Yes we do need to explicitly handle the different scaling factors of different "inputs".
Here is an example diff where the code used to assume that source, backdrop and output are all in the same scale and so offsets and UVs can just be shared. Unfortunately that assumption is silent so that can be hard to find -- it's a bug by omission :)

There may be other shaders that need to be fixed, and/or maybe I didn't get that patch quite right, and/or you've hit another subtlety :) -- but hopefully this gives some context. Thanks.

Flags: needinfo?(bpeers)

S1 or S2 bugs need an assignee - could you find someone for this bug?

I'm working on a fix for this.

Assignee: nobody → connorbrewster
Flags: needinfo?(jbonisteel)

Sounds like you have the info needed from Bert, ping me again if there is more to follow up here.

Flags: needinfo?(gwatson)

When handling mix-blend readbacks, we need to calculate the origin of the source picture in the backdrop's space.
Before this patch, this was done by scaling the source picture origin by the backdrop's device pixel scale.
However, this is the incorrect scaling; We really want the relative scale between source and backdrop instead.
This patch computes the relative scaling from the device pixel scale of both the source and backdrop pictures.

This bug likely went unnoticed because the device pixel scale used to be 1 in most cases, but now we sometimes
increase the device pixel scale for raster roots.

Thanks for the info Bert, that was very helpful!

Looks like I have been battling two different bugs (which led to a very confusing day). The bug introduced by bug 1559861 only applies to mix-blend pictures. (Which is fixed by the patch I just attached)

The other bug causes the stretching seen in the test case, but it is unrelated to the mix-blend offset bug. Also, mozregression shows that it is not a regression from bug 1559861. I'll open a new issue so we can track that separate from this bug. (Bug 1643236)

Summary: Incorrect rendering for scaled picture tasks with non-zero content offset → Incorrect rendering for scaled mix-blend pictures with non-zero content offset
Blocks: wr-79
No longer blocks: gfx-triage
Pushed by ncsoregi@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b4db2b3b6b8e
Fix incorrect offset scaling when handling mix-blend readback r=gw
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79

The patch landed in nightly and beta is affected.
:cbrewster, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(connorbrewster)
Attached image incorrect-rendering.png
Flags: needinfo?(connorbrewster)

Comment on attachment 9154075 [details]
Bug 1642549: Fix incorrect offset scaling when handling mix-blend readback r=gw,Bert

Beta/Release Uplift Approval Request

  • User impact if declined: Incorrect rendering of elements with mix-blend modes and perspective transforms. For example, https://keithclark.co.uk/labs/css-fps/nojs/ renders incorrectly.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Go to https://keithclark.co.uk/labs/css-fps/nojs/ and watch the animation for 10-20 seconds.
    Some wall textures are incorrectly offset. See the attached incorrect-rendering.png for an example.
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is a very small patch with test coverage. It only affects rendering in rare cases (mix-blend + perspective). If this causes any problems, it will be easy to back out.
  • String changes made/needed: none
Attachment #9154075 - Flags: approval-mozilla-beta?
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

This issue is verified as fixed in our latest build 79.0a1 (2020-06-08) on Windows 10.

Comment on attachment 9154075 [details]
Bug 1642549: Fix incorrect offset scaling when handling mix-blend readback r=gw,Bert

approved for 78.0b5

Attachment #9154075 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: in-testsuite+

This issue is Verified as fixed in our latest Beta build 78.0b7 on Windows 10.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: