Open Bug 1763221 Opened 3 years ago Updated 3 years ago

CSS gradient rendering glitches producing jagged artefacts, device pixel ratio or zoom level dependent

Categories

(Core :: Graphics, defect)

defect

Tracking

()

UNCONFIRMED

People

(Reporter: myf, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(10 files)

Sharp linear gradients sometimes produce chaotically jagged edges. Symptoms are heavily dependant on concrete (sub-pixel) values, device pixel ratio and/or zoom level: attached testcase was created and documented on monitor with 150 scale factor, i.e. DPR ratio 1.5 at browser 100% zoom level or 150% browser zoomed page on 100% factored monitor. 300% zoom level also works for both factors, and 50% zoom on 150% factored monitor (DPR 0.75) is probably best demonstration (used for first attached screenshot).

Testcase source:

<title>
CSS gradient rendering jagged artifacts glitch
</title>
<p style="
 font-size: calc(2em / var(--dpr));
">DPR: <output id=dpr></output>
<script>
 (onresize=()=>document.body.style.setProperty(
 '--dpr',dpr.value=devicePixelRatio))()
</script>
<div style="
 width: 100px; height: 100px;
 transform: scale(calc(1 / var(--dpr))) scale(5);
 transform-origin: 0 0;
 background-image: linear-gradient(
  45deg,
  white 0 42.1612377166748011px,
  /* First edge OK if ....010px */
  black 0 67.88224411010741466px,
  /* BOTH edges OK if .....465px */
  white 0
 );
"></div>

Symptoms are scattered across more bugs, most notable is probably closed Bug 1185636 but haven't found any with concise testcases and demonstrations.


Bug observed on badges made by www.westandwithukraine.eu .

For reference, testcase in 50% zoom (0.75 DPR) rendered with Blink.

:gw, can you comment to the bug?

Flags: needinfo?(gwatson)

It's hard to say what is going on here without doing a detailed investigation first. We do cache linear gradients in the render task cache, it's possible that the scale factors are not being determined very well - though the artifacts look a bit different to a normal up-sampling issue.

Flags: needinfo?(gwatson)

First tescase without DRP negation, rescaled to 600% size, nearest neighbour. (Crisp edge visible.)

Capture of first testcase in all zoom levels provided by toolbar buttons; glitch occurs at 50%, 100%, 200% and 400% zoom levels.

Capture of the second testcase: changing colour stop positions. First stop from produces glitches around values 8.5, 12.1, 17.1, 20.9, 25.2, 27.7 etc. Changing the second stop's position smoothens both edges.

Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: