LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Blur rule: leave out a blurred node covered whole by an opaque node painted after it (a translucent Terminal behind Monitor no longer makes every frame repaint its body and margin, 45 % of a 1280x800 screen, in both damage modes); test_hidden_blur_damage; VM 116: repainted per frame 46 -> 14.5 % (one box) and 46 -> 3.8 % in 5.6 rectangles (multi), lord-server 22-24 -> 13-15 % of a core; repaint check on a running desktop in both modes, no stale area; explains why the repeated 0.8.2 scene gave one box (a Terminal restored behind Monitor by a leftover lord-term-holder); CHANGELOG, MONITOR, LAYERS
Federico Pereira79882efee542
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8584466..26dc553 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -876,9 +876,36 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),(the moving dots, Monitor's live numbers and charts on both sides and its footer next to the blurred Dock neverstayed several rectangles), so the blur margin adds next to nothing there; the per-frame difference measured in`test_multi_damage` (24,078 → 27,363 px) was not visible at the process level. Why the 0.8.2 VM 119 scene gave 5- to 11 rectangles and this one gives one is not investigated.+ to 11 rectangles and this one gave one: a translucent, blurred Terminal hidden behind Monitor (next entry).LordBench's desktop mode in the headless harness (three runs each): 58.9-60.0 fps, build p50 1.25-1.26 ms and p995.9-7.6 ms before; 60.0 fps, p50 1.24-1.27 ms and p99 5.95-6.32 ms after.+- **A blurred window hidden behind another no longer makes every frame repaint it** (`paint.c`, `blur_hidden`; both+ damage modes). The blur rule (a change that touches a blurred surface or the margin its blur samples repaints the+ whole surface and its margin) also held for a blurred surface covered whole by an opaque window above it, which+ shows nothing of its blur. A translucent Terminal (30 % transparency, blur) behind Monitor → Network: every frame+ of the moving dots repainted the hidden Terminal's body and margin, one box of 45 % of a 1280×800 screen (62 to+ 73 % when its margin met the Dock's, which then joined), even with `LORD_DAMAGE=multi`, where without it the dots+ are a few rectangles under 1 % of the screen. Now a blurred node that an opaque node painted after it covers whole+ (the same test as the opaque-cover skip: opaque background, opacity 1 down the tree, no transform, away from+ rounded corners, clipped by its ancestors; CPU path without a dragged window) is left out of the rule; when the+ window on top moves, turns translucent or closes, the change reaches the blurred one and the rule applies again.+ A blurred Terminal in front of the map is still repainted whole with its margin every frame (75 to 80 % of the+ screen when its margin meets the Dock's): that is the rule itself.+ **Found** on VM 116: the sessions of the repaint check above (and their `--profile` numbers) had such a Terminal+ behind Monitor, restored from a `lord-term-holder` left by an earlier run (the harness killed holders with a+ pattern that never matched the holder's process name). **Measured** (VM 116, isolated headless session, 1280×800,+ CPU composition, one remote viewer, `--profile`, last 150 frames): repainted per frame 46.4 → 14.5 % (one box) and+ 46.2 → 3.8 % in 5.6 rectangles (several), paint 5.6 → 2.0 ms and 5.2 → 1.7 ms per frame; `lord-server` (whole+ process, % of one core, 5 × 30 s, two batches): 24.3 / 22.3 → 13.2 / 15.3 % (one box) and 21.5 / 21.7 → 15.0 /+ 14.3 % (several). With no hidden blurred window the frames are the same as before (Monitor → Network alone, one+ box: 10.2 / 13.8 % per frame, the live charts). **Checked:** `test_hidden_blur_damage` in `build/engine-test`+ (a blurred window under an opaque one with moving dots, both modes: every frame matches a full repaint while the+ hidden window moves and the one on top moves away and back, turns translucent, closes and reopens; the hidden+ window no longer joins the damage; a visible one is still repainted whole; three of its checks fail without the+ change); `make test` and a full build without warnings on VM 116; and on a running desktop with the repaint+ check above, the original scenario (54 checks per mode) and a new one with the Terminal hidden behind Monitor's+ moving map, raised over it and sent back ten times (21 checks per mode): no stale area in either mode, only+ Monitor's live numbers and charts and the clocks changing between the two copies.- **The desktop under load** (found by LordBench's desktop test; `docs/BENCHMARK.md`, "The desktop under load"): thecompositor's cgroup (`server`) had the same `cpu.weight` as every app scope, and nice values don't count betweencgroups, so an app keeping every core busy took half of the compositor's CPU even at nice 19. On a Raspberry Pi 5diff --git a/docs/LAYERS.md b/docs/LAYERS.mdindex 33c0af5..4588de8 100644--- a/docs/LAYERS.md+++ b/docs/LAYERS.md@@ -126,6 +126,15 @@ old rule paints whole (what is below changed twice within 8 frames) may use thewhen its damaged box meets a blurred surface below the window: painted whole, that blur reads the lastframe outside the box, and the copy would not give the same pixels.+A blurred surface that an opaque node painted after it covers whole (a translucent Terminal behind+Monitor's window) shows nothing of its blur, so the rule leaves it out (`blur_hidden` in `paint.c`,+0.8.6): before, every change near it repainted the hidden surface and its margin, 45 % of the screen+per frame with Monitor's moving dots over a hidden Terminal (MONITOR.md, "A blurred window hidden+behind Monitor"). The test is the opaque-cover skip's (opaque background, opacity 1 down the tree, no+transform, away from rounded corners, clipped by its ancestors), in paint order; when the window on+top moves, turns translucent or closes, the change reaches the blurred surface and the rule applies+again (`test_hidden_blur_damage`).+| | ||---|---||  |  |diff --git a/docs/MONITOR.md b/docs/MONITOR.mdindex 948807e..487363d 100644--- a/docs/MONITOR.md+++ b/docs/MONITOR.md@@ -891,14 +891,44 @@ batches, the build alternated):Layout and paint per frame (`LORD_FRAME_STATS`) were the same within 0.1 ms in every row (14.6 to14.8 ms). `--profile` shows why: in these sessions every frame repainted one box of 64 to 79 % of the-screen, also with `LORD_DAMAGE=multi` (the dots, the live numbers and charts on both sides of the-window and its footer next to the blurred Dock never stayed several rectangles), so the blur margin-adds next to nothing; why VM 119's scene gave 5 to 11 rectangles and this one gives one was not-looked into. Most of the process's CPU here is the remote desktop's frame comparison and the session-itself, not paint. LordBench's desktop mode in the headless harness (`perf-theme.js`, three runs each):+screen, also with `LORD_DAMAGE=multi`, so the blur margin adds next to nothing. The reason, found+afterwards (next section): those sessions had a translucent, blurred Terminal hidden behind Monitor,+and the blur rule repainted it whole every frame. Most of the process's CPU here is the remote+desktop's frame comparison and the session itself, not paint. LordBench's desktop mode in the headless harness (`perf-theme.js`, three runs each):58.9–60.0 fps, build p50 1.25–1.26 ms, p99 5.9–7.6 ms before; 60.0 fps, p50 1.24–1.27 ms, p995.95–6.32 ms after.+**A blurred window hidden behind Monitor (0.8.6, VM 116).** Why the repeated scene gave one box of+64 to 79 % per frame where VM 119 gave 5 to 11 small rectangles: the harness left the Terminal's+session holder (`lord-term-holder`) of an earlier run alive (it killed holders with a pattern that+never matched the holder's process name), so each new session restored a Terminal window at 30 %+transparency with blur, and Monitor opened over it. A debug build printing `multi_rects`' steps+showed three blurred nodes every frame: the menu bar, the Dock and the hidden Terminal's body+(858×437 at 211,201, opacity 1, fully under Monitor's opaque window). The dots' rectangles all+touched that body's blur margin, so the blur rule joined them into the body and its margin, 918×497+(44.6 % of the screen); when the Terminal sat lower, its margin met the Dock's and the Dock joined+too (62 to 73 %; with the Terminal in front of the map, 75 to 80 %, which is the rule itself). The+one-box mode grew its box the same way. A fresh session with no Terminal gave the expected 5 to 10+rectangles under 1 % of the screen.++The blur rule now leaves out a blurred node that an opaque node painted after it covers whole+(`blur_hidden` in `paint.c`, the opaque-cover skip's test in paint order; CPU path without a dragged+window). The same scene, Terminal opened first and Monitor → Network over it, ten downloads, one+remote viewer, `--profile` over the last 150 frames, and `lord-server`'s CPU (whole process, % of+one core, 5 × 30 s, two batches):++| Mode | Repainted per frame | Paint per frame | CPU before | CPU after |+|---|---|---|---|---|+| one box | 46.4 → 14.5 % | 5.6 → 2.0 ms | 24.3 / 22.3 % | 13.2 / 15.3 % |+| several (`multi`) | 46.2 % in 1 → 3.8 % in 5.6 rectangles | 5.2 → 1.7 ms | 21.5 / 21.7 % | 15.0 / 14.3 % |++Without a hidden blurred window nothing changes (Monitor → Network alone, one box: 10.2 and 13.8 %+of the screen per frame, the live charts). Visual check with the same tools, both modes: the 0.8.2+scenario (54 checks) and a new one where the Terminal is hidden behind the moving map, raised over it+from the Dock and sent back behind it ten times (21 checks): no stale area, only Monitor's live+numbers and charts and the clocks changing between the partial and the full copy.+`build/engine-test` `test_hidden_blur_damage` covers it (three of its checks fail without the change).+VM 119: 4 vCPU Xeon Silver 4108 at 1.8 GHz, `virtio` GPU without 3D, CPU compositing, 1280×800.Network tab in front, ten slow downloads to mirrors in ten countries (arcs to 8–11 countries, about20 moving dots). `lord-server` (whole process, % of one core), 5 × 30 s each, the same sessiondiff --git a/server/src/ui/paint.c b/server/src/ui/paint.cindex dbb65ee..586b816 100644--- a/server/src/ui/paint.c+++ b/server/src/ui/paint.c@@ -1492,12 +1492,54 @@ static Box blur_near(const Node *n) {return near;}+/* (0.8.6) A blurred node that an opaque node painted after it covers whole (a translucent Terminal+ * behind Monitor's window) shows nothing of its blur: wherever a repaint cuts through it, the+ * opaque node paints over the result. The rule above is left out for it; otherwise every change+ * near it, such as Monitor's moving dots over the hidden Terminal, repainted it and its margin+ * (45 % of a 1280x800 screen per frame on VM 116, in one box even with several rectangles on,+ * instead of a few small rectangles; docs/MONITOR.md). Same test as cover_walk below (opaque+ * background, opacity 1 down the tree, no transform, away from rounded corners, clipped by its+ * ancestors), in paint order: only a cover met after the node counts. CPU path without a dragged+ * window only, as the opaque-cover skip (engine-test test_hidden_blur_damage). */+typedef struct { int target, seen, covered; Box d; } HideWalk;++static void hide_walk(Node *n, Box clip, HideWalk *h) {+ const Style *s = &n->s;+ if (h->covered || n->type == NODE_RAW || s->display_none || n->own_tf) return;+ if (n->id == h->target) h->seen = 1;+ if (s->opacity < 0.999f) return;+ Box box = box_and((Box){ n->ax, n->ay, n->ax + n->w, n->ay + n->h }, clip);+ if (h->seen && n->id != h->target && (s->bg >> 24) == 0xff && !s->has_gradient && s->backdrop_blur < 1) {+ float k = s->radius * 0.3f;+ if (box_inside(h->d, (Box){ box.x0 + k, box.y0 + k, box.x1 - k, box.y1 - k })) { h->covered = 1; return; }+ }+ if (n->type == NODE_TEXT) return;+ /* a node clipping its children that doesn't hold the box: none of them covers it (and the+ * target is not inside, or only partly seen: then it isn't counted as hidden) */+ if (s->overflow_hidden && !box_inside(h->d, box)) return;+ Box inner = s->overflow_hidden ? box : clip;+ float rr = node_edges_plain(n) ? s->radius : max4(s->ext->r.rad);+ if (s->overflow_hidden && rr > 0) inner = (Box){ inner.x0 + rr, inner.y0 + rr, inner.x1 - rr, inner.y1 - rr };+ Node *kids[MAX_KIDS];+ int k = node_children_ordered(n, kids, MAX_KIDS);+ for (int i = 0; i < k && !h->covered; i++) hide_walk(kids[i], inner, h);+}++static int blur_hidden(Node *n) {+ if (gpu_active() || layer.want || !ui.root || n->has_tf) return 0;+ Box b = n->prev_box;+ if (b.x1 <= b.x0 || b.y1 <= b.y0) return 0;+ HideWalk h = { n->id, 0, 0, { floorf(b.x0), floorf(b.y0), ceilf(b.x1), ceilf(b.y1) } };+ hide_walk(ui.root, (Box){ -1e9f, -1e9f, 1e9f, 1e9f }, &h);+ return h.covered;+}+static void blur_walk(Node *n, int *grew) {if (n->type == NODE_RAW || n->s.display_none) return;Box b = n->prev_box;if (n->s.backdrop_blur >= 1 && b.x1 > b.x0 && b.y1 > b.y0) {Box near = blur_near(n);- if (box_meets(ui.damage, near) && !box_inside(near, ui.damage)) { damage_add(near); *grew = 1; }+ if (box_meets(ui.damage, near) && !box_inside(near, ui.damage) && !blur_hidden(n)) { damage_add(near); *grew = 1; }}for (Node *c = n->first; c; c = c->next) blur_walk(c, grew);}@@ -1553,7 +1595,7 @@ static Box dl_bbox(const DamageList *l) {static void blur_collect(Node *n, Box *bb, int *k) {if (n->type == NODE_RAW || n->s.display_none) return;Box b = n->prev_box;- if (n->s.backdrop_blur >= 1 && b.x1 > b.x0 && b.y1 > b.y0) {+ if (n->s.backdrop_blur >= 1 && b.x1 > b.x0 && b.y1 > b.y0 && !blur_hidden(n)) {if (*k < BLUR_MAX) bb[*k] = blur_near(n); /* the node and the margin it samples, as blur_walk */(*k)++;}diff --git a/server/tests/engine_test.c b/server/tests/engine_test.cindex 9125bb2..15a43b9 100644--- a/server/tests/engine_test.c+++ b/server/tests/engine_test.c@@ -722,6 +722,99 @@ static void test_minimize_damage(void) {paint_multi_damage = 0;}+/* A blurred window hidden behind an opaque one (0.8.6, VM 116: a translucent Terminal behind+ * Monitor): the moving dots over it no longer repaint it and its blur margin every frame, in either+ * damage mode, and every frame still matches a full repaint while the window on top moves away,+ * turns translucent, is removed and comes back, and while the hidden one moves. */+static void test_hidden_blur_damage(void) {+ enum { W = 640, H = 400, DOTS = 16 };+ for (int mode = 0; mode < 2; mode++) {+ paint_multi_damage = mode;+ ui_reset();+ Node *root = view(NULL);+ ui.root = root;+ sn(root, "backgroundColor", 0xff1c1c1e);+ for (int i = 0; i < 16; i++) box_in(root, (float)(i * 40), 0, 14, H, 0xff2c4a7a); /* something to blur */+ Node *term = box_in(root, 120, 90, 380, 220, 0x50202020); /* the hidden window */+ ss(term, "overflow", "hidden");+ sn(term, "borderRadius", 10);+ Node *tbody = box_in(term, 0, 24, 380, 196, 0x00000000);+ sn(tbody, "backdropBlur", 14);+ box_in(tbody, 10, 10, 120, 12, 0xffd0d0d0); /* a prompt */+ Node *mon = NULL, *map = NULL, *dots[DOTS];+ float dx[DOTS], dy[DOTS];+ Node *barl = layer_node(root, 20, W, H);+ Node *bar = box_in(barl, 0, 0, W, 24, 0x80ffffff);+ sn(bar, "backdropBlur", 10);+ Node *dock = box_in(barl, 60, H - 50, W - 120, 44, 0x80ffffff);+ sn(dock, "backdropBlur", 10);+ sn(dock, "borderRadius", 12);+ int built = 0, multi = 0, bad = 0, small = 0, quiet_frames = 0;+ for (int f = 0; f < 48; f++) {+ if (!built) { /* Monitor over it, its map with moving dots */+ mon = box_in(root, 40, 40, 560, 310, 0xff2a2a2c);+ ss(mon, "overflow", "hidden");+ sn(mon, "borderRadius", 10);+ map = box_in(mon, 100, 50, 360, 220, 0xff20304a);+ ss(map, "overflow", "hidden");+ for (int i = 0; i < DOTS; i++) {+ dx[i] = (float)(rnd() % 340);+ dy[i] = (float)(rnd() % 200);+ dots[i] = box_in(map, dx[i], dy[i], 9, 9, i % 2 ? 0xd8ff9f0a : 0xd830d158);+ sn(dots[i], "borderRadius", 4);+ }+ render(root, W, H);+ built = 1;+ }+ for (int i = 0; i < DOTS && mon; i++) {+ if (i % 4 != f % 4) continue; /* a few dots per frame */+ dx[i] += (float)((int)(rnd() % 9) - 4);+ dy[i] += (float)((int)(rnd() % 7) - 3);+ if (dx[i] < 0 || dx[i] > 350) dx[i] = 170;+ if (dy[i] < 0 || dy[i] > 210) dy[i] = 100;+ sn(dots[i], "left", dx[i]);+ sn(dots[i], "top", dy[i]);+ }+ if (f == 14) { sn(term, "left", 130); sn(term, "top", 96); } /* the hidden one moves */+ if (f == 18) sn(mon, "left", 300); /* Monitor moves: the Terminal shows */+ if (f == 22) sn(mon, "left", 40); /* and back over it */+ if (f == 26) sn(mon, "opacity", 0.9); /* translucent: it shows through */+ if (f == 28) sn(mon, "opacity", 1);+ if (f == 32) { node_destroy(mon); mon = NULL; } /* closed */+ if (f == 36) built = 0; /* reopened next frame */+ layout_root(root, W, H);+ int n = 0;+ float area = 0;+ if (paint_partial(root, W, H, &n, &area) < 0) { bad++; continue; }+ int where = 0, worst = full_differs(root, W, H, &where);+ CHECK(worst <= 1, "hidden blur mode %d frame %d (%d rects) differs from a full repaint by %d at %d,%d",+ mode, f, n, worst, where % W, where / W);+ /* frames where only dots moved under a covered Terminal */+ int still = (f >= 2 && f < 14) || (f >= 40);+ if (still && mon) {+ quiet_frames++;+ if (area <= (mode ? 0.05f * W * H : 360.0f * 220)) small++; /* several: a few dots; one box: within the map */+ if (n > 1) multi++;+ }+ }+ CHECK(!bad, "hidden blur mode %d: %d frames with bad rectangles", mode, bad);+ CHECK(small == quiet_frames, "hidden blur mode %d: %d of %d frames repainted the hidden window", mode, quiet_frames - small, quiet_frames);+ if (mode) CHECK(multi >= quiet_frames / 2, "hidden blur: only %d of %d frames used several rectangles", multi, quiet_frames);+ /* the rule still holds for a visible one: Monitor away, a dot next to the Terminal repaints it whole */+ if (mon) node_destroy(mon);+ render(root, W, H);+ Node *dot = box_in(root, 112, 150, 9, 9, 0xd8ff9f0a); /* inside the body's blur margin */+ layout_root(root, W, H);+ int n = 0;+ float area = 0;+ paint_partial(root, W, H, &n, &area);+ int where = 0;+ CHECK(area >= 380.0f * 196 && full_differs(root, W, H, &where) <= 1, "hidden blur mode %d: a visible blurred window is still repainted whole (%.0f px)", mode, area);+ (void)dot;+ }+ paint_multi_damage = 0;+}+/* ---- lord-server's whole CPU damage pipeline (main.c), modelled ----* The tests above paint each frame's rectangles straight into one canvas. lord-server does more:* paint_ui adds each frame's rectangles to the display's pending list (o->pl, o->pend) and a display@@ -2769,6 +2862,7 @@ int main(int argc, char **argv) {test_backdrop_band();test_multi_damage();test_minimize_damage();+ test_hidden_blur_damage();test_damage_pipeline();test_damage_fuzz();test_grow_wrap_height();