Blur drawing artifacts on https://neon-bindings.com

RESOLVED FIXED in Firefox 67

Status

()

P4
normal
RESOLVED FIXED
2 months ago
a month ago

People

(Reporter: jrmuizel, Assigned: nical)

Tracking

(Blocks: 1 bug)

unspecified
mozilla67
Points:
---

Firefox Tracking Flags

(firefox67 fixed)

Details

Attachments

(8 attachments)

(Reporter)

Description

2 months ago

It seems like something is going wrong with picture caching and the bluring.

(Reporter)

Updated

2 months ago
Blocks: 1386669
Priority: -- → P4
(Assignee)

Comment 1

2 months ago
Posted file reduced test case
(Reporter)

Updated

2 months ago
Assignee: nobody → nical.bugzilla
(Assignee)

Comment 2

2 months ago

Good news (I think?): this isn't picture caching related, but picture caching makes the glitch more visible because the frame where the issue happens can be cached.

The problem can be observed with picture caching disabled, by scrolling slowly the reduced test case such that the blurred text is partially off-screen. The blur is more intense on some frames than on other frames (by the look of it, it depends on how much of the text is partially clipped).

(Assignee)

Comment 3

2 months ago

I'm not yet 100% sure but I think that this is caused by us clipping the blurred element before blurring rather than after blurring (or rather clipping to the visible region rather than the visible region + some headroom for the blur before blurring).

I am wondering if we are losing some pixels during the down-scaling which would cause some frames to have brighter blurs than other frames depending on how clipping played out.

(Assignee)

Comment 4

2 months ago

By a look at the intermediate targets in renderdoc, the down-scaling phase doesn't "preserve energy" uniformly depending on the position. If I draw the same glyph at different (integer) positions, some of the down-scaled versions will look brighter than others. This results in brighter/darker blurs.

My guess is that the down-scaling pass isn't sampling exactly between texels everywhere which is why some the down-scaled glyphs look different. The fact sampling isn't playing out exactly the same shouldn't be an issue if the same amount of "energy" (as in brightness) is preserved, but it looks like it isn't the case. we are dividing the size by two and the linear interpolation of the sampler should mean no under-sampling, but the (perceptual)energy preservation really only works if we are in linear space.
So I wonder if the fact that we do this in srgb space instead of linear space is the reason the down-scaling perceptually doesn't produce the same amount of brightness depending on the position in the source.

That said it's hard to be 100% sure by eyeballing intermediate results in renderdoc without being certain that the latter isn't making wrong assumptions about the color space of the intermediate texture.

In general blurring in srgb is wrong. Probably not a big deal if it's consistently wrong, but if the wrong-ness changes with positions, then it becomes a lot more noticeable.

(Reporter)

Updated

2 months ago
Summary: Drawing artifacts on https://neon-bindings.com → Blur drawing artifacts on https://neon-bindings.com
(Assignee)

Comment 5

2 months ago

Nevermind what I said about srgb. Blurring in srgb is technically wrong but the flickering issue we have here is the same in linear color space.
Still in "energy preservation" terms, down-scaling the way we do it only works if we sample exactly between pixels which means we need to make sure that the size of the source of the scaling pass is exactly twice the size of the destination. I can see in my test cases that artifacts are introduced as soon as a down-scaling doesn't meet this size requirement.

(Assignee)

Comment 6

2 months ago
Posted image blur passes

In the image, from top to bottom:

  • the output of the first down-scale pass where the size of the output was exactly the size of the input
  • the output of the second down-scale pass where the size requirement wasn't met
  • vertical blur
  • horizontal blur

We can see that some glyphs got darker than others at the second down-scale pass and stayed darker after the blur although blurring makes it a bit less noticeable. The original test case has a lot of text shadows stacked on top of one another which amplifies the error.

(Assignee)

Comment 7

2 months ago

For some reason I had to draw this to really wrap my head around the issue, even though it is quite simple.

The first row represents the source image with an odd size and the second row the down-sampled result. the colors show which pixels in the source affect which pixels in the destination.

There's a pixel that never even gets sampled and for the rest, the closer to the center the more we see destination pixels that get contributions from one pixel but not the other due to linear interpolation.

Comment 12

a month ago
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8db55f13f405
Adjust shadow blur target sizes to avoid down-scaling artifacts. r=gw
https://hg.mozilla.org/integration/mozilla-inbound/rev/8d99e173cdf6
Adjust blur target sizes to avoid down-scaling artifacts. r=gw
https://hg.mozilla.org/integration/mozilla-inbound/rev/23406bc33980
Adjust reftest fuzziness. r=kats
https://hg.mozilla.org/integration/mozilla-inbound/rev/09de2f84aa1c
Update reference image. r=gw

Comment 13

a month ago
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d8ac233a5d1
Update reference image on a CLOSED TREE. r=me

Backed out 5 changesets (Bug 1523495) for reftest failures in file:///builds/worker/workspace/build/tests/reftest/tests/gfx/tests/reftest/1523776.html CLOSED TREE

https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&selectedJob=227633874

https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=227633874&repo=mozilla-inbound&lineNumber=9105

[task 2019-02-11T14:37:11.258Z] 14:37:11 INFO - REFTEST TEST-UNEXPECTED-PASS | file:///builds/worker/workspace/build/tests/reftest/tests/gfx/tests/reftest/1523776.html == file:///builds/worker/workspace/build/tests/reftest/tests/gfx/tests/reftest/1523776-ref.html | image comparison, max difference: 5, number of differing pixels: 29926

Flags: needinfo?(nical.bugzilla)

Comment 15

a month ago
Backout by shindli@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e2806772432
Backed out 5 changesets for reftest failures in file:///builds/worker/workspace/build/tests/reftest/tests/gfx/tests/reftest/1523776.html CLOSED TREE

Comment 16

a month ago
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4f7935bfb0eb
Adjust shadow blur target sizes to avoid down-scaling artifacts. r=gw
https://hg.mozilla.org/integration/mozilla-inbound/rev/782ec3fc98e0
Adjust blur target sizes to avoid down-scaling artifacts. r=gw
https://hg.mozilla.org/integration/mozilla-inbound/rev/1559889f35e7
Reftests adjustments. r=gw,kats,nical
(Assignee)

Updated

a month ago
Flags: needinfo?(nical.bugzilla)

Comment 17

a month ago
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b3f7df7c7a53
More reftest threshold adjustments in a CLOSED TREE.

Comment 18

a month ago
bugherder
Status: NEW → RESOLVED
Last Resolved: a month ago
status-firefox67: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.