App switch frame hitch (57–147 ms) in Safari #1085

Open
opened 2026-11-11 21:20:35 +00:00 by kayg · 10 comments
Owner

App switch frame hitch (57–147 ms) in Safari

Found while measuring #1075 (switcher). Whenever the Float / app-window layout really switches app (Notes → Mail → Home → Tasks, by the sidebar switcher or ⌃1–5 / ⌃⌥←→), real Safari on the Mac VM drops one frame of 57–147 ms; the idle worst frame is 21–25 ms. The old dots switcher does the same, so the switcher is not the cause: it is the app-switch path.

Branch fix/app-switch-hitch (off review/calendar-2), mockup only, not merged. Head SHA is in the comment below.

What lands in that frame (profile)

Real-Safari rAF trace (blank page first: 55.8–58.7 rAF/s, so the VM runs at ~60 Hz): the hitch is one main-thread task of 75–134 ms (the synchronous mount of the whole next app, plus tearing the old one down), then a second frame of 33–78 ms (style + layout + paint of the new tree). Hiding the global layer's blur, the sharp window backdrop or all backdrop-filter in turn did not remove it, so it is not a blur re-raster.

Chrome CDP CPU profile of a switch (Mac VM, vite dev, attribution only), self time per switch:

  • getComputedStyle().getPropertyValue ≈ 23 ms of ≈ 66 ms: syncEdges() (lib/edges.ts) run from ArtStack's publish effect and its cleanup, in both backdrops (the sharp window picture and the app's own). Cleanup cleared --edge-base and resynced, then the twin mounted, wrote it again and resynced: four whole-document restyles inside one task.
  • A MutationObserver on the root during a switch showed data-win removed and set again (WindowLayout's effect cleanup then its twin's effect), and --toast-x removed and written again: each a restyle of the whole document.
  • The rest is a flat spread over WindowLayout / Shell / sidebar tree / page (no single hot spot): Svelte mount cost of a whole app in one task.

Fix (3 parts)

  1. edgeHolder() (lib/edges.ts): a picture (ArtStack, Backdrop) and the window layout (data-win, --wl-mic-r, --toast-x) clear what they put on the root only when the last copy goes, one microtask later. A replacement mounted in the same flush causes no root write and no syncEdges(). ArtStack/Backdrop also skip a re-sync when the edge/sky is unchanged.
  2. Staged mount (WindowLayout, app switch only; the boot is not staged): window → sidebar → page → bars → list + inspector, one per rAF. While it builds the cards are visibility: hidden (no half-built card on screen, no loading state, no animation added).
  3. Spec tests/app-switch-stages.spec.ts (no timing asserted): boot not staged; window whole after a switch; cards hidden + page unbuilt at insertion, shown + built after; no root data-win / --toast-x / --edge-base / --wl-mic-r clear-and-rewrite on a window→window switch; rapid back-and-forth ends on the last app with one window.

Result in real Safari (Mac VM, 1440×900, DPR 1, production build, vite preview; warm-up 2 cycles discarded; ABAB ×3, 10 cycles each → 30 switches per app per variant)

Worst frame in the 900 ms after a switch (ms):

to base median base p90 base max new median new p90 new max
Notes 129 173 199 62 117 272
Mail 126 243 564 58 170 237
Home 92 355 687 54 107 329
Tasks 66 189 319 72 175 228
all (n=120) 110 193 687 61 131 329

p95 frame over all windows: base 38 → new 26 ms (idle p95 20 ms; idle worst 21–25, one 58 in the new run). Per-round medians: base 129 / 92 / 118, new 59 / 64 / 61.

The goal (every frame < 33 ms) is NOT reached: about half the hitch is gone (≈ 110 → ≈ 60 ms), but a ~55 ms frame remains. Experiments on the new build (CSS display:none, worst-frame median of the second frame): sharp window backdrop hidden 54 → 39; whole window hidden 54 → 41; global layer 54 → 58 (no effect); all three 54 → 30. So the remaining frame is mostly the render of the NEW window's layers (the sharp backdrop picture inside the clip-path window plus the cards), which no scheduling trick can hide. Tasks (its own layout, not WindowLayout) is not staged and shows no gain.

Honest remaining options (need kayg's call, bigger than this PR)

  • Keep the window (WindowLayout, both backdrops) mounted across app switches and swap only the app's content (the render cost of the layers disappears).
  • Or keep recently used apps mounted but inert: not attempted, because every screen reads the global route, so hidden screens would react to other apps' routes.
  • Batch the forced layouts at mount (packages/ui Selector.svelte measures offsetLeft per instance at mount; shared package, so left alone).

Not done / limits

  • iPhone sim on std not measured: the phone path is PhoneStack (not WindowLayout); only the ArtStack/Backdrop edge dedupe applies there. Heap with 3 apps warm: n/a, nothing is kept mounted.
  • Mac numbers taken only under the lock; runs overlapping the contrast lane's Safari keystroke (orchestrator notice) were discarded and redone.
## App switch frame hitch (57–147 ms) in Safari Found while measuring #1075 (switcher). Whenever the Float / app-window layout really switches app (Notes → Mail → Home → Tasks, by the sidebar switcher or ⌃1–5 / ⌃⌥←→), real Safari on the Mac VM drops one frame of 57–147 ms; the idle worst frame is 21–25 ms. The old dots switcher does the same, so the switcher is not the cause: it is the app-switch path. Branch `fix/app-switch-hitch` (off `review/calendar-2`), mockup only, **not merged**. Head SHA is in the comment below. ## What lands in that frame (profile) Real-Safari rAF trace (blank page first: 55.8–58.7 rAF/s, so the VM runs at ~60 Hz): the hitch is **one main-thread task of 75–134 ms** (the synchronous mount of the whole next app, plus tearing the old one down), then a **second frame of 33–78 ms** (style + layout + paint of the new tree). Hiding the global layer's blur, the sharp window backdrop or all backdrop-filter in turn did not remove it, so it is not a blur re-raster. Chrome CDP CPU profile of a switch (Mac VM, vite dev, attribution only), self time per switch: - `getComputedStyle().getPropertyValue` **≈ 23 ms** of ≈ 66 ms: `syncEdges()` (lib/edges.ts) run from `ArtStack`'s publish effect **and its cleanup**, in both backdrops (the sharp window picture and the app's own). Cleanup cleared `--edge-base` and resynced, then the twin mounted, wrote it again and resynced: **four whole-document restyles inside one task.** - A MutationObserver on the root during a switch showed `data-win` removed and set again (WindowLayout's effect cleanup then its twin's effect), and `--toast-x` removed and written again: each a restyle of the whole document. - The rest is a flat spread over WindowLayout / Shell / sidebar tree / page (no single hot spot): Svelte mount cost of a whole app in one task. ## Fix (3 parts) 1. **`edgeHolder()`** (lib/edges.ts): a picture (ArtStack, Backdrop) and the window layout (`data-win`, `--wl-mic-r`, `--toast-x`) clear what they put on the root only when the **last** copy goes, one microtask later. A replacement mounted in the same flush causes no root write and no `syncEdges()`. ArtStack/Backdrop also skip a re-sync when the edge/sky is unchanged. 2. **Staged mount** (WindowLayout, app switch only; the boot is not staged): window → sidebar → page → bars → list + inspector, one per rAF. While it builds the cards are `visibility: hidden` (no half-built card on screen, no loading state, no animation added). 3. Spec `tests/app-switch-stages.spec.ts` (no timing asserted): boot not staged; window whole after a switch; cards hidden + page unbuilt at insertion, shown + built after; no root `data-win` / `--toast-x` / `--edge-base` / `--wl-mic-r` clear-and-rewrite on a window→window switch; rapid back-and-forth ends on the last app with one window. ## Result in real Safari (Mac VM, 1440×900, DPR 1, production build, vite preview; warm-up 2 cycles discarded; ABAB ×3, 10 cycles each → 30 switches per app per variant) Worst frame in the 900 ms after a switch (ms): | to | base median | base p90 | base max | new median | new p90 | new max | |---|---|---|---|---|---|---| | Notes | 129 | 173 | 199 | 62 | 117 | 272 | | Mail | 126 | 243 | 564 | 58 | 170 | 237 | | Home | 92 | 355 | 687 | 54 | 107 | 329 | | Tasks | 66 | 189 | 319 | 72 | 175 | 228 | | **all (n=120)** | **110** | **193** | **687** | **61** | **131** | **329** | p95 frame over all windows: base 38 → new 26 ms (idle p95 20 ms; idle worst 21–25, one 58 in the new run). Per-round medians: base 129 / 92 / 118, new 59 / 64 / 61. **The goal (every frame < 33 ms) is NOT reached**: about half the hitch is gone (≈ 110 → ≈ 60 ms), but a ~55 ms frame remains. Experiments on the new build (CSS display:none, worst-frame median of the second frame): sharp window backdrop hidden 54 → 39; whole window hidden 54 → 41; global layer 54 → 58 (no effect); all three 54 → 30. So the remaining frame is mostly the render of the NEW window's layers (the sharp backdrop picture inside the clip-path window plus the cards), which no scheduling trick can hide. Tasks (its own layout, not WindowLayout) is not staged and shows no gain. ## Honest remaining options (need kayg's call, bigger than this PR) - Keep the window (WindowLayout, both backdrops) mounted across app switches and swap only the app's content (the render cost of the layers disappears). - Or keep recently used apps mounted but inert: not attempted, because every screen reads the global `route`, so hidden screens would react to other apps' routes. - Batch the forced layouts at mount (packages/ui `Selector.svelte` measures `offsetLeft` per instance at mount; shared package, so left alone). ## Not done / limits - iPhone sim on std not measured: the phone path is `PhoneStack` (not WindowLayout); only the ArtStack/Backdrop edge dedupe applies there. Heap with 3 apps warm: n/a, nothing is kept mounted. - Mac numbers taken only under the lock; runs overlapping the contrast lane's Safari keystroke (orchestrator notice) were discarded and redone.
Author
Owner

Head 9505a3b48 (branch fix/app-switch-hitch, 8 commits off origin/review/calendar-2 0c8d96818) — gates and the rest of the evidence

Computed values (real Safari, Mac VM, 1440, after a switch settled, base vs head; fontFamily/Size/Weight, lineHeight, letterSpacing, padding ×4, radius ×4, width, height):
Notes / Mail / Home × sidebar (.wside-in), card (.wc-main/.wc-page), toolbar (.tb): 153 values compared, 0 changed. (Tasks has no WindowLayout, so those three selectors don't exist there; it is unchanged code.)

First paint (production build, gzip, the assets index.html loads): index js 545 549 → 545 667 B (+118), Backdrop js 70 132 → 70 269 (+137), css +8 / +2 B: about +0.27 KB gz (edgeHolder, the stage counter). Per the 11-11 note small first-paint growth needs no ask; runtime frames are the gate and are better, not worse.

Typing / editor mount: untouched (no editor file changed). Heap with 3 apps warm: n/a, nothing is kept mounted.

Specs (Playwright, targeted; dev-01 Chromium, dev-02 WebKit; trains held the slots for hours and dev-01 ran at load 40–58, so timing-based specs are noisy):

  • new tests/app-switch-stages.spec.ts: 5/5 pass on Chromium (the WebKit run flagged my first, per-frame version of the "cards hidden" test: headless WebKit starves rAF; rewritten to read the state at the insertion, commit 9505a3b48; not yet re-run on WebKit after the rewrite).
  • Existing app-switch, app-keys, app-swipe-overlap, app-tabs on origin/review/calendar-2 (base) fail already: Chromium 7 (app-swipe-overlap ×2, app-switch "at rest" and the nine-width "raised row" set, :217 1 of 3) and WebKit 7. On head, with --repeat-each=3 single worker (Chromium): app-swipe-overlap:90 3/3 pass, app-switch:152 2/2 pass, app-keys:30 2/3 pass, 1 fail (base 3/3), app-switch:217 0/2 pass (base 2/3). I think these are the staged build meeting a loaded machine (the test acts 500 ms after a switch and expects the Files filter field to be focusable; with rAF at a few fps the 5 stages take longer than that), but I did not prove it. Treat app-keys:30 and app-switch:217 as open: if they reproduce on a quiet VM they block, and the fix would be to wait for .wcards.staging to go in those specs or to stage fewer frames.

Open risks / what I could not do

  • Goal not reached: worst frame ≈ 60 ms (was ≈ 110), still > 33 ms. The remainder is the render of the new window's layers; see options in the issue body.
  • iPhone sim on std not measured (phone path is PhoneStack).
  • Staging means the new app's content is built over about five frames (~80 ms at 60 Hz, longer on a slow device). It is not shown half-built, but typing into a field in the first ~80 ms after a switch has nothing to land in.
  • Mac numbers: blank rAF 55.8–58.7/s each run; ABAB ×3 clean after a 2-cycle warm-up; the earlier unwarmed runs (first of each pair, 300+ ms) and everything taken while the contrast lane could have been in Safari were discarded.
## Head `9505a3b48` (branch `fix/app-switch-hitch`, 8 commits off `origin/review/calendar-2` `0c8d96818`) — gates and the rest of the evidence **Computed values (real Safari, Mac VM, 1440, after a switch settled, base vs head; `fontFamily/Size/Weight, lineHeight, letterSpacing, padding ×4, radius ×4, width, height`):** Notes / Mail / Home × sidebar (`.wside-in`), card (`.wc-main`/`.wc-page`), toolbar (`.tb`): **153 values compared, 0 changed.** (Tasks has no WindowLayout, so those three selectors don't exist there; it is unchanged code.) **First paint (production build, gzip, the assets `index.html` loads):** index js 545 549 → 545 667 B (+118), Backdrop js 70 132 → 70 269 (+137), css +8 / +2 B: **about +0.27 KB gz** (`edgeHolder`, the stage counter). Per the 11-11 note small first-paint growth needs no ask; runtime frames are the gate and are better, not worse. **Typing / editor mount:** untouched (no editor file changed). **Heap with 3 apps warm:** n/a, nothing is kept mounted. **Specs (Playwright, targeted; dev-01 Chromium, dev-02 WebKit; trains held the slots for hours and dev-01 ran at load 40–58, so timing-based specs are noisy):** - new `tests/app-switch-stages.spec.ts`: 5/5 pass on Chromium (the WebKit run flagged my first, per-frame version of the "cards hidden" test: headless WebKit starves rAF; rewritten to read the state at the insertion, commit `9505a3b48`; **not yet re-run** on WebKit after the rewrite). - Existing `app-switch`, `app-keys`, `app-swipe-overlap`, `app-tabs` on `origin/review/calendar-2` (base) fail already: Chromium 7 (`app-swipe-overlap` ×2, `app-switch` "at rest" and the nine-width "raised row" set, `:217` 1 of 3) and WebKit 7. On head, with `--repeat-each=3` single worker (Chromium): `app-swipe-overlap:90` 3/3 pass, `app-switch:152` 2/2 pass, `app-keys:30` **2/3 pass, 1 fail** (base 3/3), `app-switch:217` **0/2 pass** (base 2/3). I think these are the staged build meeting a loaded machine (the test acts 500 ms after a switch and expects the Files filter field to be focusable; with rAF at a few fps the 5 stages take longer than that), but I did not prove it. **Treat `app-keys:30` and `app-switch:217` as open**: if they reproduce on a quiet VM they block, and the fix would be to wait for `.wcards.staging` to go in those specs or to stage fewer frames. **Open risks / what I could not do** - Goal not reached: worst frame ≈ 60 ms (was ≈ 110), still > 33 ms. The remainder is the render of the new window's layers; see options in the issue body. - iPhone sim on std not measured (phone path is `PhoneStack`). - Staging means the new app's content is built over about five frames (~80 ms at 60 Hz, longer on a slow device). It is not shown half-built, but typing into a field in the first ~80 ms after a switch has nothing to land in. - Mac numbers: blank rAF 55.8–58.7/s each run; ABAB ×3 clean after a 2-cycle warm-up; the earlier unwarmed runs (first of each pair, 300+ ms) and everything taken while the contrast lane could have been in Safari were discarded.
Author
Owner

Coordination (flaky-spec lane, review/calendar-2 ad95f9b54): I checked fix/app-switch-hitch against 0c8d96818: it adds only tests/app-switch-shell.spec.ts and does not touch app-keys.spec.ts or app-switch.spec.ts, so I took those two. My change there is waits only: the fixed pauses (400–1500 ms) after app switches, the dock/drawer decision and the sidebar-swipe snap-back became waits on state (.wl.switching gone, animations finished, the sidebar's own inert/width stable; the snap-back test now delivers the wheel and reads the sidebar's offset in one task, because app-swipe's own 90 ms idle timer could fire between two separate calls on a busy host). No assertion was loosened and no source file changed. If you edit those two spec files, please rebase on review/calendar-2 first.

Coordination (flaky-spec lane, review/calendar-2 `ad95f9b54`): I checked `fix/app-switch-hitch` against `0c8d96818`: it adds only `tests/app-switch-shell.spec.ts` and does not touch `app-keys.spec.ts` or `app-switch.spec.ts`, so I took those two. My change there is waits only: the fixed pauses (400–1500 ms) after app switches, the dock/drawer decision and the sidebar-swipe snap-back became waits on state (`.wl.switching` gone, animations finished, the sidebar's own inert/width stable; the snap-back test now delivers the wheel and reads the sidebar's offset in one task, because app-swipe's own 90 ms idle timer could fire between two separate calls on a busy host). No assertion was loosened and no source file changed. If you edit those two spec files, please rebase on `review/calendar-2` first.
Author
Owner

Round 2: persistent window (head fd0330536) — goal still NOT reached

Done as asked, on top of 9505a3b48: one WindowLayout kept mounted by WindowHost (App.svelte); an app's Shell renders WindowSlot, which hands it its snippets and flags (lib/window-slot.svelte.ts, release is one microtask late so a switch never unmounts it; leaving for Tasks/Settings does). The window, .gl global layer, sharp .wbg backdrop, shadow and sidebar frame are the same DOM nodes after a switch (spec checks it); the AI area keeps its chat too. An app change is a cut (jump turns the springs off for two frames; only a swipe plays the AS4 slide). Staged mount removed. edgeHolder() kept. Tasks untouched.

Frame table (real Safari, Mac VM, 1440×900, prod build, blank rAF 57.8/s, 2-cycle warm-up dropped, ABAB ×3, 10 cycles × 4 apps = 120 switches per variant)

to base median new median base p90 new p90
Notes 127 92 389 356
Mail 132 85 375 715
Home 81 80 158 293
Tasks 60 84 123 219
all 112 85 197 356

p95 frame 41 → 28 ms; idle worst 23 (max 48 once). Per-round medians base 105 / 114 / 116, new 72 / 172 / 82 (round 2 had a slow stretch). A second, same-session pass: base 102, persistent 81. Every switch still has a frame over 33 ms; the p90 tail is no better. Tasks looks worse (60 → 84) but its code is unchanged; it now also tears the persistent window down, and the run is noisy, so treat it as noise-or-small until re-run on a quiet Mac.

The persistent window alone is WORSE than round 1's staged mount (median ≈ 60). Why: it removes the window's render cost but the whole content mount (sidebar body + page + list + bars) now lands in one task. Probes on this build (CSS display:none, and a throwaway ?skip= switch that stopped rendering parts, discarded): with ALL content skipped a switch still costs a ~55 ms worst frame (Mail 28/56, Home 52/31, Tasks 71), so a big part of the remainder is per-app cost outside the window (Home/Tasks screen init, Mail's list/inspector card creation, forced layouts in Selector/portal/Voice rAF reads), not the shell. I tried building only the list, inspector and bars one frame later (sidebar and page in frame 0, so typing works): 75–82 vs 81, no gain, so I dropped it (commit fd0330536). Staging the page itself is what bought round 1 its gain, and that is exactly what can't be allowed (keys lost).

Specs

  • New tests/app-switch-shell.spec.ts (replaces the staging spec): 10/10 on dev-02 (5 Chromium + 5 WebKit): same elements after Notes→Mail→Home→Notes; typing right after a switch (Files filter field is visible and takes focus in the same task the field enters the DOM, then "quick brown fox" lands in full); no root data-win/--toast-x/--edge-base/--wl-mic-r clear-and-rewrite; Tasks leaves and returns; rapid back-and-forth ends on the last app with one window.
  • Suspect specs ×10 on dev-02 (chromium + webkit, --repeat-each=10, head vs origin/review/calendar-2):
    • app-keys:30: fails 10/10 on BOTH projects on head AND on base (it passed on dev-01 earlier), so not caused by this branch; but it is red at base on dev-02 and needs its own look.
    • app-switch "snaps back" (swipe): Chromium 10/10 on both; WebKit first batch head 5/10 vs base 1/10 while both ran concurrently on a loaded host; re-run alone ×20: head 19/20, base 20/20. One failure in 20; I can't call it a regression or rule it out.
    • The old-dots app-switch specs ("at rest", the nine-width "raised row") fail on base too (the dots were replaced by AppSwitch).
  • Not run: the full suites (targeted specs only, as agreed for review/* merges).

iPhone sim (std, my own iPhone 18 Pro iOS 27 sim, deleted after; PhoneStack path)

Home, Note, Mail, Tasks and a Home→Mail route change, light and dark, base vs head bundle (20 shots, local-only): visually identical; I compared Mail in light side by side and only the status-bar clock differs. No driver was attached, so no in-page switch gesture and no frame numbers on the phone (taps/swipes would need the XCUITest runner); the phone path only shares the edgeHolder dedupe.

Honest state / what I'd do next

Shipping this head gives ~25 % off the median (112 → 85 ms), no lost keys, one window, no half-built UI. It does not meet "< 33 ms". The remaining time is not the shell; the next steps, each its own PR and kayg's call: (1) make Home's and Tasks' screen init lazy/cheap, (2) keep the list and inspector cards mounted (collapsed) so Mail/Notes don't create glass layers on a switch, (3) batch the forced layouts in Selector/portal/Voice (shared package), (4) hoist the sidebar dock out of each app's sidebar into the persistent frame. I can measure each with the same protocol.

## Round 2: persistent window (head `fd0330536`) — goal still NOT reached Done as asked, on top of `9505a3b48`: **one `WindowLayout` kept mounted by `WindowHost`** (App.svelte); an app's Shell renders `WindowSlot`, which hands it its snippets and flags (`lib/window-slot.svelte.ts`, release is one microtask late so a switch never unmounts it; leaving for Tasks/Settings does). The window, `.gl` global layer, sharp `.wbg` backdrop, shadow and sidebar frame are the **same DOM nodes** after a switch (spec checks it); the AI area keeps its chat too. An app change is a cut (`jump` turns the springs off for two frames; only a swipe plays the AS4 slide). **Staged mount removed. `edgeHolder()` kept.** Tasks untouched. ### Frame table (real Safari, Mac VM, 1440×900, prod build, blank rAF 57.8/s, 2-cycle warm-up dropped, ABAB ×3, 10 cycles × 4 apps = 120 switches per variant) | to | base median | new median | base p90 | new p90 | |---|---|---|---|---| | Notes | 127 | 92 | 389 | 356 | | Mail | 132 | 85 | 375 | 715 | | Home | 81 | 80 | 158 | 293 | | Tasks | 60 | 84 | 123 | 219 | | **all** | **112** | **85** | 197 | 356 | p95 frame 41 → 28 ms; idle worst 23 (max 48 once). Per-round medians base 105 / 114 / 116, new 72 / 172 / 82 (round 2 had a slow stretch). A second, same-session pass: base 102, persistent 81. **Every switch still has a frame over 33 ms; the p90 tail is no better.** Tasks looks worse (60 → 84) but its code is unchanged; it now also tears the persistent window down, and the run is noisy, so treat it as noise-or-small until re-run on a quiet Mac. **The persistent window alone is WORSE than round 1's staged mount (median ≈ 60).** Why: it removes the window's render cost but the whole content mount (sidebar body + page + list + bars) now lands in one task. Probes on this build (CSS `display:none`, and a throwaway `?skip=` switch that stopped rendering parts, discarded): with ALL content skipped a switch still costs a ~55 ms worst frame (Mail 28/56, Home 52/31, Tasks 71), so a big part of the remainder is **per-app cost outside the window** (Home/Tasks screen init, Mail's list/inspector card creation, forced layouts in Selector/portal/Voice rAF reads), not the shell. I tried building only the list, inspector and bars one frame later (sidebar and page in frame 0, so typing works): 75–82 vs 81, no gain, so I dropped it (commit `fd0330536`). Staging the page itself is what bought round 1 its gain, and that is exactly what can't be allowed (keys lost). ### Specs - New `tests/app-switch-shell.spec.ts` (replaces the staging spec): 10/10 on dev-02 (5 Chromium + 5 WebKit): same elements after Notes→Mail→Home→Notes; **typing right after a switch** (Files filter field is visible and takes focus in the same task the field enters the DOM, then "quick brown fox" lands in full); no root `data-win`/`--toast-x`/`--edge-base`/`--wl-mic-r` clear-and-rewrite; Tasks leaves and returns; rapid back-and-forth ends on the last app with one window. - Suspect specs ×10 on dev-02 (chromium + webkit, `--repeat-each=10`, head vs `origin/review/calendar-2`): - `app-keys:30`: **fails 10/10 on BOTH projects on head AND on base** (it passed on dev-01 earlier), so not caused by this branch; but it is red at base on dev-02 and needs its own look. - `app-switch` "snaps back" (swipe): Chromium 10/10 on both; WebKit first batch head 5/10 vs base 1/10 while both ran concurrently on a loaded host; re-run alone ×20: **head 19/20, base 20/20**. One failure in 20; I can't call it a regression or rule it out. - The old-dots `app-switch` specs ("at rest", the nine-width "raised row") fail on base too (the dots were replaced by AppSwitch). - Not run: the full suites (targeted specs only, as agreed for review/* merges). ### iPhone sim (std, my own iPhone 18 Pro iOS 27 sim, deleted after; `PhoneStack` path) Home, Note, Mail, Tasks and a Home→Mail route change, light and dark, base vs head bundle (20 shots, local-only): visually identical; I compared Mail in light side by side and only the status-bar clock differs. No driver was attached, so no in-page switch gesture and no frame numbers on the phone (taps/swipes would need the XCUITest runner); the phone path only shares the `edgeHolder` dedupe. ### Honest state / what I'd do next Shipping this head gives ~25 % off the median (112 → 85 ms), no lost keys, one window, no half-built UI. It does not meet "< 33 ms". The remaining time is not the shell; the next steps, each its own PR and kayg's call: (1) make Home's and Tasks' screen init lazy/cheap, (2) keep the list and inspector cards mounted (collapsed) so Mail/Notes don't create glass layers on a switch, (3) batch the forced layouts in `Selector`/`portal`/`Voice` (shared package), (4) hoist the sidebar dock out of each app's sidebar into the persistent frame. I can measure each with the same protocol.
Author
Owner

Round 3 (head eeb0327cd): batched reads, kept cards, lazy Home tiles — steps 1–3 done, goal NOT reached

Commits (one per step, on top of the persistent window): 48394d549 read pass, ed51926bf list/inspector cards kept, eeb0327cd Home tiles.

1. Read pass. packages/ui/src/lib/read-pass.ts: readThenWrite(job) runs every queued job's reads, then every write (frame or same-task microtask). Used by Selector's first placing (one pass for every selector mounted in a flush; the first ResizeObserver report, which only repeats what the mount measured, no longer triggers a second fit+measure+place), and by the tree-section and inline-scroll fades (they each read then wrote in their own rAF, so N sections = N layouts). Safari attribution first (wrapped every layout read, ≥0.15 ms, first 130 ms of a switch, dev build): ≈30 ms/switch of forced reads, but the biggest single read (≈11 ms, a Svelte bind:clientHeight) and AppSwitch's clientWidth are the first reader paying the layout everything else would pay at render anyway, so the batchable part is only the repeated reads: Selector (≈5), fades (≈3.5), Editor (≈1.4). Shared packages/ui change (Selector): apps/web uses it too; I did not run the web specs.
2. List + inspector cards kept mounted once any app has needed them (inner content only while shown; hidden card is visibility:hidden, inert, width 0). Mail ↔ Notes no longer creates those glass layers. The main card still differs between Notes (header wrapper + card) and the others, so it is still re-created on Notes ↔ others: keeping both variants mounted would put a hidden .wc-main/.wc-wrap in the DOM that ~10 specs querySelector first.
3. Home: the first bento of five tiles is there in the first frame (lead, the two beside, the one under, the wide one); the other 7 are added two per idle callback (requestIdleCallback, 90 ms timer in Safari). The composer and sidebar are untouched, so typing works from the first frame, and nothing shows empty: the grid just ends where the screen does.

Frame deltas (real Safari, Mac VM, 1440×900, prod build, same protocol; ABAB ×3, 10 cycles × 4 apps = 120 switches per variant; blank rAF 58.2/s; each row is a separate session, so compare within the row's session)

session variants (worst-frame median, all apps)
A base 117 · persistent window 78 · +read pass 73 · +kept cards 75
B base 104 · +kept cards 76 · +Home tiles 86

Per app (median / p90, session A): base notes 130/193 mail 161/389 home 84/154 tasks 64/215; persistent 80/143, 83/178, 75/107, 75/347; +read pass 78/113, 77/186, 64/127, 72/93; +kept cards 77/124, 90/331, 72/138, 74/112.
Session B: +kept cards notes 93 mail 86 home 71 tasks 73; +Home tiles notes 88 mail 126 home 64 tasks 78.

Read: the read pass is worth about −5 ms; kept cards −0 (no change within noise); Home tiles −7 ms on Home itself (71 → 64) but the same build shows Mail at 126 (86 before), which I read as noise (its p90 swings 215–543 between sessions) rather than an effect of Home code. I cannot show any of the three steps beating the run-to-run noise except the read pass, and even that is small. The median worst frame is still ≈ 75 ms, so the stop condition (< 33 ms) is not met; I stopped after step 3 as instructed.

Where the rest is (for the next round)

With all content skipped the switch still costs ≈ 55 ms in Safari, and a first-reader layout of ≈ 20 ms plus ≈ 50 ms of Svelte DOM creation/teardown for the new app's sidebar, page and cards remain. What I think is left, in order: (1) the old app's whole sidebar/page tree is destroyed and the new one built in one task: a keyed, reused sidebar frame (AppSide/Tree rows) would turn creation into updates; (2) bind:clientHeight/ResizeObserver-driven layout in PaneScroll, AppTree and Composer, which makes layout synchronous at mount; (3) the main card difference between Notes and the other apps.

Specs

Head on dev-02, Chromium + WebKit: app-switch-shell (incl. typing right after a switch), window-layout, contacts-float: 112 passed, 0 failed. app-keys:30 left alone as agreed. Not run: apps/web specs for Selector, the full suites.

Housekeeping

My phone-pass http.servers inherited the sim lock's fd and survived (the orchestrator killed them after 1h48m): my fault. This round I also found and stopped two vite preview servers of mine still running on macos-01 from an earlier run, by PID. All my Mac and std helpers now start servers with a PID trap; none are left.

## Round 3 (head `eeb0327cd`): batched reads, kept cards, lazy Home tiles — steps 1–3 done, goal NOT reached Commits (one per step, on top of the persistent window): `48394d549` read pass, `ed51926bf` list/inspector cards kept, `eeb0327cd` Home tiles. **1. Read pass.** `packages/ui/src/lib/read-pass.ts`: `readThenWrite(job)` runs every queued job's reads, then every write (frame or same-task microtask). Used by Selector's first placing (one pass for every selector mounted in a flush; the first ResizeObserver report, which only repeats what the mount measured, no longer triggers a second fit+measure+place), and by the tree-section and inline-scroll fades (they each read then wrote in their own rAF, so N sections = N layouts). Safari attribution first (wrapped every layout read, ≥0.15 ms, first 130 ms of a switch, dev build): ≈30 ms/switch of forced reads, but the biggest single read (≈11 ms, a Svelte `bind:clientHeight`) and AppSwitch's `clientWidth` are the *first* reader paying the layout everything else would pay at render anyway, so the batchable part is only the repeated reads: Selector (≈5), fades (≈3.5), Editor (≈1.4). **Shared `packages/ui` change (Selector): `apps/web` uses it too; I did not run the web specs.** **2. List + inspector cards kept mounted** once any app has needed them (inner content only while shown; hidden card is `visibility:hidden`, `inert`, width 0). Mail ↔ Notes no longer creates those glass layers. The main card still differs between Notes (header wrapper + card) and the others, so it is still re-created on Notes ↔ others: keeping both variants mounted would put a hidden `.wc-main`/`.wc-wrap` in the DOM that ~10 specs `querySelector` first. **3. Home:** the first bento of five tiles is there in the first frame (lead, the two beside, the one under, the wide one); the other 7 are added two per idle callback (`requestIdleCallback`, 90 ms timer in Safari). The composer and sidebar are untouched, so typing works from the first frame, and nothing shows empty: the grid just ends where the screen does. ### Frame deltas (real Safari, Mac VM, 1440×900, prod build, same protocol; ABAB ×3, 10 cycles × 4 apps = 120 switches per variant; blank rAF 58.2/s; each row is a separate session, so compare within the row's session) | session | variants (worst-frame median, all apps) | |---|---| | A | base 117 · persistent window 78 · **+read pass 73** · +kept cards 75 | | B | base 104 · +kept cards 76 · **+Home tiles 86** | Per app (median / p90, session A): base notes 130/193 mail 161/389 home 84/154 tasks 64/215; persistent 80/143, 83/178, 75/107, 75/347; +read pass 78/113, 77/186, 64/127, 72/93; +kept cards 77/124, 90/331, 72/138, 74/112. Session B: +kept cards notes 93 mail 86 home 71 tasks 73; +Home tiles notes 88 mail 126 home 64 tasks 78. Read: the read pass is worth about −5 ms; kept cards −0 (no change within noise); Home tiles −7 ms on Home itself (71 → 64) but the same build shows Mail at 126 (86 before), which I read as noise (its p90 swings 215–543 between sessions) rather than an effect of Home code. **I cannot show any of the three steps beating the run-to-run noise except the read pass, and even that is small.** The median worst frame is still ≈ 75 ms, so the stop condition (< 33 ms) is not met; I stopped after step 3 as instructed. ### Where the rest is (for the next round) With all content skipped the switch still costs ≈ 55 ms in Safari, and a first-reader layout of ≈ 20 ms plus ≈ 50 ms of Svelte DOM creation/teardown for the new app's sidebar, page and cards remain. What I think is left, in order: (1) the old app's whole sidebar/page tree is destroyed and the new one built in one task: a keyed, reused sidebar frame (AppSide/Tree rows) would turn creation into updates; (2) `bind:clientHeight`/`ResizeObserver`-driven layout in PaneScroll, AppTree and Composer, which makes layout synchronous at mount; (3) the main card difference between Notes and the other apps. ### Specs Head on dev-02, Chromium + WebKit: `app-switch-shell` (incl. typing right after a switch), `window-layout`, `contacts-float`: **112 passed, 0 failed.** `app-keys:30` left alone as agreed. Not run: `apps/web` specs for Selector, the full suites. ### Housekeeping My phone-pass `http.server`s inherited the sim lock's fd and survived (the orchestrator killed them after 1h48m): my fault. This round I also found and stopped two `vite preview` servers of mine still running on macos-01 from an earlier run, by PID. All my Mac and std helpers now start servers with a PID trap; none are left.
Author
Owner

Plan note: next phase for the app-switch frame (no code, for kayg to decide)

Where we are: worst frame after a switch, real Safari 1440, median over all apps: base ≈ 110 ms → ≈ 75 ms with the persistent window, edge dedupe, read pass, kept cards and lazy Home tiles. Every switch still has a frame > 33 ms. These are the three items that remain, with what I measured and what I'd expect. The expected gains are estimates from my probes, not promises: the run-to-run noise in Safari on the Mac VM is ±10 ms on the median, and some of these overlap.

1. Reuse keyed sidebar and page frames across apps

What: every app's sidebar is its own tree (AppSide / NotesSide / each app's side file) and ends with its own SideDock (avatar, AppSwitch strip, search). Switching destroys the old tree and builds the new one: brand row, body wrapper, the dock (the switcher alone is ≈ 3–4 ms self in Chrome, plus its first-layout read) and the page's scroll frame (PaneScroll). Keep ONE sidebar frame (title row, scroll body, dock) and ONE page frame mounted in the persistent window, and let each app fill only its own rows and page content.
Evidence: Chrome CDP profile after the persistent window: sidebar/dock pieces (AppSwitch 4.3 ms inclusive, Selector 4.5, TreeSection 2.2, InlineScroll 2.1) ≈ 15 of ≈ 45 ms of main-thread work per switch; Safari runs ≈ 1.5–2× Chrome here.
Expected: −10 to −20 ms on every switch.
Cost/risk: the biggest change: 9 sidebars call SideDock themselves, tests for the dock live inside them, phone uses the same components (phone prop), swipes slide the sidebar content (appSwipe). Needs a design pass with the Tasks Float port (Tasks will join the shared window), so I'd do it after that lands.

2. Kill the mount-time bind:clientHeight / ResizeObserver layouts in PaneScroll, AppTree, Composer (and the NotesSide library)

What: these measure their own size at mount (Svelte bind:clientHeight reads in an effect, ResizeObserver callbacks on first observe) to compute padding, fades and strips. The first read forces a full layout inside the mount task (≈ 11 ms in my Safari trace, the single biggest read), and the callbacks write state that triggers a second pass. Replace the measured values with CSS (flex/padding from the known toolbar heights, position: sticky, container query units) so nothing has to be read at mount; keep the observers only for later changes and skip their first report (what I did in Selector).
Expected: −5 to −12 ms. Honest caveat: the browser still lays out once before paint, so only the second, repeated layout is saved; the part I can prove is ≈ 5.
Cost/risk: medium. PaneScroll's measured padding/blur/dock agreement is a design guarantee ("always agree"), so the CSS replacement must keep it pixel-exact: a computed-value table before/after is the gate. Composer is also the Home and AI field, so typing must be re-checked.

3. Unify the Notes and other-app main card

What: Notes draws its page as a header wrapper (.wc-main.wc-wrap) with a card inside (.wc-page); every other app draws a plain .wc-main card. Switching between the two kinds destroys one card (with its glass layer) and creates the other. Make it one card element whose header line is optional, so a switch only changes its content.
Evidence: hiding the cards in a switch (.wcards{display:none}, Safari) took the second frame from ≈ 64 to ≈ 44 ms; the list and inspector are already kept, the main card is the part that is still rebuilt on Notes ↔ other.
Expected: −10 to −20 ms on Notes ↔ others (about half of all switches), ≈ 0 between the other apps.
Cost/risk: ~ten specs read .wc-main / .wc-page / .wc-wrap by class with querySelector (page-toolbar-clear, notes-approve, width-matrix, look-pins, merged-borders, window-layout…): they must be ported to the single card in the same PR. Visual risk is the card's narrow reading width and the header pills, so it needs screenshots at 1440/1180/800, light and dark.

Also found while merging (not in the list, small)

  • Upstream's new standClear (the standalone Ask AI button) runs a MutationObserver over the whole cards area and, in the next frame, a getBoundingClientRect / elementFromPoint pass over every button in the card, on every DOM change, which includes every switch. Expected −3 to −8 ms if it is limited to the first 64 px band and run once per settled frame. Not mine to change in this PR.
  • Home and Tasks pay their own screen init (≈ 15–25 ms each, outside the window): lazy fixtures and the Tasks Float port. Not part of the three items.

What I'd expect in total

Items 1 + 2 + 3 on top of today: ≈ 75 → ≈ 40–50 ms. I do not expect < 33 ms from these three alone; the last stretch needs Home/Tasks init (above) and probably splitting the old app's destruction from the new app's creation. Order I'd suggest: 3 (self-contained, biggest on the common Notes ↔ app switch), then 2, then 1 together with the Tasks port. All three keep the typing-right-after-switch spec and the Safari protocol (120 switches, ABAB) as gates.

## Plan note: next phase for the app-switch frame (no code, for kayg to decide) **Where we are:** worst frame after a switch, real Safari 1440, median over all apps: base ≈ 110 ms → ≈ 75 ms with the persistent window, edge dedupe, read pass, kept cards and lazy Home tiles. Every switch still has a frame > 33 ms. These are the three items that remain, with what I measured and what I'd expect. The expected gains are estimates from my probes, not promises: the run-to-run noise in Safari on the Mac VM is ±10 ms on the median, and some of these overlap. ### 1. Reuse keyed sidebar and page frames across apps *What:* every app's sidebar is its own tree (`AppSide` / `NotesSide` / each app's side file) and ends with its own `SideDock` (avatar, `AppSwitch` strip, search). Switching destroys the old tree and builds the new one: brand row, body wrapper, the dock (the switcher alone is ≈ 3–4 ms self in Chrome, plus its first-layout read) and the page's scroll frame (`PaneScroll`). Keep ONE sidebar frame (title row, scroll body, dock) and ONE page frame mounted in the persistent window, and let each app fill only its own rows and page content. *Evidence:* Chrome CDP profile after the persistent window: sidebar/dock pieces (`AppSwitch` 4.3 ms inclusive, `Selector` 4.5, `TreeSection` 2.2, `InlineScroll` 2.1) ≈ 15 of ≈ 45 ms of main-thread work per switch; Safari runs ≈ 1.5–2× Chrome here. *Expected:* **−10 to −20 ms** on every switch. *Cost/risk:* the biggest change: 9 sidebars call `SideDock` themselves, tests for the dock live inside them, phone uses the same components (`phone` prop), swipes slide the sidebar content (`appSwipe`). Needs a design pass with the Tasks Float port (Tasks will join the shared window), so I'd do it after that lands. ### 2. Kill the mount-time `bind:clientHeight` / ResizeObserver layouts in PaneScroll, AppTree, Composer (and the NotesSide library) *What:* these measure their own size at mount (Svelte `bind:clientHeight` reads in an effect, ResizeObserver callbacks on first observe) to compute padding, fades and strips. The first read forces a full layout inside the mount task (≈ 11 ms in my Safari trace, the single biggest read), and the callbacks write state that triggers a second pass. Replace the measured values with CSS (flex/`padding` from the known toolbar heights, `position: sticky`, container query units) so nothing has to be read at mount; keep the observers only for later changes and skip their first report (what I did in `Selector`). *Expected:* **−5 to −12 ms**. Honest caveat: the browser still lays out once before paint, so only the second, repeated layout is saved; the part I can prove is ≈ 5. *Cost/risk:* medium. PaneScroll's measured padding/blur/dock agreement is a design guarantee ("always agree"), so the CSS replacement must keep it pixel-exact: a computed-value table before/after is the gate. Composer is also the Home and AI field, so typing must be re-checked. ### 3. Unify the Notes and other-app main card *What:* Notes draws its page as a header wrapper (`.wc-main.wc-wrap`) with a card inside (`.wc-page`); every other app draws a plain `.wc-main` card. Switching between the two kinds destroys one card (with its glass layer) and creates the other. Make it one card element whose header line is optional, so a switch only changes its content. *Evidence:* hiding the cards in a switch (`.wcards{display:none}`, Safari) took the second frame from ≈ 64 to ≈ 44 ms; the list and inspector are already kept, the main card is the part that is still rebuilt on Notes ↔ other. *Expected:* **−10 to −20 ms on Notes ↔ others (about half of all switches)**, ≈ 0 between the other apps. *Cost/risk:* ~ten specs read `.wc-main` / `.wc-page` / `.wc-wrap` by class with `querySelector` (page-toolbar-clear, notes-approve, width-matrix, look-pins, merged-borders, window-layout…): they must be ported to the single card in the same PR. Visual risk is the card's narrow reading width and the header pills, so it needs screenshots at 1440/1180/800, light and dark. ### Also found while merging (not in the list, small) - Upstream's new `standClear` (the standalone Ask AI button) runs a MutationObserver over the whole cards area and, in the next frame, a getBoundingClientRect / elementFromPoint pass over every button in the card, on **every** DOM change, which includes every switch. **Expected −3 to −8 ms** if it is limited to the first 64 px band and run once per settled frame. Not mine to change in this PR. - Home and Tasks pay their own screen init (≈ 15–25 ms each, outside the window): lazy fixtures and the Tasks Float port. Not part of the three items. ### What I'd expect in total Items 1 + 2 + 3 on top of today: **≈ 75 → ≈ 40–50 ms**. I do not expect < 33 ms from these three alone; the last stretch needs Home/Tasks init (above) and probably splitting the old app's destruction from the new app's creation. Order I'd suggest: 3 (self-contained, biggest on the common Notes ↔ app switch), then 2, then 1 together with the Tasks port. All three keep the typing-right-after-switch spec and the Safari protocol (120 switches, ABAB) as gates.
Author
Owner

Landed in review/calendar-2: head 9eca18792 (fast-forward from 61a858b22), slot calendar-2 redeployed at 9eca1879

Merged origin/review/calendar-2 (the AI toolbar, switcher and flaky-spec fixes) into fix/app-switch-hitch twice (one conflict, in WindowLayout.svelte: kept upstream's standClear standalone AI toolbar and my kept list/inspector cards).

Two changes while landing

  1. Selector change backed out (5acc128c4). origin/dev already batches Selector's mount and frame reads (selector/measure-batch), so my version would have conflicted on the port, and there is nothing left in packages/ui for the web specs to cover except the new read-pass.ts (used only by the mockup's tree-section and inline-scroll fades). I did not run apps/web specs for that reason. The Selector part was ≈ −3 ms of the read-pass step; it comes back when calendar-2 takes dev's version.
  2. Bug found by the swipe specs and fixed (1ecdc98a2): with one persistent window, the swipe's switching flag was cleared by an effect cleanup that re-ran when swipe.dir was reset, so .wl.switching stayed on forever after a swipe. The timer is now its own.

Targeted specs on the merged head (app-switch-shell, window-layout, contacts-float, app-switch, look-pins, chrome-contrast, app-swipe-overlap):

  • dev-02 (aarch64), Chromium + WebKit: 287 passed, 5 failed, all of which also fail or flake on origin/review/calendar-2 without my changes: app-swipe-overlap:70 ×3 (red at base on both projects), look-pins:62 WebKit (red at base), window-layout:288 WebKit (a right-click menu that did not open once: head 1/8, base 0/8, no pattern in the failure).
  • dev-01 (x86) Chromium, chrome-contrast + look-pins + app-switch-shell: 49 passed, 0 failed (the x86 contrast gate).
  • Earlier on the pre-merge head: app-switch swipe/Tasks/AI footer failures were either my stuck-flag bug (fixed) or red at base (the Tasks/AI footer pair; upstream's 61a858b22 fixes their dockOn wait, now merged and green).
  • app-keys:30 left to the flaky-spec lane as agreed; the held-swipe WebKit spec is flaky at base too (head 5/10 vs base 7/10 failing).

Typing-right-after-switch (app-switch-shell) is green on Chromium x86 and aarch64 and on WebKit.

## Landed in `review/calendar-2`: head `9eca18792` (fast-forward from `61a858b22`), slot `calendar-2` redeployed at `9eca1879` Merged `origin/review/calendar-2` (the AI toolbar, switcher and flaky-spec fixes) into `fix/app-switch-hitch` twice (one conflict, in `WindowLayout.svelte`: kept upstream's `standClear` standalone AI toolbar and my kept list/inspector cards). **Two changes while landing** 1. **`Selector` change backed out** (`5acc128c4`). `origin/dev` already batches Selector's mount and frame reads (`selector/measure-batch`), so my version would have conflicted on the port, and there is nothing left in `packages/ui` for the web specs to cover except the new `read-pass.ts` (used only by the mockup's tree-section and inline-scroll fades). I did not run `apps/web` specs for that reason. The Selector part was ≈ −3 ms of the read-pass step; it comes back when calendar-2 takes dev's version. 2. **Bug found by the swipe specs and fixed** (`1ecdc98a2`): with one persistent window, the swipe's `switching` flag was cleared by an effect cleanup that re-ran when `swipe.dir` was reset, so `.wl.switching` stayed on forever after a swipe. The timer is now its own. **Targeted specs on the merged head** (`app-switch-shell`, `window-layout`, `contacts-float`, `app-switch`, `look-pins`, `chrome-contrast`, `app-swipe-overlap`): - dev-02 (aarch64), Chromium + WebKit: **287 passed, 5 failed**, all of which also fail or flake on `origin/review/calendar-2` without my changes: `app-swipe-overlap:70` ×3 (red at base on both projects), `look-pins:62` WebKit (red at base), `window-layout:288` WebKit (a right-click menu that did not open once: head 1/8, base 0/8, no pattern in the failure). - dev-01 (x86) Chromium, `chrome-contrast` + `look-pins` + `app-switch-shell`: **49 passed, 0 failed** (the x86 contrast gate). - Earlier on the pre-merge head: `app-switch` swipe/Tasks/AI footer failures were either my stuck-flag bug (fixed) or red at base (the Tasks/AI footer pair; upstream's `61a858b22` fixes their `dockOn` wait, now merged and green). - `app-keys:30` left to the flaky-spec lane as agreed; the held-swipe WebKit spec is flaky at base too (head 5/10 vs base 7/10 failing). Typing-right-after-switch (`app-switch-shell`) is green on Chromium x86 and aarch64 and on WebKit.
Author
Owner

Next phase started (kayg 11-12): coordination

I'm doing the plan's four items in order on fix/app-switch-hitch, each landed on review/calendar-2 after its own Safari measurement: (1) standClear reads, (2) mount-time bind:clientHeight/ResizeObserver in PaneScroll, AppTree, Composer, (3) one main card for Notes and the other apps, (4) keyed sidebar/page frames.

To the switcher lane (the click-switch fade, opacity only): my protocol compares builds within one session on the same base, so a fade landing in between doesn't pollute my deltas: each step is measured as (head before the step) vs (head with the step), built from the same merge base. Please post your commit on this issue when it lands on calendar-2, and I'll merge it before the next step's baseline instead of mixing it into a measurement. If your fade runs on the first frames after a switch, please keep it on opacity of one element (no filter/backdrop-filter change): a fade over blurred glass would show up as a long frame in my table and I'd have to attribute it to you.

## Next phase started (kayg 11-12): coordination I'm doing the plan's four items in order on `fix/app-switch-hitch`, each landed on `review/calendar-2` after its own Safari measurement: (1) `standClear` reads, (2) mount-time `bind:clientHeight`/ResizeObserver in PaneScroll, AppTree, Composer, (3) one main card for Notes and the other apps, (4) keyed sidebar/page frames. **To the switcher lane (the click-switch fade, opacity only):** my protocol compares builds **within one session on the same base**, so a fade landing in between doesn't pollute my deltas: each step is measured as (head before the step) vs (head with the step), built from the same merge base. Please post your commit on this issue when it lands on calendar-2, and I'll merge it before the next step's baseline instead of mixing it into a measurement. If your fade runs on the first frames after a switch, please keep it on `opacity` of one element (no `filter`/`backdrop-filter` change): a fade over blurred glass would show up as a long frame in my table and I'd have to attribute it to you.
Author
Owner

Next phase (kayg 11-12): result — landed 2405dd402 on review/calendar-2, slot calendar-2 redeployed at 2405dd40; target (< 33 ms) NOT reached, stopped after step 3

Merged with the switcher lane's fade (f3ecb4784) before measuring; the final A/B is 3232345c9 (calendar-2 before me, fade included) vs 2405dd402, same session, real Safari 1440, 6 rounds × 4 apps × 8 cycles = 192 switches per variant.

step what measured (median worst frame) verdict
1 standClear: find the controls in the card's top band first, hit-test only those 60 → 66 (6 paired rounds: 57 vs 60) no change
2 no synchronous height read at mount: dead bind:clientHeight in AppTree and NotesSide removed, PaneScroll and Composer use a ResizeObserver (lib/watch-height) 66 → 69 (rounds, noise ±5) no change; computed values: 391 compared, 0 changed (sidebar, card, toolbar, Composer stage, PaneScroll rows on Mail, Files, Automations)
extra the Shell read --pane-gap with getComputedStyle on every app switch (13 ms of a Notes switch in Chrome): now once per page folded into the final table principled, no isolated gain
3 both forms of the main card (note wrapper+card, plain card) stay mounted; a switch toggles classes (wc-idle carries none of the classes the CSS and specs find the card by, so no spec needed porting) all apps 62 → 60, but arriving at Notes 78/89/87/75 → 68/72/76 (interleaved sessions) ≈ −10 ms kept
4 keyed sidebar and page frames not done: see below

Final table (median / p90 of the worst frame): calendar-2 before 3232345c9 — notes 79/128, mail 60/90, home 51/78, tasks 59/85, all 62/92; after 2405dd402 — notes 76/87, mail 63/72, home 51/65, tasks 55/71, all 60/80. So the median did not move; the slow tail did (p90 92 → 80, Notes 128 → 87). Today's baseline on this Mac (≈ 60 ms) is also lower than the ≈ 75 I reported earlier (that was a busier session); compare only inside one table.

What I tried and backed out: a Selector read pass through dev's measure-batch (no gain: 65 vs 69, and the web e2e can't run on calendar-2 anyway: its server command has no --state, every current binary refuses to start; reverted).

Why I did not do step 4, and what the data says (Chrome CDP profile of arriving at Notes, Safari frame tests by arrival): the cost is in the content of the app being mounted, not in the frame around it: Notes arrival ≈ 80 ms vs Files ≈ 55 and Mail ≈ 60 in the same session; the profile shows NotesSide 13 ms inclusive (tree sections 9, rows 7), Editor 6, Composer 3.4; WindowDock/AppSwitch/SideDock (what a keyed frame would save) are ≈ 4 ms in total. A keyed frame would therefore cut ≈ 4–8 ms for the largest refactor on the list, and each of the four steps above showed that removing a read moves layout to the next reader without removing it. Removing a read only saves time when it is a repeated layout, and none of these were.

What would still move the number (each is per-app content work, not shell work): Notes sidebar rows below the fold built at idle (as Home's tiles are, ≈ −8…−12 ms on Notes), the Editor's first paint of a long note, Home's composer and the Tasks screen init, and the old app's DOM teardown in the same task (≈ 20 ms in the profile; deferring it a frame needs the old tree to stay inert and invisible for a frame). I'd rather do those one at a time with a Safari number each than the keyed frame.

Specs on 2405dd402: dev-02 Chromium + WebKit, 584 passed / 5 failed / 3 skipped (app-switch-shell incl. typing right after a switch, window-layout, contacts-float, app-switch incl. the fade spec, look-pins, chrome-contrast, notes-approve, width-matrix, merged-borders, page-toolbar-clear, backdrop-builder, divider, app-swipe-overlap); the 5 are app-swipe-overlap ×4 and look-pins:62 on WebKit, all red at base earlier. dev-01 x86 Chromium (chrome-contrast, look-pins, app-switch-shell, window-layout): 86 passed, 0 failed.

## Next phase (kayg 11-12): result — landed `2405dd402` on `review/calendar-2`, slot `calendar-2` redeployed at `2405dd40`; target (< 33 ms) NOT reached, stopped after step 3 Merged with the switcher lane's fade (`f3ecb4784`) before measuring; the final A/B is `3232345c9` (calendar-2 before me, fade included) vs `2405dd402`, same session, real Safari 1440, 6 rounds × 4 apps × 8 cycles = 192 switches per variant. | step | what | measured (median worst frame) | verdict | |---|---|---|---| | 1 | `standClear`: find the controls in the card's top band first, hit-test only those | 60 → 66 (6 paired rounds: 57 vs 60) | no change | | 2 | no synchronous height read at mount: dead `bind:clientHeight` in AppTree and NotesSide removed, PaneScroll and Composer use a ResizeObserver (`lib/watch-height`) | 66 → 69 (rounds, noise ±5) | no change; **computed values: 391 compared, 0 changed** (sidebar, card, toolbar, Composer stage, PaneScroll rows on Mail, Files, Automations) | | extra | the Shell read `--pane-gap` with getComputedStyle on every app switch (13 ms of a Notes switch in Chrome): now once per page | folded into the final table | principled, no isolated gain | | 3 | both forms of the main card (note wrapper+card, plain card) stay mounted; a switch toggles classes (`wc-idle` carries none of the classes the CSS and specs find the card by, so **no spec needed porting**) | all apps 62 → 60, but **arriving at Notes 78/89/87/75 → 68/72/76** (interleaved sessions) ≈ −10 ms | kept | | 4 | keyed sidebar and page frames | **not done**: see below | | Final table (median / p90 of the worst frame): calendar-2 before `3232345c9` — notes 79/128, mail 60/90, home 51/78, tasks 59/85, **all 62/92**; after `2405dd402` — notes 76/87, mail 63/72, home 51/65, tasks 55/71, **all 60/80**. So the median did not move; the slow tail did (p90 92 → 80, Notes 128 → 87). Today's baseline on this Mac (≈ 60 ms) is also lower than the ≈ 75 I reported earlier (that was a busier session); compare only inside one table. **What I tried and backed out:** a Selector read pass through dev's `measure-batch` (no gain: 65 vs 69, and the web e2e can't run on calendar-2 anyway: its server command has no `--state`, every current binary refuses to start; reverted). **Why I did not do step 4, and what the data says** (Chrome CDP profile of arriving at Notes, Safari frame tests by arrival): the cost is in the *content* of the app being mounted, not in the frame around it: Notes arrival ≈ 80 ms vs Files ≈ 55 and Mail ≈ 60 in the same session; the profile shows `NotesSide` 13 ms inclusive (tree sections 9, rows 7), `Editor` 6, `Composer` 3.4; `WindowDock`/`AppSwitch`/`SideDock` (what a keyed frame would save) are ≈ 4 ms in total. A keyed frame would therefore cut ≈ 4–8 ms for the largest refactor on the list, and each of the four steps above showed that removing a *read* moves layout to the next reader without removing it. Removing a read only saves time when it is a repeated layout, and none of these were. **What would still move the number** (each is per-app content work, not shell work): Notes sidebar rows below the fold built at idle (as Home's tiles are, ≈ −8…−12 ms on Notes), the Editor's first paint of a long note, Home's composer and the Tasks screen init, and the old app's DOM teardown in the same task (≈ 20 ms in the profile; deferring it a frame needs the old tree to stay inert and invisible for a frame). I'd rather do those one at a time with a Safari number each than the keyed frame. **Specs on `2405dd402`:** dev-02 Chromium + WebKit, 584 passed / 5 failed / 3 skipped (`app-switch-shell` incl. typing right after a switch, `window-layout`, `contacts-float`, `app-switch` incl. the fade spec, `look-pins`, `chrome-contrast`, `notes-approve`, `width-matrix`, `merged-borders`, `page-toolbar-clear`, `backdrop-builder`, `divider`, `app-swipe-overlap`); the 5 are `app-swipe-overlap` ×4 and `look-pins:62` on WebKit, all red at base earlier. dev-01 x86 Chromium (`chrome-contrast`, `look-pins`, `app-switch-shell`, `window-layout`): 86 passed, 0 failed.
Author
Owner

Wrote the app-switch and open-note findings for the port on #1088 (per-step results, what did not help, what will: Notes sidebar rows at idle, the editor's first paint of a long note, persistent tab strip). Deferred teardown of the old app: measured at ≈ 2 ms of ≈ 50 ms per switch in the Chrome profile, so not built (it would keep the old app's content alive and reacting to the new route for no real gain). No mockup code changed in this step; head stays 2405dd402.

Wrote the app-switch and open-note findings for the port on #1088 (per-step results, what did not help, what will: Notes sidebar rows at idle, the editor's first paint of a long note, persistent tab strip). Deferred teardown of the old app: measured at ≈ 2 ms of ≈ 50 ms per switch in the Chrome profile, so not built (it would keep the old app's content alive and reacting to the new route for no real gain). No mockup code changed in this step; head stays `2405dd402`.
Author
Owner

Root cause of "typing right after a switch" losing/reordering keys (WebKit) — fixed in 60cf14504 on review/calendar-2

Symptom (app-switch-shell.spec.ts:49, calendar-2 2405dd402): typing "quick brown fox" right after a switch gave quck brown foxi, quick brown oxf, qk brown foxciu: characters lost and re-inserted late, at the end.

Cause (mine). My two "keep it mounted" changes (the dual main-card forms, wc-idle, and the kept list card) toggled inert + aria-hidden on the card the page is switching away from and to. The glass map build in behind-glass lifts every [inert] node for its whole length (chunks over several tasks) and, in 2405dd402, put inert = true back blindly at its end. The build the page starts about 600 ms after load can straddle the switch: it had captured the idle Files-form card as inert; the switch made that card live (Svelte removed its inert); at the end of the build the blind restore set inert = true on the card that now held the focused field. An element under an inert ancestor loses focus and takes no key events, so the next keys went to the document (Files' type-to-filter then routed them back into the field late, at the end): lost and reordered characters. It needed the build to end in the few-hundred-ms window of the typing, hence ~10 % of WebKit runs and 0 on a quiet re-run.

Interaction with the contrast lane. f76538528 ("a map build puts inert back as its owner last asked", in calendar-2 since 566966709's parent chain) fixes the blind restore, and with it calendar-2 head passed the spec 70/70 on WebKit before my change. I did not rely on that: the real error was giving cards that are already unreachable (display: none / visibility: hidden) an inert that the page flips on a switch.

Fix. The idle form of the main card and the idle list card carry no inert/aria-hidden any more (display: none and visibility: hidden already remove them from focus order and the accessibility tree; the inspector and AI area, which genuinely slide away and keep inert, are untouched). Then keys cannot land in a card the lift/restore can freeze, whatever the lease does.

Evidence

  • 2405dd402 (before): WebKit x86 --repeat-each=40: 4 failed (oxf, rown foxb, qk brown foxciu, …).
  • 2405dd402 + only this change: WebKit x86 --repeat-each=60: 60 passed (so the change alone is sufficient).
  • Head 60cf14504, spec ×20 on WebKit and Chromium: dev-01 (x86) 40 passed, dev-02 (aarch64) 40 passed; earlier on 566966709 (lease only) ×20 per browser on dev-02 and ×20 per browser on x86 and ×30 under load 40 (WebKit): all passed.
  • Wider sweep on dev-02 Chromium + WebKit (app-switch-shell, window-layout, contacts-float, app-switch, look-pins, behind-inert, notes-approve, width-matrix, glass-shared): 385 passed, 1 failed (look-pins:62 WebKit, red at base).
  • Slot calendar-2 redeployed.

For the port (#1088): never put inert on the form of a card that a route change flips between; use display: none / visibility: hidden for a form that is not in use, and keep inert only for things that stay visible but must not take input (a sliding panel). Any code that lifts and restores inert (the glass map) must restore what the owner last asked, as liftInert now does.

## Root cause of "typing right after a switch" losing/reordering keys (WebKit) — fixed in `60cf14504` on `review/calendar-2` **Symptom** (`app-switch-shell.spec.ts:49`, calendar-2 `2405dd402`): typing "quick brown fox" right after a switch gave `quck brown foxi`, `quick brown oxf`, `qk brown foxciu`: characters lost and re-inserted late, at the end. **Cause (mine).** My two "keep it mounted" changes (the dual main-card forms, `wc-idle`, and the kept list card) toggled `inert` + `aria-hidden` on the card the page is switching *away from* and *to*. The glass map build in `behind-glass` lifts every `[inert]` node for its whole length (chunks over several tasks) and, in `2405dd402`, put `inert = true` back **blindly** at its end. The build the page starts about 600 ms after load can straddle the switch: it had captured the idle Files-form card as inert; the switch made that card live (Svelte removed its `inert`); at the end of the build the blind restore set `inert = true` on the card that now held the focused field. An element under an inert ancestor loses focus and takes no key events, so the next keys went to the document (Files' type-to-filter then routed them back into the field late, at the end): lost and reordered characters. It needed the build to end in the few-hundred-ms window of the typing, hence ~10 % of WebKit runs and 0 on a quiet re-run. **Interaction with the contrast lane.** `f76538528` ("a map build puts inert back as its owner last asked", in calendar-2 since 566966709's parent chain) fixes the *blind restore*, and with it calendar-2 head passed the spec 70/70 on WebKit before my change. I did not rely on that: the real error was giving cards that are already unreachable (`display: none` / `visibility: hidden`) an `inert` that the page flips on a switch. **Fix.** The idle form of the main card and the idle list card carry no `inert`/`aria-hidden` any more (`display: none` and `visibility: hidden` already remove them from focus order and the accessibility tree; the inspector and AI area, which genuinely slide away and keep `inert`, are untouched). Then keys cannot land in a card the lift/restore can freeze, whatever the lease does. **Evidence** - `2405dd402` (before): WebKit x86 `--repeat-each=40`: **4 failed** (`oxf`, `rown foxb`, `qk brown foxciu`, …). - `2405dd402` + only this change: WebKit x86 `--repeat-each=60`: **60 passed** (so the change alone is sufficient). - Head `60cf14504`, spec ×20 on **WebKit and Chromium**: dev-01 (x86) **40 passed**, dev-02 (aarch64) **40 passed**; earlier on `566966709` (lease only) ×20 per browser on dev-02 and ×20 per browser on x86 and ×30 under load 40 (WebKit): all passed. - Wider sweep on dev-02 Chromium + WebKit (`app-switch-shell`, `window-layout`, `contacts-float`, `app-switch`, `look-pins`, `behind-inert`, `notes-approve`, `width-matrix`, `glass-shared`): **385 passed, 1 failed** (`look-pins:62` WebKit, red at base). - Slot `calendar-2` redeployed. **For the port (#1088):** never put `inert` on the form of a card that a route change flips between; use `display: none` / `visibility: hidden` for a form that is not in use, and keep `inert` only for things that stay visible but must not take input (a sliding panel). Any code that lifts and restores `inert` (the glass map) must restore what the owner last asked, as `liftInert` now does.
Sign in to join this conversation.
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#1085
No description provided.