You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I profiled this on an optimized build of main at a19b3ed (macOS 26, Chrome 152 headless, a 189-thread data dir snapshot) and in the trace attached above. The time is not network or server work; it is forced synchronous layout on the main thread during the switch.
Observed
Per switch, measured with a long-animation-frame observer and wrapped layout-read getters:
Case
Blocking time
Of which forced style/layout
Warm revisit of an already opened thread
700 to 850 ms
580 to 710 ms
Cold open
340 to 480 ms
230 to 320 ms
The attached Trace-20260925T223104.json.gz shows the same shape on a different machine: 965 ms of forced layout across the trace, nine main-thread tasks between 505 and 927 ms, and the top forcing callers are the timeline expandable-panel height effect (44 forced layouts, 152 ms), the secondary panel (8 forced layouts, 445 ms) and one markdown-preview measurement (202 ms).
Causes I could confirm in code
TimelineWindowedItems renders every row un-windowed on its first commits after a switch. TanStack's range is null until the scroll rect is measured, and on a keyed remount the scroll-root ref is not attached yet when the child's layout effect runs, so it flips to the fallback:
. Each such commit forces a full layout of the whole timeline (110 to 120 ms each on my machine, three times per switch).
ExpandablePanel reads offsetHeight and writes style.height in a layout effect that runs on mount and whenever its parent re-renders, because the effect depends on renderedBody and collapsedContent identity:
bborn/bb perf/thread-switch-layout-thrash (bborn#1): seed the virtualizer with the last usable scroll-root height, keep windowing on while the ref is pending, retain measurements per thread, and only force a panel read on toggles. Same measurement after: warm revisits 200 to 240 ms blocking (107 to 130 ms forced), cold opens 230 to 250 ms (97 to 157 ms forced). Existing timeline windowing, disclosure and scroll-body tests pass (797 tests across those directories). I have not touched the secondary panel or markdown-preview callers visible in the trace.
Ruled out
Not the server: the timeline request for these threads answers in 25 to 90 ms on loopback; it is not on the critical path of the warm case at all.
NOT REPRODUCED in an optimized isolated timeline-component fixture, repeated by the same agent in two clean checkouts at the same main SHA (66 samples, 100/1,000/5,000 simple rows). All click-to-third-frame samples were below 50 ms. This is not a full-app switch measurement or an ALREADY FIXED claim: rich messages, markdown/secondary panes and the original 2–9s application delay remain unresolved. Current main includes the limited changes from #4537.
🤖 AGENT GENERATED: Claude analysed a DevTools trace from my machine; I reviewed it before posting.
Reproduced on Linux desktop 0.48.1 (e003e95, Chrome 152), so after #4537.
In a 20 s recording I switched threads 7 times. Each switch blocked the renderer for roughly 0.5 to 1 s, almost all of it forced style/layout. The server answered the timeline request in 1 to 3 ms, so the time is client-side.
The biggest forcing callers per switch were the scroll keeper's connect/apply reading scrollTop, the TimelineWindowedItems viewport measurement, ProseMirror in the composer re-applying attributes, and useOverflowMeasurement reading scrollWidth. Each forced restyle took 20 to 40 ms.
DevTools was open, so absolute numbers are inflated. I can't attach the trace because it contains private conversations, but I can capture another if that's useful.
Activity
jyc commentedon Sep 26, 2026
Committing a bunch of untracked files might have helped? I feel like I ran into this once before
bborn commentedon Sep 27, 2026
I profiled this on an optimized build of
mainat a19b3ed (macOS 26, Chrome 152 headless, a 189-thread data dir snapshot) and in the trace attached above. The time is not network or server work; it is forced synchronous layout on the main thread during the switch.Observed
Per switch, measured with a
long-animation-frameobserver and wrapped layout-read getters:The attached
Trace-20260925T223104.json.gzshows the same shape on a different machine: 965 ms of forced layout across the trace, nine main-thread tasks between 505 and 927 ms, and the top forcing callers are the timeline expandable-panel height effect (44 forced layouts, 152 ms), the secondary panel (8 forced layouts, 445 ms) and one markdown-preview measurement (202 ms).Causes I could confirm in code
TimelineWindowedItemsrenders every row un-windowed on its first commits after a switch. TanStack'srangeisnulluntil the scroll rect is measured, and on a keyed remount the scroll-root ref is not attached yet when the child's layout effect runs, so it flips to the fallback:bb/apps/app/src/components/thread/timeline/TimelineWindowedItems.tsx
Line 176 in a19b3ed
bb/apps/app/src/components/thread/timeline/TimelineWindowedItems.tsx
Lines 225 to 228 in a19b3ed
ExpandablePanelreadsoffsetHeightand writesstyle.heightin a layout effect that runs on mount and whenever its parent re-renders, because the effect depends onrenderedBodyandcollapsedContentidentity:bb/apps/app/src/components/ui/disclosure.tsx
Lines 186 to 196 in a19b3ed
Map(bb/apps/app/src/components/thread/timeline/ThreadTimelineRows.tsx
Line 1919 in a19b3ed
Prototype
bborn/bb
perf/thread-switch-layout-thrash(bborn#1): seed the virtualizer with the last usable scroll-root height, keep windowing on while the ref is pending, retain measurements per thread, and only force a panel read on toggles. Same measurement after: warm revisits 200 to 240 ms blocking (107 to 130 ms forced), cold opens 230 to 250 ms (97 to 157 ms forced). Existing timeline windowing, disclosure and scroll-body tests pass (797 tests across those directories). I have not touched the secondary panel or markdown-preview callers visible in the trace.Ruled out
--worktreeor dev server: measured on the optimized bundle served by the production server.I can split the prototype into a PR against this issue once approved per CONTRIBUTING.
Avoid full-history layout during thread switches (#4537)
SawyerHood commentedon Sep 30, 2026
Verified scoped report: https://get-bb.github.io/reports/issues/4396.html
NOT REPRODUCED in an optimized isolated timeline-component fixture, repeated by the same agent in two clean checkouts at the same main SHA (66 samples, 100/1,000/5,000 simple rows). All click-to-third-frame samples were below 50 ms. This is not a full-app switch measurement or an ALREADY FIXED claim: rich messages, markdown/secondary panes and the original 2–9s application delay remain unresolved. Current main includes the limited changes from #4537.
wy3z commentedon Nov 3, 2026
Note
🤖 AGENT GENERATED: Claude analysed a DevTools trace from my machine; I reviewed it before posting.
Reproduced on Linux desktop 0.48.1 (
e003e95, Chrome 152), so after #4537.In a 20 s recording I switched threads 7 times. Each switch blocked the renderer for roughly 0.5 to 1 s, almost all of it forced style/layout. The server answered the timeline request in 1 to 3 ms, so the time is client-side.
The biggest forcing callers per switch were the scroll keeper's
connect/applyreadingscrollTop, theTimelineWindowedItemsviewport measurement, ProseMirror in the composer re-applying attributes, anduseOverflowMeasurementreadingscrollWidth. Each forced restyle took 20 to 40 ms.DevTools was open, so absolute numbers are inflated. I can't attach the trace because it contains private conversations, but I can capture another if that's useful.
Mount timeline rows without forcing layout from the scroll handler (#…