Open Bug 1720893 (wr-gradients) Opened 3 years ago Updated 20 days ago

[meta] [project] Fix gradient correctness issues

Categories

(Core :: Graphics: WebRender, task, P3)

task

Tracking

()

People

(Reporter: nical, Assigned: nical)

References

(Depends on 17 open bugs, Blocks 1 open bug)

Details

(Keywords: meta)

Edit: This started as a meta bug for pixelated gradients and ended up covering all gradient quality/correctness issues. Pixelated gradients are now tracked by bug 1889093.


Most gradients are rendered via a cached render task and composited with the image shader. We limit the resolution of the cached gradients to 1024 pixels. Most gradients are only smooth transitions so the artifacts aren't very visible. However, when there are hard stops it can cause some very visible pixelation artifacts. Today this should only affect radial and conic gradients.

There's a few bugs on file already for various cases revolving around the same root cause so I'm going to group them under this meta-bug.

Potential solutions:

  • Increase the maximum resolution for cached gradients with hard stops. Not really a fix per se but easy and might be enough.
  • Roll back to having brush shaders for radial and conic gradients in addition to the cached ones, and use them for large gradients with hard stops. That's the most correct route but our code isn't well organized for doing this wihout duplicating a large amount of code. It would be nice to refactor some of this tech debt beforehand if we go this route.
No longer blocks: 1717934
Depends on: 1707624, 1717934
Depends on: 1715370

This also happens with Firefox 90 on Fedora now when using a repeating-linear-gradient() with hard stops as background-image.

Actually, this is also broken:

linear-gradient( -45deg, white 1.2%, white 2%, #51993c 2%, #51993c 3%, white 3%)

So it seems like it affects all hard stops, if the gradient is applied to an element that covers a large area. Pretty severe, if you ask me. Doesn't happen with older Firefox versions.

This is definitely a problem for a pair of linear gradients we're using to visually separate sections of a page header that spans the window width. ```css
linear-gradient(72deg, white 41.7%, rgba(1, 1, 1, 0) 41.7%), linear-gradient(#334466, #001540)

The 1024px limit is definitely not pleasant to see on 4k screens!

Instead of picking an arbitrary(ish) limit for all gradients, could the largest element using that gradient determine the cached size? Maybe treat a too-small cached gradient as a miss and update the cache?

(Meanwhile, I slid the first stop to 41.6% to smooth out the jaggies. Still looks poor compared to Chrome/Edge)

It also looks pretty severe if you create stripes with repeating-linear-gradient which is a not-uncommon usecase:

body {
  background: #fb0;
  background-image: repeating-linear-gradient(-135deg, transparent, transparent 35px, rgba(0,0,0,1) 35px, rgba(0,0,0,1) 70px);
  padding: 0;
  height: 100vh;
}
Depends on: 1809095
Depends on: 1885571
Alias: wr-gradients
Depends on: 1833397
Depends on: 1881665
Depends on: 1869248
Depends on: 1851394
Depends on: 1833123
Summary: [meta] Pixelated gradients → [meta] gradients rendering issues
Depends on: 1860310
Depends on: 1708030
Depends on: 1881921
Depends on: 1767182
Blocks: wr-projects
Depends on: 885021
Summary: [meta] gradients rendering issues → [meta] [project] Fix gradient correctness issues
Depends on: 1787132
Depends on: 1484908
Depends on: 1525705
Depends on: 1680882
Depends on: 1652751
Depends on: 1749560
Depends on: 1769968
Depends on: 1774457
Depends on: 1476800
Depends on: 1797030
Depends on: 1692583
Depends on: 1777592
Depends on: 967074
Depends on: 1846670
Depends on: 1885717
Depends on: 1843689
Depends on: 1791628
Depends on: 1646043
Depends on: 1605425
Depends on: 1889073
Depends on: 1889092
No longer depends on: 1652751
No longer depends on: 1749560
Depends on: 1889093
Depends on: 1889095
No longer depends on: 1717934
No longer depends on: 1881665
No longer depends on: 1869248
No longer depends on: 1791628
No longer depends on: 1809095
No longer depends on: 1777592
No longer depends on: 1774457
No longer depends on: 1715370
No longer depends on: 1708030
No longer depends on: 1707624
No longer depends on: 885021
No longer depends on: 1843689
No longer depends on: 1833123
No longer depends on: 1833397
No longer depends on: 1692583
No longer depends on: 1860310
No longer depends on: 1767182
No longer depends on: 1680882
No longer depends on: 1881921
Rank: 2
Depends on: 1891907
Rank: 2 → 3
Depends on: 1888334
You need to log in before you can comment on or make changes to this bug.