Skip to content

[GTK][WPE] Fix the source area of filters and backdrop filters - #75441

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
nikolaszimmermann:eng/filter-source-outside-viewport
Oct 1, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
nikolaszimmermann:eng/filter-source-outside-viewport

Conversation

@nikolaszimmermann

@nikolaszimmermann nikolaszimmermann commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

0245999

[GTK][WPE] Fix the source area of filters and backdrop filters
https://bugs.webkit.org/show_bug.cgi?id=325847

Reviewed by Carlos Garcia Campos.

Filters are applied in an offscreen surface that only covered the visible part
of the layer. Content outside of it was never painted into the surface, so it
did not contribute to the filter result. For example, if a layer with a drop
shadow is partly scrolled out of the viewport, the shadow of the scrolled out
part was missing, even when the shadow resides inside the viewport. Like
Chromium, extend the surface by the area the filter reads from outside the
visible part - clamped to the maximum surface size. Also add the area the
filter has to cover into the damage region.

The surface of a backdrop filter instead covered its whole border box, and lost
the visible part, if that did not fit. Limit it the same way, to what the filter
reads for the visible part of the border box, _within_ the border box. As the
surface can now end before the border box, mirror a backdrop blur at the border
box, as the spec requires, instead of clamping it at the edges of the surface.
Also apply the filter of the layer to its backdrop, which was painted outside of
it before, which was wrong.

Stop painting a backdrop in recursivePaint() when reaching the layer it belongs
to, before any of the effects of that layer. The filter path could return before
it reached paintSelfAndChildren(), and the layers after it were then painted
into the backdrop.

This fixes several backdrop-filter WPT tests, and drop-shadow-with-3d-transform.html.
Add a new specific test covering the "filter outside viewport" scenario,
which triggered the investigation into this topic. Raise the fuzzy pixel budget of
filter-unbounded-child-in-layer-plane.html, as the larger surface changes the
rounding of a few pixels by one.

Test: compositing/filters/filter-source-outside-viewport.html

* LayoutTests/compositing/filters/filter-source-outside-viewport-expected.html: Added.
* LayoutTests/compositing/filters/filter-source-outside-viewport.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/filter-unbounded-child-in-layer-plane.html:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/gtk/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp:
(WebCore::SkiaCompositingLayer::setBackdropFilters):
(WebCore::SkiaCompositingLayer::hasFilter const):
(WebCore::filterSourceBounds):
(WebCore::SkiaCompositingLayer::paintBackdrop):
(WebCore::SkiaCompositingLayer::paintWithMaskAndBackdrop):
(WebCore::SkiaCompositingLayer::paintWithFilterAndMask):
(WebCore::SkiaCompositingLayer::recursivePaint):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h:
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayerFilters.cpp:
(WebCore::SkiaCompositingLayerFilters::create):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayerFilters.h:

Canonical link: https://commits.webkit.org/322384@main

502107e

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2   🧪 win-tests
✅ 🧪 webkitperl   🧪 ios-wk2   🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt   🧪 api-mac-debug
  🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
  🛠 ios-safer-cpp   🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-wk2-stress ✅ 🧪 gtk-wk2
  🛠 🧪 merge ✅ 🛠 vision-sim   🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2   🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@nikolaszimmermann nikolaszimmermann added the WPE WebKit WebKit WPE component label Sep 30, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 1, 2026
@nikolaszimmermann nikolaszimmermann removed the merging-blocked Applied to prevent a change from being merged label Oct 1, 2026
@nikolaszimmermann
nikolaszimmermann force-pushed the eng/filter-source-outside-viewport branch from b3cf5be to 502107e Compare October 1, 2026 10:34
@nikolaszimmermann nikolaszimmermann added the merge-queue Applied to send a pull request to merge-queue label Oct 1, 2026
https://bugs.webkit.org/show_bug.cgi?id=325847

Reviewed by Carlos Garcia Campos.

Filters are applied in an offscreen surface that only covered the visible part
of the layer. Content outside of it was never painted into the surface, so it
did not contribute to the filter result. For example, if a layer with a drop
shadow is partly scrolled out of the viewport, the shadow of the scrolled out
part was missing, even when the shadow resides inside the viewport. Like
Chromium, extend the surface by the area the filter reads from outside the
visible part - clamped to the maximum surface size. Also add the area the
filter has to cover into the damage region.

The surface of a backdrop filter instead covered its whole border box, and lost
the visible part, if that did not fit. Limit it the same way, to what the filter
reads for the visible part of the border box, _within_ the border box. As the
surface can now end before the border box, mirror a backdrop blur at the border
box, as the spec requires, instead of clamping it at the edges of the surface.
Also apply the filter of the layer to its backdrop, which was painted outside of
it before, which was wrong.

Stop painting a backdrop in recursivePaint() when reaching the layer it belongs
to, before any of the effects of that layer. The filter path could return before
it reached paintSelfAndChildren(), and the layers after it were then painted
into the backdrop.

This fixes several backdrop-filter WPT tests, and drop-shadow-with-3d-transform.html.
Add a new specific test covering the "filter outside viewport" scenario,
which triggered the investigation into this topic. Raise the fuzzy pixel budget of
filter-unbounded-child-in-layer-plane.html, as the larger surface changes the
rounding of a few pixels by one.

Test: compositing/filters/filter-source-outside-viewport.html

* LayoutTests/compositing/filters/filter-source-outside-viewport-expected.html: Added.
* LayoutTests/compositing/filters/filter-source-outside-viewport.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/filter-unbounded-child-in-layer-plane.html:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/gtk/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp:
(WebCore::SkiaCompositingLayer::setBackdropFilters):
(WebCore::SkiaCompositingLayer::hasFilter const):
(WebCore::filterSourceBounds):
(WebCore::SkiaCompositingLayer::paintBackdrop):
(WebCore::SkiaCompositingLayer::paintWithMaskAndBackdrop):
(WebCore::SkiaCompositingLayer::paintWithFilterAndMask):
(WebCore::SkiaCompositingLayer::recursivePaint):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h:
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayerFilters.cpp:
(WebCore::SkiaCompositingLayerFilters::create):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayerFilters.h:

Canonical link: https://commits.webkit.org/322384@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/filter-source-outside-viewport branch from 502107e to 0245999 Compare October 1, 2026 13:56
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 322384@main (0245999): https://commits.webkit.org/322384@main

Reviewed commits have been landed. Closing PR #75441 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 0245999 into WebKit:main Oct 1, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 1, 2026
@nikolaszimmermann
nikolaszimmermann deleted the eng/filter-source-outside-viewport branch October 1, 2026 14:02
danielhanchen added a commit to unslothai/unsloth that referenced this pull request Nov 20, 2026
…GTK before 2.54 (TextureMapper backdrop includes later layers) (#18600)

## What it fixes

On Linux with WebKitGTK older than 2.54 (Mint 22.1 ships 2.52.6), with
Glass on and the sidebar pinned, the unsloth logo at the top of the
sidebar sits in a soft halo tinted by the logo. Tester's 2.54.2 doesn't
show it.

## Why it happens

The pinned strip's glass is a `backdrop-filter` on
`[data-windows-glass-frame]::before`, with the sidebar's content painted
over it. Before 2.54, WebKitGTK composites with TextureMapper, and
TextureMapper's backdrop includes layers painted *after* the filtered
one. So the strip blurs the logo that sits on top of it, and the blurred
copy shows around the logo. 2.54 replaced TextureMapper with a Skia
compositor ([2.54
highlights](https://webkitgtk.org/2026/09/16/webkitgtk-2.54-highlights.html)).
The closest WebKit change I found is
[WebKit/WebKit#75441](WebKit/WebKit#75441) (bug
325847, 322384@main, Oct 1 2026), which stops a backdrop paint from
including layers that come after the owning layer. I haven't confirmed
which 2.54.x first carries it, and 2.54.0 / 2.54.1 were not run.

A surface's own `backdrop-filter` leaves its children out. So on the old
compositor, `sidebar-inner` blurs for itself over the strip and carries
the strip's fill, and the logo no longer feeds the blur under it.

## What decides when the rule applies

The first commit (ce8a9af) keyed the rule on `webkit-cpu-paint`. That
class comes from `paints_on_cpu` in `src-tauri/src/linux_webkit.rs`.
It's true when the GPU setting is Off or the unsafe flag is set, when
WebKitGTK is older than 2.54 (`(major, minor) < (2, 54)`, because before
2.54 it paints on the CPU on every path), or, from 2.54 on, when
`WEBKIT_DISABLE_DMABUF_RENDERER`, `WEBKIT_SKIA_ENABLE_CPU_RENDERING` or
`WEBKIT_DISABLE_COMPOSITING_MODE` is set.

Tester (2.54.2) with `WEBKIT_SKIA_ENABLE_CPU_RENDERING=1` paints on the
CPU (`cpu_painting=true` in the log) and shows **no** halo on main. So
the bug follows the compositor, not CPU painting, and the CPU gate would
have changed the look on 2.54 CPU paths for nothing. 112a048 moves
the gate to a new `legacy_compositor(webkit_version)` (`< 2.54.0`). It
goes out on the GPU rendering status as `legacyCompositor`, `main.tsx`
adds `webkit-legacy-compositor`, and the CSS rule keys on that class. On
2.52 and older both classes are set, so Mint behaves exactly as with the
first commit.

Tradeoff: on WebKitGTK < 2.54 only, the sidebar's own blur and the
strip's blur meet inside the 34px titlebar band, so a faint seam can
show there.

## On screen

![Halo before and after: Mint real app, #18530 stacked, and the same
page on WebKitGTK vs
macOS](<https://raw.githubusercontent.com/LeoBorcherding/unsloth/pr-media-18030-18032/glass-webkitgtk-cpu-halo/halo-figure.png>)

- **A** is what this PR fixes: on Mint the logo sits in a teal glow on
main and is clean at 112a048.
- **B** is with #18530 stacked (glass-latest
5677d08): its strip glass runs down the docked Run settings, so the
slider thumbs glow too. 4e02fc8 is the panel rule #18530 will need on
top of this one. Main's own Run settings already blurs for itself, so
its thumbs don't glow (row A's build, thumb rings -0.3 / -0.8).
- **C** loads one fixture page with the built CSS of each commit in both
engines. WebKitGTK 2.52.6 haloes with main's CSS; macOS WKWebView
doesn't, and its two commits are pixel-identical. So the halo comes from
the engine, and on macOS this PR changes nothing.

<details><summary>Earlier 4x crops (ce8a9af) and tester
2.54.2</summary>

![Mint logo and thumbs
4x](<https://raw.githubusercontent.com/LeoBorcherding/unsloth/pr-media-18030-18032/glass-webkitgtk-cpu-halo/mint-halo-zoom-4x.png>)

![tester 2.54.2 logo 4x, GPU and forced
CPU](<https://raw.githubusercontent.com/LeoBorcherding/unsloth/pr-media-18030-18032/glass-webkitgtk-cpu-halo/tester-254-logo-4x.png>)

</details>

## Coverage

Ring = mean brightness 17 to 20 px from the logo centre minus 26 to 30
px (+ means a halo). On the hidden display (light mode) the halo's teal
tint is the better signal: mean `G - (R+B)/2` over the same rings.

| machine | what ran | main 2818609 | this branch |
|---|---|---|---|
| Mint 22.1, WebKitGTK 2.52.6, RX 9060 XT, X11, real screen | live app
at ce8a9af, Glass on, sidebar pinned, dark | logo ring +5.5, visible
halo | -2.2, gone |
| Mint 22.1, same box, hidden 1440x900 Xvfb, own D-Bus | built app at
112a048, light | teal ring +5.9, visible halo | 0.0, gone; `<html>`
has `webkit-legacy-compositor`, `sidebar-inner` `backdrop-filter:
blur(8.4px) saturate(1.9)` |
| tester, Arch, WebKitGTK 2.54.2, KDE Wayland (native, no
`GDK_BACKEND`), GPU path | built app at ce8a9af, `cpu_painting=false`
| ring -13.3, no halo | -13.3; frames differ only in the greeting text
box |
| tester, same, forced CPU (`WEBKIT_SKIA_ENABLE_CPU_RENDERING=1`) |
built app at ce8a9af, `cpu_painting=true` | -13.2, no halo | -10.6
(the old CPU gate applied for nothing, which is what 112a048 removes)
|
| tester at 112a048 | not run, tester offline | | |
| Mint, same box, hidden 1440x900 Xvfb, own D-Bus, dark, Fuji wallpaper
| built apps at 2818609 and 112a048, Run settings open | logo teal
ring +14.7; thumbs -0.3 / -0.8 (no glow on main) | logo -1.5; thumbs
unchanged |
| Mint, same setup, with #18530 stacked | glass-latest
5677d08 vs + 4e02fc8 (panel rule) | thumbs +13.7 / +16.0, logo +5.1
| thumbs -1.0 / -1.5, logo -0.2 |
| Mint, WebKitGTK 2.52.6 (PyGObject view, hidden display) | fixture page
with the built CSS of 2818609 and 112a048 | logo teal ring +19.0 |
-0.6 |
| macOS 26, WKWebView, M5 (window capture) | same fixture page and CSS,
native classes (`tauri`, no `render-linux`) | -0.7, no halo | -0.7,
pixel-identical to main |
| Windows, WebView2 (GR33N) | pending, relay request sent | | |

Tests: new `tests/glass-frame-legacy-compositor.test.ts` is red without
the change and green with it. Full frontend suite at 112a048: 16815
tests, 16814 pass, 0 fail; typecheck clean. Rust: `legacy_compositor` is
a plain version compare; the release builds on Mint compile at
112a048.

## Not covered

- WebKitGTK 2.54.0 and 2.54.1, where #75441 may not have landed yet. If
they still halo, the gate needs to read `< (2, 54, 2)`.
- `chat-settings-panel:has(.sticky, [data-glass-float])::before` on main
can leak the same way on the old compositor, but nothing on screen here
hits it.
- #18530 runs the strip's glass down the docked Run
settings panel. It will need the same rule for that panel, keyed on
`webkit-legacy-compositor`.





## Sidebar column tone on the legacy compositor (e240589)

As submitted, the sidebar blurred and filled itself on top of the
strip's glass, which still covered the sidebar column, so on every
WebKitGTK before 2.54 the pinned sidebar got two layers of fill and
turned visibly darker (dark mode, mean sidebar RGB: liquid 118/137/38 on
main vs 87/98/38, frosted 91/104/37 vs 59/64/38). e240589 masks the
sidebar column out of the strip under `webkit-legacy-compositor`,
keeping only the caption band and the inner corner, so the column is one
layer of glass again: liquid, liquid-3d, blurred and frosted all match
main exactly. The new test checks the legacy strip mask leaves the
column out.

Rendered with WebKitGTK 2.50.4 on a fixture page with the built CSS
(`data-glass="frosted"`, dark, pinned strip):

![Sidebar tone: main, PR as submitted, PR with
e240589](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/18600/tone_composite-0b7d5658e968.png)

---------

Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WPE WebKit WebKit WPE component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants