perf(backdrop): bake the cloud blur; deletes no longer cost a 50 ms frame (#984) #987

Closed
kayg wants to merge 0 commits from perf/delete-long-frame into dev
Owner

Fixes #984.

Root cause. The drifting cloud canvases in the backdrop carry a live CSS filter: blur(6px) (.track canvas). Any bottom-bar change (text bar to idle bar, which every selection collapse or deletion causes) made WebKit redo that filter on the 1440-wide moving layers: one 46-90 ms frame about 70-85 ms after the key. It is not the editor, undo, save or decorations (a bare contenteditable, and typing, show none).

Elimination on the Mac VM (plain Backspace on a selected word, 14 runs each, frames >= 50 ms): dev 6-15; backdrop-filter:none 13; no masks 9; no halo 12; no transitions on bar/pills/editor 11-17; no animations 0; filter:none 0; .track canvas{filter:none} 0; no backdrop 0; .track{animation:none} 14.

Fix. The soft edge is baked into the cloud pixels once (packages/ui/src/lib/sky-blur.ts, premultiplied gaussian, wraps left-right like the tile), and the CSS blur is gone. The cloud painter moves to its own lazy chunk sky-clouds (sky-clouds.ts), loaded where clouds are already painted when idle, so first paint gets smaller. The mockup imports paintClouds from the new file; it still has its own CSS.

Gates

Mac VM, WebKit 1440, interleaved ABAB, 15 runs per cell dev db15794ac: frames >= 50 ms fix 43e424216: frames >= 50 ms
Backspace on selected word (round 1 / 2) 15 / 13 2 / 0 (the 2: at t=1.3 s, not after the key)
Backspace at a caret (round 1 / 2) 12 / 5 0 / 1 (at t=1.5 s, noise)
typing 0 / 0 0 / 0
idle (45 windows) 0 / 0 0 / 2 (VM noise; one earlier B run had 6 idle too)

(Counts are raw rAF deltas; the harness leaves old rAF loops running so many hitches count twice, in both arms.) In the earlier f1 run (SHA 164eafb56, same code path): dev 23+17 / 15+2, fix 0 / 0 over 30 deletes x2.

  • First paint (bundle-size.mjs, brotli): JS 230531 B vs dev 230817 B (-286 B); CSS 18379 vs 18383 B. New lazy chunk sky-clouds 1076 B, budget line added.
  • Unit: web vitest 109 passed, ui primitives 61 passed (2 new for the blur); svelte-check 0 errors.
  • Playwright editor.spec + backdrops.spec: chromium-1440 23/23, chromium-390 22 passed (dev-01); webkit-1440 20 passed, webkit-390 19 passed (dev-02).
  • Look: night-sky screenshots of dev and fix in Safari (Mac VM) look the same (clouds are faint at night).
  • Not met cleanly: typing latency on dev-01 (keystroke to paint @perf, ABAB x3): dev-01 was busy with other jobs, p50 86-870 ms in both arms, so the numbers carry no signal. Typing on the Mac shows 0 hitches and p95 25 vs 25 ms in both arms. The change touches no typing path; I'd re-run on a quiet dev-01 or perf VM if you want that number.

Open risk: daytime clouds are brighter, so I only compared a night frame; the blur sigma (1.5 / 2 texels) was chosen to match 6 CSS px, please look at a day sky.

🤖 Generated with Claude Code

Fixes #984. **Root cause.** The drifting cloud canvases in the backdrop carry a live CSS `filter: blur(6px)` (`.track canvas`). Any bottom-bar change (text bar to idle bar, which every selection collapse or deletion causes) made WebKit redo that filter on the 1440-wide moving layers: one 46-90 ms frame about 70-85 ms after the key. It is not the editor, undo, save or decorations (a bare contenteditable, and typing, show none). Elimination on the Mac VM (plain Backspace on a selected word, 14 runs each, frames >= 50 ms): dev 6-15; `backdrop-filter:none` 13; no masks 9; no halo 12; no transitions on bar/pills/editor 11-17; no animations **0**; `filter:none` **0**; `.track canvas{filter:none}` **0**; no backdrop **0**; `.track{animation:none}` 14. **Fix.** The soft edge is baked into the cloud pixels once (`packages/ui/src/lib/sky-blur.ts`, premultiplied gaussian, wraps left-right like the tile), and the CSS blur is gone. The cloud painter moves to its own lazy chunk `sky-clouds` (`sky-clouds.ts`), loaded where clouds are already painted when idle, so first paint gets smaller. The mockup imports `paintClouds` from the new file; it still has its own CSS. **Gates** | Mac VM, WebKit 1440, interleaved ABAB, 15 runs per cell | dev `db15794ac`: frames >= 50 ms | fix `43e424216`: frames >= 50 ms | |---|---|---| | Backspace on selected word (round 1 / 2) | 15 / 13 | 2 / 0 (the 2: at t=1.3 s, not after the key) | | Backspace at a caret (round 1 / 2) | 12 / 5 | 0 / 1 (at t=1.5 s, noise) | | typing | 0 / 0 | 0 / 0 | | idle (45 windows) | 0 / 0 | 0 / 2 (VM noise; one earlier B run had 6 idle too) | (Counts are raw rAF deltas; the harness leaves old rAF loops running so many hitches count twice, in both arms.) In the earlier f1 run (SHA `164eafb56`, same code path): dev 23+17 / 15+2, fix 0 / 0 over 30 deletes x2. - First paint (`bundle-size.mjs`, brotli): JS 230531 B vs dev 230817 B (-286 B); CSS 18379 vs 18383 B. New lazy chunk `sky-clouds` 1076 B, budget line added. - Unit: web vitest 109 passed, ui primitives 61 passed (2 new for the blur); svelte-check 0 errors. - Playwright `editor.spec` + `backdrops.spec`: chromium-1440 23/23, chromium-390 22 passed (dev-01); webkit-1440 20 passed, webkit-390 19 passed (dev-02). - Look: night-sky screenshots of dev and fix in Safari (Mac VM) look the same (clouds are faint at night). - **Not met cleanly:** typing latency on dev-01 (`keystroke to paint @perf`, ABAB x3): dev-01 was busy with other jobs, p50 86-870 ms in both arms, so the numbers carry no signal. Typing on the Mac shows 0 hitches and p95 25 vs 25 ms in both arms. The change touches no typing path; I'd re-run on a quiet dev-01 or perf VM if you want that number. Open risk: daytime clouds are brighter, so I only compared a night frame; the blur sigma (1.5 / 2 texels) was chosen to match 6 CSS px, please look at a day sky. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A live CSS blur on the drifting cloud canvases cost one 46-56 ms frame
about 70 ms after the bottom bar changed (any selection collapse or
deletion). The soft edge is now part of the pixels.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
perf: budget line for the lazy sky-clouds chunk (#984)
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
43e424216d
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Owner

Look check: dev db15794ac vs PR (day, dawn, dusk, night; light mode; clouds paused)

Found and fixed: at 390 the PR's clouds were visibly sharper than dev in day skies. The cloud strip is 360x120 texels stretched to the window, and the PR baked a fixed blur in texels (tuned at 1440, 4 px per texel). On a phone it is about 1 px per texel, so the same blur was a quarter as wide on screen. Fix 25e3d75e0: the blur is sized from the width the strip is shown at (sigmaFor, 6 CSS px as before), and the clouds repaint when the window width moves into another 160 px bucket. Budget line fix e2859af5b (see below).

How: Chromium on dev-01 and real Safari (safaridriver, Mac VM, dpr 1), same URL /?test=1&theme=light&sky=<phase>#/signin, .track animation paused. Pairs: dev left, PR right. 2x crops are centred on the brightest cloud block (same box for both). SSIM of the shots (1.0 = identical):

browser sky 1440 full / crop SSIM 390 full / crop SSIM
Chromium (dev-01) day 0.9994 / 0.9962 0.9994 / 0.9954
Chromium dawn 0.9994 / 0.9965 0.9994 / 0.9958
Chromium dusk 0.9995 / 0.9969 0.9995 / 0.9965
Chromium night 0.9997 / 0.9983 0.9997 / 0.9982
Safari (Mac VM) day 0.9993 / 0.9961 0.9994 / 0.9970
Safari dawn 0.9994 / 0.9964 0.9995 / 0.9971
Safari dusk 0.9994 / 0.9964 0.9995 / 0.9972
Safari night 0.9994 / 0.9966 0.9995 / 0.9973

Every pair is >= 0.995 (the 390 day crop was visibly sharper before the fix). The 2x crops, day first:

Safari day 390 safari-day-390-crop2x-dev_left-pr_right.png
Safari day 1440 safari-day-1440-crop2x-dev_left-pr_right.png
Chromium day 390 chromium-day-390-crop2x-dev_left-pr_right.png
Chromium day 1440 chromium-day-1440-crop2x-dev_left-pr_right.png

Full pairs (Safari): day safari-day-1440-full-dev_left-pr_right.png dawn safari-dawn-1440-full-dev_left-pr_right.png dusk safari-dusk-1440-full-dev_left-pr_right.png night safari-night-1440-full-dev_left-pr_right.png
Phone (Safari): day safari-day-390-full-dev_left-pr_right.png dusk safari-dusk-390-full-dev_left-pr_right.png night safari-night-390-full-dev_left-pr_right.png
Chromium full pairs, the other crops and the dawn phone pair are attached below on this comment (same names, chromium-*/safari-*).

Frame check on 25e3d75e0 (Mac VM, WebKit 1440, ABAB, 15 runs per cell, rAF deltas >= 50 ms in 1.5 s after Backspace on a selected word)

round dev db15794ac 25e3d75e0
1 7 0
2 19 0
Idle baselines: dev 0 / 0, fix 1 / 0 (max 56 ms once). Raw counts, hitches count twice in both arms.

One window resize across a bucket (1440 <-> 900, 12 resizes per run, 2 runs per arm, 1.5 s windows)

arm resizes frames >= 50 ms worst
dev (no repaint) 24 + 24 62 + 50 140 / 132 ms
PR 25e3d75e0 24 + 24 54 + 55 101 / 97 ms
A resize itself costs long frames in WebKit on this VM, on dev too; the cloud repaint (sliced, off the main path) adds none that I can measure (PR counts are at or below dev). Idle: 1 window of 96 over 50 ms.

Tests on dev-01 / dev-02 (binary from a recent dev build, Rust untouched by the PR)

  • packages/editor bun run test: 41 files, 526 passed. packages/ui vitest: 12 files, 96 passed (includes the new sigmaFor test).
  • editor.spec + backdrops.spec at 25e3d75e0: chromium-1440 23 passed; chromium-390 22 passed, 1 skipped; webkit-1440 20 passed, 3 skipped; webkit-390 19 passed, 4 skipped.
  • perf/web.sh --bundle-only --gate: the PR's 43e424216 failed it twice (the new sky-clouds line left the chunk budgets summing to 405.3 against a 404.2 total, and the chunk is now 1.149 KB). e2859af5b sets the line to 1.2 KB and takes 1.2 from index (229.2 -> 228): gate passes (exit 0), first JS 224.874 KB brotli (limit 240), total 367.646, sky-clouds 1.149.
  • Note: this branch is behind current dev (merge-base db15794ac); perf/budgets.json will conflict with dev's newer budget edits, so the budget lines need a rebase.
## Look check: dev `db15794ac` vs PR (day, dawn, dusk, night; light mode; clouds paused) **Found and fixed:** at 390 the PR's clouds were visibly sharper than dev in day skies. The cloud strip is 360x120 texels stretched to the window, and the PR baked a fixed blur in texels (tuned at 1440, 4 px per texel). On a phone it is about 1 px per texel, so the same blur was a quarter as wide on screen. Fix `25e3d75e0`: the blur is sized from the width the strip is shown at (`sigmaFor`, 6 CSS px as before), and the clouds repaint when the window width moves into another 160 px bucket. Budget line fix `e2859af5b` (see below). How: Chromium on dev-01 and real Safari (safaridriver, Mac VM, dpr 1), same URL `/?test=1&theme=light&sky=<phase>#/signin`, `.track` animation paused. Pairs: dev left, PR right. 2x crops are centred on the brightest cloud block (same box for both). SSIM of the shots (1.0 = identical): | browser | sky | 1440 full / crop SSIM | 390 full / crop SSIM | |---|---|---|---| | Chromium (dev-01) | day | 0.9994 / 0.9962 | 0.9994 / 0.9954 | | Chromium | dawn | 0.9994 / 0.9965 | 0.9994 / 0.9958 | | Chromium | dusk | 0.9995 / 0.9969 | 0.9995 / 0.9965 | | Chromium | night | 0.9997 / 0.9983 | 0.9997 / 0.9982 | | Safari (Mac VM) | day | 0.9993 / 0.9961 | 0.9994 / 0.9970 | | Safari | dawn | 0.9994 / 0.9964 | 0.9995 / 0.9971 | | Safari | dusk | 0.9994 / 0.9964 | 0.9995 / 0.9972 | | Safari | night | 0.9994 / 0.9966 | 0.9995 / 0.9973 | Every pair is >= 0.995 (the 390 day crop was visibly sharper before the fix). The 2x crops, day first: **Safari day 390** ![safari-day-390-crop2x-dev_left-pr_right.png](https://git.kayg.org/attachments/225d691b-2ddc-4068-b7a8-30f8ced8c6e1) **Safari day 1440** ![safari-day-1440-crop2x-dev_left-pr_right.png](https://git.kayg.org/attachments/03e50665-3a9b-4248-aeea-90cf69b4eea4) **Chromium day 390** ![chromium-day-390-crop2x-dev_left-pr_right.png](https://git.kayg.org/attachments/0ce1bf94-e29f-46c1-9b65-fc1199e77695) **Chromium day 1440** ![chromium-day-1440-crop2x-dev_left-pr_right.png](https://git.kayg.org/attachments/875ff3fd-388f-4e15-90df-2a2779fdd3d1) Full pairs (Safari): day ![safari-day-1440-full-dev_left-pr_right.png](https://git.kayg.org/attachments/cd7b4edd-d274-4193-9c3b-8f896ac00fae) dawn ![safari-dawn-1440-full-dev_left-pr_right.png](https://git.kayg.org/attachments/dc2facb5-1ab2-42a3-a58b-739fd399db47) dusk ![safari-dusk-1440-full-dev_left-pr_right.png](https://git.kayg.org/attachments/96098c2e-304a-4f49-9cfa-454fbe951287) night ![safari-night-1440-full-dev_left-pr_right.png](https://git.kayg.org/attachments/2567b2d5-98b2-4be9-8dd9-ae3bda12223c) Phone (Safari): day ![safari-day-390-full-dev_left-pr_right.png](https://git.kayg.org/attachments/02b419e3-692f-4ca2-8fcb-b58e64661ecd) dusk ![safari-dusk-390-full-dev_left-pr_right.png](https://git.kayg.org/attachments/40f5fd78-c91e-4501-9bc7-fbd95459dd42) night ![safari-night-390-full-dev_left-pr_right.png](https://git.kayg.org/attachments/07866606-f275-48c0-b11a-ee393c069bb9) Chromium full pairs, the other crops and the dawn phone pair are attached below on this comment (same names, `chromium-*`/`safari-*`). ### Frame check on `25e3d75e0` (Mac VM, WebKit 1440, ABAB, 15 runs per cell, rAF deltas >= 50 ms in 1.5 s after Backspace on a selected word) | round | dev `db15794ac` | `25e3d75e0` | |---|---|---| | 1 | 7 | 0 | | 2 | 19 | 0 | Idle baselines: dev 0 / 0, fix 1 / 0 (max 56 ms once). Raw counts, hitches count twice in both arms. ### One window resize across a bucket (1440 <-> 900, 12 resizes per run, 2 runs per arm, 1.5 s windows) | arm | resizes | frames >= 50 ms | worst | |---|---|---|---| | dev (no repaint) | 24 + 24 | 62 + 50 | 140 / 132 ms | | PR `25e3d75e0` | 24 + 24 | 54 + 55 | 101 / 97 ms | A resize itself costs long frames in WebKit on this VM, on dev too; the cloud repaint (sliced, off the main path) adds none that I can measure (PR counts are at or below dev). Idle: 1 window of 96 over 50 ms. ### Tests on dev-01 / dev-02 (binary from a recent dev build, Rust untouched by the PR) - `packages/editor` `bun run test`: 41 files, 526 passed. `packages/ui` vitest: 12 files, 96 passed (includes the new `sigmaFor` test). - `editor.spec` + `backdrops.spec` at `25e3d75e0`: chromium-1440 23 passed; chromium-390 22 passed, 1 skipped; webkit-1440 20 passed, 3 skipped; webkit-390 19 passed, 4 skipped. - `perf/web.sh --bundle-only --gate`: the PR's `43e424216` failed it twice (the new `sky-clouds` line left the chunk budgets summing to 405.3 against a 404.2 total, and the chunk is now 1.149 KB). `e2859af5b` sets the line to 1.2 KB and takes 1.2 from `index` (229.2 -> 228): gate passes (exit 0), first JS 224.874 KB brotli (limit 240), total 367.646, `sky-clouds` 1.149. - Note: this branch is behind current dev (merge-base `db15794ac`); `perf/budgets.json` will conflict with dev's newer budget edits, so the budget lines need a rebase.
Author
Owner

Merged into dev by the orchestrator; budgets resolved with sky-clouds funded from the widget reserve. The daily train will run the bundle gate on dev.

Merged into dev by the orchestrator; budgets resolved with sky-clouds funded from the widget reserve. The daily train will run the bundle gate on dev.
kayg closed this pull request 2026-11-06 13:02:21 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!987
No description provided.