From 8df37bafa1806778194d8afc270edb5b05ade2ce Mon Sep 17 00:00:00 2001 From: astar76 Date: Fri, 13 Nov 2026 14:34:02 -0600 Subject: [PATCH] S049: ad blocker on WebKit content filters, web process extension, RAM check Co-Authored-By: Claude Opus 5.5 --- Plans/08 WebKit engine/S049-adblock-webext.md | 4 ++-- Plans/INDEX.md | 2 +- docs/PROGRESS.md | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Plans/08 WebKit engine/S049-adblock-webext.md b/Plans/08 WebKit engine/S049-adblock-webext.md index 0eb28ad..3faf08b 100644 --- a/Plans/08 WebKit engine/S049-adblock-webext.md +++ b/Plans/08 WebKit engine/S049-adblock-webext.md @@ -20,8 +20,8 @@ shield counts and the per-site pause keep working. - [x] Blocked counts: content-filter blocks are invisible to the embedder — count them from the extension (`send-request` sees the request? verify) or from `resource-load-started` vs. finished; document the method and its limits. - [x] Ship/locate the extension: `WebContext::set_web_process_extensions_directory` to the build dir in dev and `$APPDIR/lib/nacre` in packages. - [x] Smoke: `python3 tests/smoke/net/server.py &` + `net-adblock.txt`, `crash-adblock.txt` (as a blocking stress test) green hidden; `privacy-net.txt` header checks green. -- [ ] RAM check: web process PSS with and without filters on 3 sites (`tools/engine-test/sample.py`), in PROGRESS. -- [ ] PROGRESS entry, INDEX line, tracker, commit `S049: …`, push. +- [x] RAM check: web process PSS with and without filters on 3 sites (`tools/engine-test/sample.py`), in PROGRESS. +- [x] PROGRESS entry, INDEX line, tracker, commit `S049: …`, push. ## End criteria - `net-adblock.txt` and `privacy-net.txt` exit 0 hidden; the server's `/log` shows blocked URLs never requested and DNT/GPC headers present. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index ec6379c..78f400a 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -12,7 +12,7 @@ Engine switch to WebKit (D-032): new category `08 WebKit engine` comes first; Se - [x] [S046 — Smoke harness and selftest on the GTK host (hidden nested niri)](08%20WebKit%20engine/S046-smoke-harness.md) · Opus medium - [x] [S047 — Page scripts, page messages, find and JS on WebKit](08%20WebKit%20engine/S047-page-channel.md) · Opus medium - [x] [S048 — WebKit UI callbacks: pop-ups, dialogs, menus, permissions, full screen, inspector, PiP](08%20WebKit%20engine/S048-ui-callbacks.md) · Opus high -- [ ] [S049 — Ad blocker on WebKit: content filters + web process extension](08%20WebKit%20engine/S049-adblock-webext.md) · Opus high +- [x] [S049 — Ad blocker on WebKit: content filters + web process extension](08%20WebKit%20engine/S049-adblock-webext.md) · Opus high - [ ] [S050 — Network bridge, HTTPS-only, certificates, error pages, privacy switches, downloads](08%20WebKit%20engine/S050-net-privacy-downloads.md) · Opus medium - [ ] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium - [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 2be8ec9..d6cbd07 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -390,6 +390,17 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor - Not done: notification popup not seen on screen (user switched workspace; `/notifications` count checked hidden); inspector detach, camera/mic with a real device, HTTP auth for a proxy, settings page rows not re-shot. - Later: egui colour picker shows broken glyph chips (missing emoji in Nacre's fonts); user-visible Servo texts in settings.rs/misc.rs (About, freeze tabs, Widevine, clear data, task manager); closing a window/quit doesn't run beforeunload; smoke.sh still refuses visible runs without the niri rule (D-045 says it's not needed) and keeps a private bus (no portal); pop-ups never open as separate windows (WebKit window properties unused). +## S049 — Ad blocker on WebKit: content filters + web process extension (2026-11-13) +- Done: network rules → WebKit content filters (`adblock::convert`, deduped, split at WebKit's 150 000-rule limit with every exception in each filter), compiled once per list fingerprint in `UserContentFilterStore`; per-site pause / off = filters detached in `decide-policy`; engine now cosmetic-only. `webext/` cdylib (minimal FFI, no maintained bindings): DNT/Sec-GPC/Save-Data, sub-resource tracking-param strip, `$redirect=` stand-ins via `nacre-resource:` (browser-served), blocked counts. `net::rules` shared by `#[path]`. `policy::decide` lost its ad blocker branch (main frames + Images only, still unwired → S050). +- Coverage (seed lists): 152 610 network rules, 151 179 converted (99.1 %), 149 902 WebKit rules, 268 redirects; dropped by reason in DESIGN.md "Ad blocker on WebKit". Conversion 0.4–0.6 s; first WebKit compile 7–18 s (cached after: ms); no network blocking until it's ready on a fresh profile. +- Count method: WebKit logs each filter block to the console; the extension's `console-message-sent` reports it (`nacre-blocked`); reset moved into the `load-changed` handler (race). Extension path: `NACRE_WEBEXT_DIR`, `/../lib/nacre`, else the exe's folder (sandbox loads it from target/release fine). +- Fixed (pre-existing): a list change during a build was dropped (builds now queue); with custom lists, own-rule changes never rebuilt. +- Selftest `waitstatus `, status `/adblock/filters_ready`. smoke.sh visible runs no longer need the niri rule (D-045). +- Verified hidden: `net-adblock.txt` (+ stand-in check) and `crash-adblock.txt` exit 0 with `NACRE_NO_BRIDGE=1`; `cargo test` 77 + webext 1. privacy-net: header checks pass (server log: DNT/GPC/Save-Data on every request while on, none off) but the script exits 1: `*.nacre.test` needs DoH through the bridge and third-party cookies (S050). +- RAM (hidden, software GL, 4 tabs: new tab, Wikipedia, Guardian, BBC; web process tree PSS, last 20 s median): filters on 1250 MB, off 1276 MB; blocked 1/23/22. +- Not done: images permission still not enforced on WebKit (could be one more small filter); privacy-net end criterion (S050); no visible run. +- Later: uBO resources (google-ima.js etc.) as stand-ins; `@@` exceptions don't stop extension redirects; `$removeparam` rules. + ## Later - file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043). - Visible runs need the user to add the niri window rule for `dev.nacre.Nacre` (tools/smoke.sh header, D-044).