port: Notes Float slice 7 fix: no glass recompute on scroll behind no glass #1104

Closed
kayg wants to merge 0 commits from port/notes-float-bg-fix into port/notes-float
Owner

Slice 7 fix: the adaptive glass did work on every scroll of the note list, behind no glass. Branch port/notes-float-bg-fix, base port/notes-float. Part of #1088.

Cause. packages/ui/src/lib/behind-glass.ts listened for scrollend on the document (capture) and, for ANY scroller, rebuilt the busy map by walking document.body with a TreeWalker (reading getBoundingClientRect, checkVisibility, matches) and recomputed every registered glass (getPropertyValue, rect reads). A wheel gives one scrollend per step. On the perf VM that was +53 % script time and +31 % style recalc while scrolling the note list on the integration build (4-arm session, 8 runs per arm, dev/dev2 control within 1.2 %).

Fix. (1) The module remembers each glass's rectangle at its last answer; a scrollend is ignored when the scroller's box overlaps no glass (one rectangle read for the scroller; the page itself scrolling, or a glass never answered yet, always counts). (2) A burst of scroll ends is judged ONCE, 80 ms after the burst (judging each read the scroller's rectangle, which forced a layout, 40 times: first attempt measured getBoundingClientRect at +567 us per normalised key from that guard alone). Nothing about how the glass looks changes.

Spec. adaptive-glass.spec.ts: "scrolling the note list (no glass behind it) and typing recompute nothing" reads behindStats.runs before and after a wheel scroll of the list and a short line of typing, and it must not move.

Function profile (V8 sampler, 100 us, dev-02 aarch64, 4 runs per build, self time per normalised key; which functions appear, not absolute ms): scroll of the note list, integration build before the fix vs dev: getBoundingClientRect +1398, getPropertyValue +911, nextNode +621, acceptNode +333, checkVisibility +177, matches +240. After the fix: none of the walker, getPropertyValue, checkVisibility or matches entries appear; getBoundingClientRect +14; total 16.5 vs dev 16.6. Typing: no behind-glass function in the diff; JS total 74.0 vs dev 73.8.

Gates. svelte-check 0 errors; unit tests 28 files / 267 tests; adaptive-glass, glass, keys-no-motion, search-palette, composer-open, window-layout, contrast on chromium-1440 (41 passed), chromium-390 (15), webkit-1440 (41), webkit-390 (14), none failed (dev-02, aarch64).

Not done here, owed before the final merge: the pooled typing/list ABAB with this fix on perf-01 (the shell-only arm is +0.9 % on list, i.e. dev's level; the full arm without this fix was +6.0 %), a real-Safari list-scroll rAF run (the Mac renders at about 1 frame/s right now, a VM display problem), and an iPhone-simulator shot.

🤖 Generated with Claude Code

Slice 7 fix: the adaptive glass did work on every scroll of the note list, behind no glass. Branch `port/notes-float-bg-fix`, base `port/notes-float`. Part of #1088. **Cause.** `packages/ui/src/lib/behind-glass.ts` listened for `scrollend` on the document (capture) and, for ANY scroller, rebuilt the busy map by walking `document.body` with a `TreeWalker` (reading `getBoundingClientRect`, `checkVisibility`, `matches`) and recomputed every registered glass (`getPropertyValue`, rect reads). A wheel gives one `scrollend` per step. On the perf VM that was +53 % script time and +31 % style recalc while scrolling the note list on the integration build (4-arm session, 8 runs per arm, dev/dev2 control within 1.2 %). **Fix.** (1) The module remembers each glass's rectangle at its last answer; a `scrollend` is ignored when the scroller's box overlaps no glass (one rectangle read for the scroller; the page itself scrolling, or a glass never answered yet, always counts). (2) A burst of scroll ends is judged ONCE, 80 ms after the burst (judging each read the scroller's rectangle, which forced a layout, 40 times: first attempt measured `getBoundingClientRect` at +567 us per normalised key from that guard alone). Nothing about how the glass looks changes. **Spec.** `adaptive-glass.spec.ts`: "scrolling the note list (no glass behind it) and typing recompute nothing" reads `behindStats.runs` before and after a wheel scroll of the list and a short line of typing, and it must not move. **Function profile** (V8 sampler, 100 us, dev-02 aarch64, 4 runs per build, self time per normalised key; which functions appear, not absolute ms): scroll of the note list, integration build before the fix vs dev: `getBoundingClientRect` +1398, `getPropertyValue` +911, `nextNode` +621, `acceptNode` +333, `checkVisibility` +177, `matches` +240. After the fix: none of the walker, `getPropertyValue`, `checkVisibility` or `matches` entries appear; `getBoundingClientRect` +14; total 16.5 vs dev 16.6. Typing: no behind-glass function in the diff; JS total 74.0 vs dev 73.8. **Gates.** svelte-check 0 errors; unit tests 28 files / 267 tests; `adaptive-glass`, `glass`, `keys-no-motion`, `search-palette`, `composer-open`, `window-layout`, `contrast` on chromium-1440 (41 passed), chromium-390 (15), webkit-1440 (41), webkit-390 (14), none failed (dev-02, aarch64). **Not done here, owed before the final merge:** the pooled typing/list ABAB with this fix on perf-01 (the shell-only arm is +0.9 % on list, i.e. dev's level; the full arm without this fix was +6.0 %), a real-Safari list-scroll rAF run (the Mac renders at about 1 frame/s right now, a VM display problem), and an iPhone-simulator shot. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The walk over the whole document on every scrollend was most of the extra script time of scrolling the
note list on the perf VM (getBoundingClientRect, TreeWalker, checkVisibility, getPropertyValue).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ui: a burst of scroll ends is judged once (a wheel gives one per step; each judgement forced a layout)
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
ee22cc6734
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Owner

Merged into port/notes-float (a --no-ff git merge, by the captain) and contained in the integration head e3bc2040c. Closing this PR; the behind-glass fix ships with the final merge of port/notes-float into dev. Open perf items are tracked on #1088.

Merged into `port/notes-float` (a --no-ff git merge, by the captain) and contained in the integration head `e3bc2040c`. Closing this PR; the behind-glass fix ships with the final merge of `port/notes-float` into dev. Open perf items are tracked on #1088.
kayg closed this pull request 2026-11-13 01:46:37 +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!1104
No description provided.