Skip to content

Thread open on a slow phone: plugins the page does not need evaluate during the timeline's first render #8252

Backlog

Description

@salemsayed

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 main b0ddaad, pnpm run build, served by scripts/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.setCPUThrottlingRate 4, Network.emulateNetworkConditions latency 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/dist changes.

Steps to reproduce

  1. 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.
  2. bb plugin enable account-pool ask-user-question bb--server-switcher bb--storage-retention bb--mcp, then bb plugin install builtin:browser-automation, builtin:memory, git:https://github.com/ComicBit/bb-plugin-genui.git@d8cac8d1781bac336214cc38981aba4a58d9c1c0 and git:https://github.com/MacHatter1/bb-plugin-composer-predictions.git@63a1fadd03fc5c104c543d565deb519fe3e64aa7. That gives 25 enabled frontends, 3.1 MB of plugin JS.
  3. 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.
  4. 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 (PerformanceObserver longtask), 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 build metadata). 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.tsx has two failures on main at 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

  1. added theissue type on Nov 26, 2026
  2. added
    plugins
    ui
    partial-repro
    on Nov 26, 2026
  3. bb-slop-cop commented on Nov 26, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium. Applied labels: plugins, ui, perf, partial-repro.
    • Report: Reproduction and root-cause report — PARTIALLY REPRODUCED, root-cause confidence high.
    • Root cause: Non-priority imports wait for critical code loads to settle or a three-second page-age deadline; neither observes timeline readiness.
    • Evidence: Two clean trusted-main checkouts show imports starting while the real timeline remains pending with zero rows; both focused assertions fail as expected. All 21 relevant existing tests pass. The phone-performance gains were not remeasured.
    • No PR: Changing plugin reveal order, content-provider priority, and timeout behavior requires a product-policy decision, so this is not a safe simple fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    partial-reproperfpluginsui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions