App switch frame hitch (57–147 ms) in Safari #1085
Open
opened 2026-11-11 21:20:35 +00:00 by kayg
·
10 comments
No Branch/Tag specified
main
port/tasks-float-2
fix/train-1116-2
fix/train-1116-3
fix/train-1116-1
fix/flake-1134
fix/server-1182
dev
port/notes-float-3c
docs/auto-update-ig
feat/dav-transport
port/tasks-float-1
wip/mail1011-sv-order-1116
fix/flake-1179
fix/flake-1178
fix/guards-1153-fsio-split
fix/guards-1153-notes-split-we
fix/guards-1153-notes-lib
fix/guards-1153-notes-home
fix/guards-1153-ui-primitives
fix/guards-1153-primitives-e2e
fix/guards-1153-visibility-doc
feat/paper-grey-1116
fix/flake-1165
fix/flake-1119
docs/imap-766-plan-v2
fix/e2e-unique-ports
t3/paged-search-reconcile-final
wip/mail1011-final-1115
docs/tasks-float-port
perf/editor-first-paint-1c
feat/imap-notes-fetch
feat/imap-notes-projection
feat/imap-notes-readonly
feat/imap-notes-auth
feat/imap-notes-server-foundation
wip/mail1011-txn-ownvocab-1115
wip/mail1011-txn-novocab-1115
perf/p1117-final-harness
perf/single-shot-repeats
port/tasks-matrix
wip/mail1011-txn-1115
fix/static-gates-1155
feat/files-s1-identity-r7
fix/files-r7-idle-loop
fix/daily-train-1152
port/notes-float
fix/editor-tables-test-types
port/notes-float-listscript
feat/tasks-actions
port/notes-float-phone-preload
perf/sound-comparator
port/notes-float-listscroll
port/notes-float-budgets
port/notes-float-suite-fix-b
port/notes-float-sidebar-fix
port/notes-float-trim
port/notes-float-3-lists
fix/attachments-meta-capability
docs/carddav-writes-v2-plan
feat/contacts-companion-pure
issue/carddav-read-perf-fix-r2
issue/carddav-read-r2
port/notes-float-devsync2
review/calendar-2
review/switcher-a-pills
port/notes-float-switcher-a
port/port-tables-2
review/switcher-ends
wip/whiteboard-s1-1114
port/port-tables
wip/mail1011-perfneutral
review/photo-tint
port/notes-float-shell
wip/local/collections-db
wip/local/mail-p1
wip/local/cold-growth-on-tiering
wip/local/tiering-v3-s1
wip/local/wal1051-cap
wip/local/tiering-v3-s1-resume
wip/local/index-position-startup-scan
port/notes-float-flat
port/notes-float-promote
wip/handover/mail1011-candidate
wip/handover/files-s1-candidate
port/notes-float-shell-only
port/notes-float-perf
feat/whiteboard-s1
feat/tiering-v5
fix/app-switch-hitch
wip/local/files-s1-dev-v4-final
feat/files-s1-dev-v4
fix/c2-glass-shared
feat/flat-lists
wip/handover/whiteboard-s1-resume
wip/att-lazy-861
feat/switcher-browse
wip/att-lazy-860
feat/tasks-float
recovered/flat-backup-candidate
perf/stalls-1054-kc
land/ai-toolbar
feat/collections-db
feat/collections-db-fixes
codex/mail-1011-redesign-20261111
fix/ai-toolbar
backup/macos-vm/st3-head
perf/trim-candidate-phonestack
feat/switcher-three
fix/1051-index-idle-checkpoint
perf/stalls-1054-kb
perf/stalls-1054-k
perf/stalls-1054-r3
fix/c2-contrast-tail
perf/stalls-1054-r3-preview
feat/collections-before
feat/tiering-v4
fix/timelog-caret
wip/local/tasks-actions
docs/tasks-writes-v2-plan
st3-r3
feat/pass8
review/calendar-2-before-1111
wip/tiering-v3-cold4
perf/stalls-1054-r2
fix/suite-A4
fix/suite-A5-probe
fix/suite-A6
fix/suite-A3
fix/suite-A2
fix/suite-A5
fix/suite-A1
wip/local/attachments-861-fix
feat/contrast
wip/local/ports-861
storage/wal-checkpoint-off-save-1051
wip/local/mail-1011-reconcile-20261110
feat/style-sheet-fixes
feat/money-round
perf/stalls-1054
wip/tiering-v3-cold5
t3/mail-1011-liveness
feat/iphone-fixes
feat/notes-approve
wip/local/shrow-work
feat/files-s1-identity
feat/quickfix
wip/tiering-v3-cold
wip/local/shared-row-swipes
backup/macos-vm/pfx-B
backup/macos-vm/pfx-C
backup/macos-vm/pfx-D
feat/contrast-r1
feat/tiering-v3-s2-tags
feat/folder-drop
t3/photos-s1
feat/tiering-v3-s1-namespace
wip/local/photos-s1
t3/photos-plan-slice-one
recovered/backup/p1b-61505
t3/paged-search-reconcile
t3/smooth-pane-transitions
t3/index-position-startup-scan
fix/private-staging-759b-r2
backup/macos-vm/hk/hk1009/pr877
backup/macos-vm/hk/hk1009/pr878
docs/undo-block-ids-plan
fix/undo-768
backup/macos-vm/hk/hk1009/pr875
backup/macos-vm/hk/hk1009/pr904
proto/block-identity-v7d
backup/macos-vm/hk/hk1009/pr846
backup/macos-vm/hk/hk1009/pr860
backup/macos-vm/hk/hk1009/pr861
backup/macos-vm/hk/hk1009/pr849
backup/macos-vm/hk/hk1009/pr848
backup/macos-vm/hk/hk1009/pr853
backup/macos-vm/hk/hk1009/pr957
backup/macos-vm/hk/hk1009/pr893
backup/macos-vm/hk/hk1009/pr889
backup/macos-vm/hk/hk1009/pr902
docs/imap-notes-plan
docs/quota-plan-2
fix/parallel-test-flakes
docs/calendar-backend-v2-plan
feat/calendar-ical-converter
backup/macos-vm/hk/hk1009/pr808
docs/contacts-import-v2-plan
issue/610-pm-midnight
feat/calendar-v2-s1-containment
backup/macos-vm/hk/hk1009/pr854
backup/macos-vm/hk/hk1009/pr845
backup/macos-vm/hk/hk1009/pr917
docs/dav-recorder-v2-plan
plan/previews-865
plan/save-log-durable-entry
backup/macos-vm/hk/hk1009/pr934
fix/e2e-data-on-ram
backup/macos-vm/hk/hk1009/pr888
feat/appwindow3
feat/appwindow2
feat/appwindow
feat/money-p1
feat/keys-sheet
review/calendar-2-themes
feat/smooth-cursor
fix/float-style
review/calendar-2-float
release/2026-11-06-hotfix
archive/port/rows-drop-code
archive/port/rows-actions
archive/port/rows
scratch/tasks-894-ui-gates
review/calendar-2-night-wip
recovered/flaky/toast-reduced
release/2026-11-05
archive/flaky/rows-drop-fixed
archive/flaky/rows-actions
archive/flaky/rows
sim/bm15-final
sim/bm15-bis-932
sim/bm15-bis-909
sim/bm15
sim/bm15-bis-887
perf/tiering-option-b
fix/sw-lazy-precache
archive/plan/save-log-durable-entry
mock/money-fix2
archive/fix/e2e-data-on-ram
mock/appearance-all
mock/pill-press
mock/pill-press-mac
backup/macos-vm/appearance-after
mock/auto-swipes
mock/mail-actions
backup/macos-vm/mock/mail-actions
mock/money-static
archive/review/standards-917
perf/tiering-761-fix
mock/type-audit
mock/third-pane
feat/contacts-import-v2-s1
perf/executor-hot-path
archive/port/hidden-blocks
archive/port/devices
scratch/executor-on-894
scratch/executor-spans2
scratch/executor-spans
archive/port/rows-drop
feat/tiering-761-d-scale
feat/tiering-761-c-index
feat/tiering-761-b-reader
archive/review/sharing-pr3-review-9fec3d1f
perf/ports-lazy-budgets
feat/tiering-761-a-migration
archive/review/sharing-pr3-review
archive/review/sharing-pr3-review-code
archive/plan/previews-865
archive/port/port-attachments-3
archive/port/contacts-merge
fix/motion-audit-859
fix/motion-audit-859-mac
archive/port/port-pickers
archive/port/port-tables-2
archive/port/port-tables
recovered/local/sharing-s1-pr2-room-snapshot-candidate
archive/fix/parallel-test-flakes-code-minipc01
docs/imap-766-readonly-slice
feat/dav-recorder-v3
research/788-diagnosis
archive/fix/parallel-test-flakes
archive/perf/pr792-cold-index-edit
docs/sharing-slice-1
recovered/feat/dav-recorder-v2
recovered/feat/dav-recorder-v2-edd7bbb
spike/imap-766-s0-cases
archive/fix/undo-768
recovered/feat/dav-recorder
recovered/feat/dav-recorder-901acd4
feat/contacts-import
perf/cold-growth-on-764
perf/cold-growth-on-tiering
recovered/feat/tasks-set-status
feat/tasks-move-reorder
feat/tasks-delete-promote-duplicate
feat/carddav-writes
perf/quota-on-tiering
perf/quota-simple
perf/cold-growth-on-quota-stack
recovered/perf/cold-growth-on-tiering
feat/calendar-identity
feat/calendar-event-parser
feat/calendar-props-maps
port/glass-when-ring
recovered/feat/tiering-761-s1-wip-8132a84
recovered/feat/tiering-761-s1-wip-9da4094
recovered/feat/tiering-761-s1-wip-724512c
recovered/feat/tiering-761-s1-wip-66e667e
recovered/feat/tiering-761-s1
wip/6by32-01-tier-761-s1-pause-20261030
spike/imap-766-s0
wip/6by32-02-calternal-pause-20261030
wip/8by64-01-review-688-pause-20261030
wip/6by32-01-verify-744-pause-20261030
wip/6by32-01-verify-742-pause-20261030
fix/private-staging-759b
wip/6by32-01-review-748-pause-20261030
wip/6by32-01-review-733c-pause-20261030
wip/6by32-01-review-733b-pause-20261030
review/calendar-month
wip/local/bm15-trash
plan/759b-staging
review/767b-tests
review/preview-2026-10-29
docs/tiering-731-plan
wip/c6b02-review-733d
wip/c6b02-bm1-full-a
docs/deploy-plan
fix/storage-owner-liveness-642
fix/storage-fix-7
feat/tiering-731
wip/tiering-731-first-attempt
perf/idle-honest-2
fix/storage-private-tmp-642-dev
fix/storage-exact-file-quarantine-642
perf/one-flush-save
review/calendar-static
review/indexing-ring
review/when-field-2
proto/block-identity-2-review
proto/block-identity-review
review/when-field
issue/tasks-create-ids
issue/tasks-create
review/combined
review/task-polish
review/top-buttons
review/q1-q5
archive/integ325-293
archive/integ325-ci
issue/calendar-adr
archive/old/train/2026-10-23bk2
archive/old/train/2026-10-23bk
issue/469-mockup-9a
issue/smart-tasks-mockup
issue/469-menus
issue/652-signout-flake
issue/652-history-fix7
issue/652-history-fix6
archive/old/issue/spring-check-perf
issue/spring-check-perf
issue/659-rename-fast
archive/old/train/2026-10-21ar
issue/search-hardening-3
issue/652-history-fix5
issue/660-port-sheets-glass
issue/652-history-fix4
issue/652-history-fix3
issue/652-history-fix2
issue/652-history-flake
train/2026-10-21an
issue/settings-admin-port
issue/search-port
train/2026-10-20am
issue/storage-split-fix2
issue/storage-split
archive/old/issue/folder-ids-fix
train/2026-10-20al
archive/old/issue/folder-ids
train/2026-10-20ak
issue/tables-mockup
train/2026-10-19aj
train/2026-10-19ai
issue/469-merge-fixes
issue/sidebar-band
archive/old/issue/608-settings-spec
train/2026-10-19ah
issue/swipe-offscreen
train/2026-10-19ag
archive/old/issue/590-nlp-adr
archive/old/issue/587-event-after-write-2
train/2026-10-19af
archive/old/issue/587-event-after-write
issue/469-pill-room-c
issue/469-pill-room
train/2026-10-19ae
issue/469-narrow-handle
issue/397-ios-swipe-2
issue/469-desk-fixes
archive/old/issue/auto-update-adr
issue/469-filter-gap
issue/469-port-1b
issue/442-opacity-flake
issue/327-web-fast-3
archive/old/issue/469-port-1
issue/469-port-1
issue/327-web-fast-2
archive/old/issue/327-web-fast
archive/old/issue/425-stt-bench-vq1
archive/old/issue/445-no-bleed
archive/old/issue/400-swipe-mockup-2
issue/426-client-review
issue/426-client-2
issue/426-client
archive/old/issue/476-safe-area-lab
archive/old/issue/445-top-light
issue/471-blocks-mockup
archive/old/issue/448-links-app-2
archive/old/issue/448-links-app
archive/old/issue/398-cold-links
issue/434-442-small-2
issue/434-442-small
archive/old/issue/398-unload
archive/old/issue/445-bottom-band
issue/445-bottom-band
issue/351-rem-3
issue/351-rem-2
issue/351-rem
archive/old/issue/327-first-note
issue/395-width-phone
archive/old/issue/327-typing
issue/396-ios-edges
issue/397-ios-swipe
archive/old/issue/327-notes-index
issue/345-347-contrast-empty-2
archive/old/issue/44-arenas
issue/44-arenas
archive/integ325
archive/old/issue/327-perf-harness
archive/old/issue/44-thp
issue/44-thp
archive/old/issue/285-sticky-pills
archive/old/issue/44-trim-3
issue/44-trim-3
archive/old/issue/165-cards
archive/old/issue/165-picker-2
archive/old/issue/212-multi-select
No results found.
Labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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(offreview/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 fromArtStack's publish effect and its cleanup, in both backdrops (the sharp window picture and the app's own). Cleanup cleared--edge-baseand resynced, then the twin mounted, wrote it again and resynced: four whole-document restyles inside one task.data-winremoved and set again (WindowLayout's effect cleanup then its twin's effect), and--toast-xremoved and written again: each a restyle of the whole document.Fix (3 parts)
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 nosyncEdges(). ArtStack/Backdrop also skip a re-sync when the edge/sky is unchanged.visibility: hidden(no half-built card on screen, no loading state, no animation added).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 rootdata-win/--toast-x/--edge-base/--wl-mic-rclear-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):
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)
route, so hidden screens would react to other apps' routes.Selector.sveltemeasuresoffsetLeftper instance at mount; shared package, so left alone).Not done / limits
PhoneStack(not WindowLayout); only the ArtStack/Backdrop edge dedupe applies there. Heap with 3 apps warm: n/a, nothing is kept mounted.Head
9505a3b48(branchfix/app-switch-hitch, 8 commits offorigin/review/calendar-20c8d96818) — gates and the rest of the evidenceComputed 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.htmlloads): 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):
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, commit9505a3b48; not yet re-run on WebKit after the rewrite).app-switch,app-keys,app-swipe-overlap,app-tabsonorigin/review/calendar-2(base) fail already: Chromium 7 (app-swipe-overlap×2,app-switch"at rest" and the nine-width "raised row" set,:2171 of 3) and WebKit 7. On head, with--repeat-each=3single worker (Chromium):app-swipe-overlap:903/3 pass,app-switch:1522/2 pass,app-keys:302/3 pass, 1 fail (base 3/3),app-switch:2170/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. Treatapp-keys:30andapp-switch:217as open: if they reproduce on a quiet VM they block, and the fix would be to wait for.wcards.stagingto go in those specs or to stage fewer frames.Open risks / what I could not do
PhoneStack).Coordination (flaky-spec lane, review/calendar-2
ad95f9b54): I checkedfix/app-switch-hitchagainst0c8d96818: it adds onlytests/app-switch-shell.spec.tsand does not touchapp-keys.spec.tsorapp-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.switchinggone, 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 onreview/calendar-2first.Round 2: persistent window (head
fd0330536) — goal still NOT reachedDone as asked, on top of
9505a3b48: oneWindowLayoutkept mounted byWindowHost(App.svelte); an app's Shell rendersWindowSlot, 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,.glglobal layer, sharp.wbgbackdrop, 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 (jumpturns 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)
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 (commitfd0330536). Staging the page itself is what bought round 1 its gain, and that is exactly what can't be allowed (keys lost).Specs
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 rootdata-win/--toast-x/--edge-base/--wl-mic-rclear-and-rewrite; Tasks leaves and returns; rapid back-and-forth ends on the last app with one window.--repeat-each=10, head vsorigin/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.app-switchspecs ("at rest", the nine-width "raised row") fail on base too (the dots were replaced by AppSwitch).iPhone sim (std, my own iPhone 18 Pro iOS 27 sim, deleted after;
PhoneStackpath)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
edgeHolderdedupe.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 3 (head
eeb0327cd): batched reads, kept cards, lazy Home tiles — steps 1–3 done, goal NOT reachedCommits (one per step, on top of the persistent window):
48394d549read pass,ed51926bflist/inspector cards kept,eeb0327cdHome 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 Sveltebind:clientHeight) and AppSwitch'sclientWidthare 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). Sharedpackages/uichange (Selector):apps/webuses 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-wrapin the DOM that ~10 specsquerySelectorfirst.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)
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:30left alone as agreed. Not run:apps/webspecs 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 twovite previewservers 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.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 ownSideDock(avatar,AppSwitchstrip, 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 (
AppSwitch4.3 ms inclusive,Selector4.5,TreeSection2.2,InlineScroll2.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
SideDockthemselves, tests for the dock live inside them, phone uses the same components (phoneprop), 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:clientHeightreads 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/paddingfrom 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 inSelector).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-maincard. 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-wrapby class withquerySelector(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)
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.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.
Landed in
review/calendar-2: head9eca18792(fast-forward from61a858b22), slotcalendar-2redeployed at9eca1879Merged
origin/review/calendar-2(the AI toolbar, switcher and flaky-spec fixes) intofix/app-switch-hitchtwice (one conflict, inWindowLayout.svelte: kept upstream'sstandClearstandalone AI toolbar and my kept list/inspector cards).Two changes while landing
Selectorchange backed out (5acc128c4).origin/devalready batches Selector's mount and frame reads (selector/measure-batch), so my version would have conflicted on the port, and there is nothing left inpackages/uifor the web specs to cover except the newread-pass.ts(used only by the mockup's tree-section and inline-scroll fades). I did not runapps/webspecs for that reason. The Selector part was ≈ −3 ms of the read-pass step; it comes back when calendar-2 takes dev's version.1ecdc98a2): with one persistent window, the swipe'sswitchingflag was cleared by an effect cleanup that re-ran whenswipe.dirwas reset, so.wl.switchingstayed 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):origin/review/calendar-2without my changes:app-swipe-overlap:70×3 (red at base on both projects),look-pins:62WebKit (red at base),window-layout:288WebKit (a right-click menu that did not open once: head 1/8, base 0/8, no pattern in the failure).chrome-contrast+look-pins+app-switch-shell: 49 passed, 0 failed (the x86 contrast gate).app-switchswipe/Tasks/AI footer failures were either my stuck-flag bug (fixed) or red at base (the Tasks/AI footer pair; upstream's61a858b22fixes theirdockOnwait, now merged and green).app-keys:30left 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.Next phase started (kayg 11-12): coordination
I'm doing the plan's four items in order on
fix/app-switch-hitch, each landed onreview/calendar-2after its own Safari measurement: (1)standClearreads, (2) mount-timebind: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
opacityof one element (nofilter/backdrop-filterchange): 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 (kayg 11-12): result — landed
2405dd402onreview/calendar-2, slotcalendar-2redeployed at2405dd40; target (< 33 ms) NOT reached, stopped after step 3Merged with the switcher lane's fade (
f3ecb4784) before measuring; the final A/B is3232345c9(calendar-2 before me, fade included) vs2405dd402, same session, real Safari 1440, 6 rounds × 4 apps × 8 cycles = 192 switches per variant.standClear: find the controls in the card's top band first, hit-test only thosebind:clientHeightin AppTree and NotesSide removed, PaneScroll and Composer use a ResizeObserver (lib/watch-height)--pane-gapwith getComputedStyle on every app switch (13 ms of a Notes switch in Chrome): now once per pagewc-idlecarries none of the classes the CSS and specs find the card by, so no spec needed porting)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; after2405dd402— 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
NotesSide13 ms inclusive (tree sections 9, rows 7),Editor6,Composer3.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-shellincl. typing right after a switch,window-layout,contacts-float,app-switchincl. the fade spec,look-pins,chrome-contrast,notes-approve,width-matrix,merged-borders,page-toolbar-clear,backdrop-builder,divider,app-swipe-overlap); the 5 areapp-swipe-overlap×4 andlook-pins:62on WebKit, all red at base earlier. dev-01 x86 Chromium (chrome-contrast,look-pins,app-switch-shell,window-layout): 86 passed, 0 failed.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.Root cause of "typing right after a switch" losing/reordering keys (WebKit) — fixed in
60cf14504onreview/calendar-2Symptom (
app-switch-shell.spec.ts:49, calendar-22405dd402): typing "quick brown fox" right after a switch gavequck 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) toggledinert+aria-hiddenon the card the page is switching away from and to. The glass map build inbehind-glasslifts every[inert]node for its whole length (chunks over several tasks) and, in2405dd402, putinert = trueback 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 itsinert); at the end of the build the blind restore setinert = trueon 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) aninertthat the page flips on a switch.Fix. The idle form of the main card and the idle list card carry no
inert/aria-hiddenany more (display: noneandvisibility: hiddenalready remove them from focus order and the accessibility tree; the inspector and AI area, which genuinely slide away and keepinert, 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).60cf14504, spec ×20 on WebKit and Chromium: dev-01 (x86) 40 passed, dev-02 (aarch64) 40 passed; earlier on566966709(lease only) ×20 per browser on dev-02 and ×20 per browser on x86 and ×30 under load 40 (WebKit): all passed.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:62WebKit, red at base).calendar-2redeployed.For the port (#1088): never put
inerton the form of a card that a route change flips between; usedisplay: none/visibility: hiddenfor a form that is not in use, and keepinertonly for things that stay visible but must not take input (a sliding panel). Any code that lifts and restoresinert(the glass map) must restore what the owner last asked, asliftInertnow does.