Skip to content

Archiving a thread leaves its native browser views alive #2298

Open

Description

@seancxk

Archiving a thread leaves its native browser views alive

bb 0.39.0 · macOS 26.6.2 · arm64

Summary

Archiving a thread closes its panes but never destroys the native
WebContentsViews its browser tabs created. Deleting a thread does.

The surviving views keep a renderer process and their IOSurface memory, and —
because a hidden view keeps running its page — they keep compositing. An
archived thread can therefore still drive WindowServer CPU for a page nobody can
see, indefinitely.

Once a thread is archived its tabs are no longer reachable in the UI, so the
Cmd+W that would have released them is no longer available. Restarting bb is
the only remedy left to the user.

Impact

Archiving is the ordinary way to finish with a thread, so this accrues silently
in normal use: every archived thread that had a browser preview open leaves
something behind, and the user has no way to see it or clear it.

The cost falls on GPU/compositing rather than the memory figures people usually
check — a machine can be hot and sluggish with WindowServer high while memory
pressure looks unremarkable, which makes it hard to attribute. It is worst for
pages that animate, since a hidden view keeps drawing at full rate.

Users with limited RAM feel it first, but the accumulation itself is not
machine-specific: it scales with how many threads you archive after using a
preview, which for preview-heavy workflows is most of them.

Observed during a single working day of ordinary use: GPU-helper footprint
peaked at 1.30 GB with IOSurface use climbing from 483 MB / 111 regions to
736 MB / 151 regions, WindowServer at 43–50% CPU and the GPU helper at 20–37%,
with no memory thrashing — the cost was compositing, not swap. At that point
there were 10 renderer processes for 4 live threads, and 22 archived threads
still held persisted browser tabs.

Reproduce

  1. Open a thread and open an in-app browser tab (a local dev server page).
  2. Archive the thread. It leaves the sidebar.
  3. The renderer process for that tab is still alive, and the tab record is still
    present in thread_tabs.
  4. footprint -p <bb GPU helper pid> still counts its IOSurface regions.

Clearest with a page that animates: it keeps drawing while hidden.

What is not being claimed

Views are not retained unconditionally for the life of the app. During
observation the count fell on its own from 10 renderers / 736 MB / 151 regions
to 5 renderers / 340 MB / 65 regions with no bb restart, so something —
Chromium reclaim, or an existing bb path — does release some of them.

What is reproducible is that archive itself does not trigger the teardown,
and that survivors accumulate faster than they are reclaimed under normal use.
The figures above are the cost of that gap, not proof of an unbounded leak.

Suggested fix

In archiveThreadAndChildrenAction, after a successful archive, call
destroyPersistedBrowserViewsForThread for each archived thread id — the same
teardown delete already performs. Retain the tab metadata so unarchiving
recreates the page lazily, as reopening already does.

This makes archive consistent with delete and bounds the accumulation at the
point the user has signalled they are finished with the thread.

Possible follow-up

A pressure- or age-based policy for hidden browser views generally: destroy a
view hidden for longer than N minutes and reload it on demand. That would also
cover live threads whose previews are hidden with Cmd+J rather than closed
with Cmd+W — currently a hidden preview keeps both its memory and its
animation loop, which is easy to do accidentally since hiding feels like
closing.

Note

This cannot be worked around by a plugin. The server-side plugin SDK exposes a
tabs-changed event and the tab shape, but no mutation that closes a view; the
WebContentsView manager is desktop-core only. Clearing the persisted tab
record via bb thread tabs set would remove the record while leaving the live
view running and unreferenced, which is worse than the current behaviour.

Activity

  1. added theissue type on Aug 23, 2026
  2. added
    desktop
    on Aug 23, 2026
  3. SawyerHood commented on Aug 24, 2026

    @SawyerHood
    Collaborator

    ---Auto-Generated---

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2298.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): Since ce006c6 browser WebContentsViews are retained on unmount and destroyed only on tab close / thread delete / environment delete; neither the UI archive action (ThreadActionsProvider.archiveThreadAndChildrenAction) nor the archived-changed broadcast handler calls destroyPersistedBrowserViewsForThread, and the main process never reclaims views except on window close, so each archived thread's preview renderer stays alive (hidden, not animating) until the window closes.
    • Proposed fix: Mirror delete's teardown at both archive entry points (validated again in worktree wf_846839f8-f8a-17, diff at /tmp/bb-reports/issues/2298/repro/proposed-fix.diff): (1) in apps/app/src/components/thread/ThreadActionsProvider.tsx archiveThreadAndChildrenAction, after closePanesForThreads(response.archivedThreadIds), call destroyPersistedBrowserViewsForThread({desktopBrowser: getDesktopBrowserApi(), threadId}) for every archived id; (2) in apps/app/src/hooks/cache-owners/resource-route-owner.ts handle thread messages whose changes include "archived-changed" the same way as "thread-deleted" (cove…
    • Caveats: Revision re-ran the whole live repro from a fresh worktree (wf_846839f8-f8a-17, dev instance :14158/:22158/:30158) with the corrected scripts: launch-desktop.sh now derives the checkout from cwd/$WORKTREE/argv[1] and its desktop.log output is in the report; open-preview-in-thread.js and archive-via-sidebar.js discover the app target via browser.listPages(); bbdev.sh replaces BB_SERVER_URL prefixes…

    The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Code

  4. added
    confirmed-repro
    on Aug 24, 2026
  5. added
    partial-repro
    on Sep 30, 2026
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

    confirmed-reprodesktoppartial-reproperf

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions