Repository navigation
Description
Summary
On a slow phone, every plugin frontend a thread page does not need downloads and evaluates while the thread's timeline is still rendering its first rows. Plugins outside the priority set start once the route's code has loaded (about 3 s on the profile below), while the rows of a long thread arrive at 5 to 8 s, so the two compete for the main thread. Starting those plugins after the first rows are on screen (and loading the plugins that draw message content first) brought first rows 2 to 3 s earlier in most of my runs, but it moves work into the seconds after the rows appear. A prototype is linked below. I am filing this as an issue first because it changes the order in which plugin UI appears, which overlaps the reveal rules from #8152 and #8203.
Versions and environment
- bb from source at
mainb0ddaad,pnpm run build, served byscripts/start-bb.mjs(NODE_ENV=production) with its own data dir and ports. - Linux x64, Node 24.22.3, headless Chromium from Playwright 1.58.2 (revision 1208).
- Phone profile: iPhone user agent, 440×956, touch, CDP
Emulation.setCPUThrottlingRate4,Network.emulateNetworkConditionslatency 120 ms, 10 Mbit/s down, 3 Mbit/s up. - The host was shared with other builds, so single runs vary by several seconds. Every comparison below alternates main and the prototype run by run against the same server and data; only the served
apps/app/distchanges.
Steps to reproduce
- Build
main, start it once with an empty data dir, stop it, and seed it:pnpm seed:perf -- --data-dir <dir> --projects 1 --threads 12 --events 60000. Start it again. bb plugin enable account-pool ask-user-question bb--server-switcher bb--storage-retention bb--mcp, thenbb plugin install builtin:browser-automation,builtin:memory,git:https://github.com/ComicBit/bb-plugin-genui.git@d8cac8d1781bac336214cc38981aba4a58d9c1c0andgit:https://github.com/MacHatter1/bb-plugin-composer-predictions.git@63a1fadd03fc5c104c543d565deb519fe3e64aa7. That gives 25 enabled frontends, 3.1 MB of plugin JS.- In a fresh browser context with the phone profile, open the largest seeded thread (9,000 events) and let it settle, so the app has remembered its surface providers.
- Open it again, once after
Network.clearBrowserCache(localStorage kept) and once with a warm cache. Record when the first visible[data-timeline-row-id]row appears, long tasks (PerformanceObserverlongtask), and the resource timing of/api/v1/plugin-app-assets/*/app.js.
Expected vs actual
Actual on main: the app.js of plugins outside the priority set is requested at a median 3.3 s (cache cleared) and 2.7 s (warm), before the first row (5.9 s and 5.0 s). Their download and evaluation run during the timeline's first render.
Expected: plugins the first screen does not draw start once the thread has something on screen, which is what waiting for the screen paint is meant to do.
Observed cause: non-priority plugins wait on whenScreenPainted() (plugin-frontend.ts#L836), which ScreenPaintSignal resolves when the critical code loads settle (ScreenPaintSignal.tsx#L10). On a thread route the timeline's data and first render come after that.
Evidence
Prototype: salemsayed/bb perf/lazy-plugin-frontend (7b95add). On thread routes it adds the plugins that registered code-fence renderers, message directives or timeline renderers in the previous session to the priority set (remembered like the surface providers), and starts the remaining plugins once ThreadTimelineSurface has left its pending state, at most 10 s after page start. With nothing remembered yet (a fresh browser), it behaves exactly like main.
Medians, phone profile, main vs prototype, runs alternated:
| Setup | Open | Runs per side | First row | Settled | Long tasks after first row | Longest task |
|---|---|---|---|---|---|---|
| Steps above (25 frontends, 3.1 MB) | cache cleared | 5 | 5.9 s → 3.8 s | 7.6 s → 4.6 s | 3.8 s → 1.1 s | 0.53 s → 0.37 s |
| Steps above | warm | 5 | 5.0 s → 5.1 s | 5.8 s → 7.3 s | 1.6 s → 6.5 s | 0.35 s → 0.60 s |
| Larger setup: 28 frontends, 4.3 MB, a real 19,600-row thread | cache cleared | 10 | 8.4 s → 5.6 s | 9.9 s → 7.7 s | 1.0 s → 3.6 s | 1.45 s → 1.18 s |
| Larger setup | warm | 10 | 7.8 s → 4.7 s | 9.3 s → 6.2 s | 0.8 s → 1.6 s | 1.42 s → 0.84 s |
| Larger setup, desktop, no throttling | warm | 15 | 1.31 s → 1.21 s |
"Settled" is the last time the first visible row moved or the visible row count changed. In the larger setup the prototype was faster to the first row in 8 of 10 alternated pairs for each open type. Upper bound: holding every plugin bundle except the composer and navigation until the first row was visible took the larger setup's first row from 7.2 s to 3.5 s (5 runs).
What the prototype does not solve, and why I am asking before a PR:
- The deferred plugins now evaluate and register after the rows exist. Long-task time after the first row went up in three of the four rows above, so the page stays busy for a second or more after the rows appear. In the public setup's warm open, that cost outweighed the gain.
- Plugin chrome on the thread page (header actions, composer actions, Info rows) now appears after the rows on slow devices instead of before.
- A real "load a plugin only when one of its slots renders" would need each plugin's registration footprint before its entry evaluates (for example from
bb plugin buildmetadata). That is larger than this change.
Settled screenshots of the thread, home and a plugin settings page, desktop and phone, showed the same plugin controls and text with and without the prototype, and no crashed slots.
What you ruled out
- Not covered by Load plugin surfaces and core contributions from chunks with one lazy helper #8152 or Start lazy plugin parts and their runtime slots as early as the screen needs them #8203: those move parts of a plugin behind
experimental_lazy, but every enabled plugin's entry still evaluates in the window above. Their measurements also found time to interactive moved only slightly. - Not a duplicate: I searched open issues for plugin frontend loading, slow phone open and startup plugin bundles.
- Bytes alone are not the issue. The gain comes from moving when the evaluation happens; total plugin bytes are unchanged.
- A fresh browser with no remembered providers is unchanged by the prototype, by design.
ThreadDetailPromptArea.test.tsxhas two failures onmainat b0ddaad ("keeps a delayed bottom upload owned by the bottom draft", "dismisses a missing queued message but keeps a stale edit recoverable"); they are unrelated to this and fail with or without the prototype.
Suggested priority and effort
Affects anyone opening bb on a phone with several plugins enabled, most on long threads; no data loss and no workaround. The prototype is a host-side scheduling change in apps/app (no SDK or wire change). If this direction is wanted, I can turn it into a PR, or rework it to spread the post-row registrations so they do not pile up right after the first rows.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 26, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotplugins,ui,perf,partial-repro.