[Bug]: Preview tabs from other threads stay alive as hidden, unthrottled webviews until restart (13 tabs, ~2.7 GB) #15579
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
- Over a working day, let agents in several threads call
preview_open(13 tabs across a few threads here). - Never close those previews by hand. The agents never call
preview_closeeither. - Switch to another thread with the preview panel closed and leave the app running.
Expected behavior#
Preview tabs that the user can't see, in threads they're not looking at, should be throttled, frozen or discarded. They should also be closed eventually, for example when the thread is idle, archived or deleted. They shouldn't keep a full renderer running for the rest of the session.
Actual behavior#
Nothing ever closes them. The desktop trace log shows 13 createTab and 0 closeTab since start. ElectronBrowserHost mounts a HostedBrowserWebview for every session in every thread. Hidden ones are only moved offscreen with CSS, and there is no backgroundThrottling, freeze or discard. The pages keep running scripts, including the ad and tracker iframes of the visited sites. PreviewManager holds the sessions in memory until an explicit close(), and ResourceCleanupService doesn't close previews.
Measured 2026-10, with the T3 Code window visible on another thread and no preview panel open:
- 18 renderer processes, about 2.7 GB PSS in total. Most of that is the preview tabs; the main window is one renderer.
- The main process "Gamepad polling" thread wakes about 245 times a second; the same thread in another Chromium browser here is idle. T3 Code itself doesn't use the Gamepad API, so this is presumably a script on one of the preview pages calling
navigator.getGamepads()(fingerprinting scripts do this).
None of this is visible in the UI, so the user can't tell that the previews are still open.
Related: #14966 (sessions outlive a deleted thread), #14730 (inactive macOS previews keep rendering) and #13610 (orphaned hidden tab leaks GPU memory). This issue is the Linux, cross-thread version: threads that are neither deleted nor orphaned.
Impact#
Major degradation or frequent failure
Version or commit#
v0.0.45 (desktop)
Environment#
NixOS, Linux 7.2.8, GNOME (Wayland), Intel Lunar Lake laptop on battery
Workaround#
Restart T3 Code (preview sessions aren't persisted), or open each thread and close its previews.
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
juliusmarminge closed this
Note
Grok responding on behalf of Julius.
Reopening: #16961 (merge
d9f7c0c) still listedFixesfor this issue, but the hidden-tabs commit was reverted before merge (f3bbe7f— Revert "fix(web): hidden browser tabs on macOS stop painting").mainstill keeps inactive macOS guests paintable viakeepPaintableWhenInactive: isMacPlatform(...), so this is not fixed yet.juliusmarminge reopened this
Additional measured incident on macOS with the newer server-hosted browser path. Posting here to avoid duplicating the broader retained-preview report; the headless rendering path may warrant separate tracking. Related: #17090.
Environment:
- T3 Code Nightly
0.0.46-nightly.20261009.2861, installed commit3b6af0bd1600. - macOS 26.6, build 25G72, Apple Silicon (
Mac17,9), 15 CPU cores, 48 GiB RAM. - Managed
chrome-headless-shell154.0.8037.92.
The user reported mild lag across the system. During read-only inspection:
- A T3-owned headless browser's graphics process consumed 140.9% CPU in a timed
topsample and 153.7% in a separate rollingpsreading (100% = one core). - Browser launch flags included
--disable-gpu --enable-unsafe-swiftshader --force-device-scale-factor=2 --disable-background-timer-throttling --disable-renderer-backgrounding. - Its graphics process used
--use-angle=swiftshader-webgl. - The browser had been running for approximately 4 hours 42 minutes and was parented by the T3 backend.
- T3's Electron GPU/interface processes and WindowServer were also busy; total system CPU still had about 60% idle capacity.
- Memory pressure was normal, swap was zero, data-volume free space was about 846 GiB, and
pmset -g thermreported no thermal/performance warning. preview_statusandt3_preview_listfor the diagnostic thread returned no tabs. These tools are thread-scoped, so this does not establish that tabs in other threads were inactive or had no automation consumers. Their individual visibility was not inspected.
At the user's request to close previews, SIGTERM was sent only to the identity-verified shared headless browser root process. Its graphics process and all managed headless-browser processes then disappeared; the T3 desktop and backend remained running. A subsequent timed system sample had 72.4% CPU idle (the preceding sample had 74.9%). This was a short live observation, not a controlled benchmark, and no claim is made that all perceived lag was resolved. The browser was stopped at process level because the available normal tab-close tool only covered the diagnostic thread; preview-session metadata cleanup was not verified.
This supports investigating the CPU cost and lifecycle of retained server-hosted browser tabs on local macOS installations, in addition to the earlier native webview reports. It does not establish a memory leak, an exact reproduction sequence, or that SwiftShader alone caused the system-wide lag. Inactive tabs without automation, recording, or viewing consumers should suspend rendering, and users should be able to discover and close retained tabs across threads.
Measurements and this comment prepared with Codex on the user's behalf.
- T3 Code Nightly
Adding another symptom from #20890 (closed as a duplicate of this one): when the project is a browser game or any page that autoplays audio, every lingering preview tab keeps playing its own copy of the soundtrack. After a few rounds of agent checks across threads, you hear dozens of copies of the same loop playing over each other, and the UI gives no way to tell which tabs are making the noise. Settling the threads doesn't stop it either. On macOS here (v0.0.45).
I've opened #20893 in Ideas for user-facing controls (mute preview tabs by default, an audio indicator, "Mute all" / "Close all preview tabs") as a stopgap alongside the lifecycle fix here.
Another measured incident, on Windows, much larger than the original report.
Environment:
- T3 Code (Beta)
0.1.9, Windows 11 Home, 64 GB RAM, WSL2 backend. - About eight threads open; agents in several of them had used preview tools over the session.
Measured with
Get-CimInstance Win32_Processbefore a restart:Process type Count Working set renderer 116 16.7 GB main 1 0.6 GB gpu-process 1 0.3 GB utility 1 0.1 GB The largest renderer held 1.7 GB; most of the others held 0.1 to 0.3 GB each.
Effect: Windows was at 49 of 64 GB used. WSL could not get its memory back, and it used 6 of 8 GB of swap. The whole machine lagged.
After a full quit and restart of T3 Code: 5 processes, 0.9 GB. Windows went down to 31 GB used, and WSL went back to 0 swap.
I can't confirm that every one of the 116 renderers was a retained preview tab, because they were gone after the restart. The growth pattern and the full recovery after the restart match this issue.
- T3 Code (Beta)
Another measured incident, on a low-memory Mac with a remote environment. Two details may be new: killing the renderers does not help, and settled threads keep their tabs.
Environment:
- T3 Code Nightly
0.1.9-nightly.20261110.4478, macOS 26.3, MacBook Air with 8 GB RAM. - The desktop app connects to a remote environment on another machine. All of the threads ran there.
What happened:
- I ran about 16 threads in one batch. Each produced an HTML page, and a preview tab opened for it.
- All the threads settled within an hour. None were archived. Their 19 preview tabs stayed open.
- Four days later, the desktop app held 19 preview renderers.
topshowed 150 to 370 MB each, mostly compressed. That came to about 4 GB on an 8 GB machine, with swap at 4.5 of 5 GB. renderer-history.ndjsonshowed each one as"surface":"preview", with atabIdof[remoteEnvironmentId, threadId, …, tab_x].
Killing the renderer processes does not work.
PreviewManagerre-registers every webview, and all 19 renderers came back within seconds. The desktop trace showsrender-process-goneand thenregisterWebviewfor each tab.What worked was a reload of the main window. The tab list lives only in that window's memory, so the tabs did not come back. Swap fell from 4.5 GB to 2.9 GB.
The existing
ServerBrowseridle policy does not cover these tabs. It hasAGENT_TAB_LIMIT = 8,SERVER_TAB_LIMIT = 32andAGENT_TAB_IDLE_MS = 30 min, but desktop webview tabs have no limit and no expiry.Suggested fix, in order of preference:
- Destroy a hidden tab's webview after N minutes. Keep its URL, title and favicon, and load it again when the user opens that preview panel. Tabs in settled threads qualify sooner.
- Add a setting to close a thread's desktop preview tabs when it settles or is archived.
- Cap live preview webviews across all threads, and suspend the least recently used tab first.
- T3 Code Nightly
Adding my experience and a vote for automatically closing a thread’s previews when it settles.
On T3 Code Beta 0.1.9, on an Apple Silicon MacBook Pro with 24 GiB RAM, my Mac was getting hot and RAM pressure remained high. Inspection found previews from completed/settled threads still loaded.
We closed 27 old preview tabs through T3’s UI, leaving active previews, conversations and current work open. Approximate observations before and after:
- Total T3 process memory reported by macOS
top(including compressed memory): 8,063 MiB → 3,470 MiB, about 4.5 GiB released. - T3 process count: 41 → 17.
- macOS
kern.memorystatus_vm_pressure_level: 2 → 1.
These were live observations, not a controlled benchmark; other work continued during cleanup. The heat investigation also found a busy macOS
suggestdprocess, so I’m not attributing all the heat to T3.My preferred workflow is simple: settle a thread → close its preview tabs and release their renderers, while keeping conversations, files and active threads intact. Ideally keep the last URLs available to reopen, and offer an opt-out if some users want previews to stay live. Merely hiding a preview or stopping its dev server doesn’t solve the retained RAM problem.
This seems to belong here rather than #34681, which explicitly leaves preview lifetime/memory cleanup out of scope. Happy to see this addressed through the existing upstream work rather than needing a custom app build.
Measurements collected with Codex; posted at my request.
- Total T3 process memory reported by macOS
advaitpaliwal(GitHub profile, opens in a new tab) linked this to #38399
Note
🤖 Claude Opus 5.5 responding on behalf of samdickson22
This still happens on
0.1.12-nightly.20261123.5151(macOS 27.0, build 26A428, Apple Silicon, 24 GB). The scale here is smaller than the other reports, but the lifecycle is the same.renderer-history.ndjsonshows a preview webContents opened by a delegated subagent thread 25 hours ago. That thread finished long ago, and the tab's renderer is still alive.footprintputs it at 206 MB, with a peak of 216 MB.- Over the same app session,
desktop.trace.ndjson*logs 4PreviewManager.createTabcalls and 2closeTabcalls. Both tabs that were never closed still hold a renderer: 206 MB and 368 MB, against 293 MB for the main window's renderer. - Neither preview tab is open in the UI.
To reproduce, have a subagent thread call
preview_openand finish without callingpreview_close, then keep the app running. The renderer stays alive until a restart.For anyone triaging a large "T3 Code" figure in Activity Monitor or in the macOS "out of application memory" dialog: on this machine, T3's own processes (main, server, renderers, GPU) added up to about 2.3 GB and stayed flat across three samples. The remaining 8 to 11 GB in the T3 process tree belonged to agent children, such as builds, test browsers and per-session MCP servers. Measure your own process tree before you blame the app.
I observed this on T3 Code Beta 0.1.12, macOS 27.0.1 (26A434), Apple Silicon with 32 GB RAM. A single resource-heavy preview tab in a completed thread was enough to cause severe system-wide memory pressure. I had switched away from that thread long before noticing the load, with no agent task running in that thread.
Before closing the tab
- T3 Code's renderer history identified the busy process as a preview guest (
surface: "preview"). - The guest had been alive for roughly 8.5 hours. Short-interval macOS
topsamples showed 153–199% CPU (100% is one logical core). Bothsampleandvmmapreported a 14.5 GB physical footprint. - System-wide used memory was about 31 GB, including about 14 GB of compressed memory.
After closing the tab in T3 Code
- The renderer history recorded a
destroyedevent for the guest, and its process exited. T3 Code stayed open. - System-wide used memory fell to about 24 GB, with compressed memory down to about 7.7 GB.
This was a live before-and-after check. The exact page workload and allocation path are still unknown.
Suggested behavior
Automatically unload a preview guest after a configurable idle period (for example, 10 minutes) when its thread has finished, the preview is hidden, and there is no browser operation in flight. Let ongoing background screenshots and clicks finish before unloading. Keep the tab's title and URL with a sleeping indicator so selecting it reloads the page. A per-tab “Keep running” option would let users preserve pages with in-memory state, such as an unfinished form. Under memory pressure, consider unloading the oldest eligible hidden guests sooner.
- T3 Code's renderer history identified the busy process as a preview guest (
I encountered a user-visible audio symptom of the retained preview on T3 Code Desktop (Beta) 0.1.13, macOS 27.2.1, Apple silicon.
Sequence observed once
- A delegated Antigravity / Gemini 4 Neon run opened a public YouTube video with
preview_open({ open: false, url }). - The run called
preview_navigateon that tab and was interrupted a few seconds later. The child thread was subsequently shown as settled. - Many hours later, while a different thread was active, T3 unexpectedly played audio. The embedded browser's YouTube cache contained the exact video title shown during the incident. YouTube autoplay is plausible, but the precise transition and whether playback was continuous are unverified.
Why it was hard to stop
- The desktop renderer history still showed a live preview webContents for the settled child thread. From the investigating thread,
preview_status({ tabId })returnedavailable: falseandt3_preview_listreturned no sessions. - Revisiting the child thread and closing the visible Browser panel did not remove that webContents. Sending SIGTERM to the identified preview renderer produced consecutive
render-process-goneanddestroyedevents for it. The T3 main process stayed running.
Expected behavior: Clean up hidden, agent-created previews on interruption or settlement, or keep any retained preview muted and give the user a way to locate and close it. Background media should not play with no corresponding tab controls.
- A delegated Antigravity / Gemini 4 Neon run opened a public YouTube video with
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks so much for the careful measurements, @davidvornholt, they made this easy to trace. I checked it on current
main(eac52f0087) and on v0.0.45 (6c8fed35dd), and the relevant code is the same on both: preview tabs you aren't looking at stay mounted as live Chromium guests for the rest of the session.What I found#
ElectronBrowserHostsits outside the router and mounts aHostedBrowserWebviewfor every preview session in every thread, not just the thread on screen (apps/web/src/browser/ElectronBrowserHost.tsx). A thread stays in that index as long as it has sessions (syncActivePreviewThreadinapps/web/src/previewStateStore.ts).closeTabruns only when the React guest unmounts (apps/web/src/browser/desktopTabLifetime.ts), which happens only after an explicitpreview.closefrom the UI or frompreview_close/t3_preview_close. Closing the panel or switching threads doesn't close tabs.(-100000, -100000)withvisibility: hidden(apps/web/src/browser/hostedBrowserWebviewStyle.ts).data-preview-rendering="suspended"is only a marker for automation. Nothing calls Chromium freeze or discard, and nothing destroys the guest.contextIsolation=false,sandbox=true,nodeIntegration=false(apps/desktop/src/preview/WebviewPreferences.ts). Electron's default background throttling only applies once Chromium considers the page backgrounded, and the guest is temporarily set tosetBackgroundThrottling(false)while recording or in picture-in-picture.navigator.getGamepads(), so the Gamepad polling wakeups very likely come from a script inside one of those guests, which fits your theory.ResourceCleanupServiceonly cleans up terminals and attachments, and thread deletion, archive, and settlement don't touch previews (apps/server/src/orchestration-v2/ThreadDeletion.ts).How this differs from the related issues you linked:
preview_resizetimeout. These tabs were never evicted.Likely fix area#
A few options a maintainer could weigh:
renderingActivepath.Restarting the app or closing each thread's previews remains the workaround for now.
A maintainer will decide on the fix direction.