Skip to content

fork: a desktop tab keeps drawing for its viewer while T3's window is hidden - #61

Merged
3mdistal merged 5 commits into
fork/mainfrom
t3/hidden-tab-frames
Nov 19, 2026
Merged

3mdistal merged 5 commits into
fork/mainfrom
t3/hidden-tab-frames

Conversation

@3mdistal

@3mdistal 3mdistal commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Problem

A preview tab an agent opens on Alice's Windows PC lives inside the T3 desktop app there, as an Electron <webview>. From another device (her MacBook), the browser panel shows it live: the server starts a Chrome DevTools Protocol (CDP) screencast on the tab and forwards each frame. While T3's window on the PC was minimized, hidden or covered by other windows, the tab drew nothing, so the panel stayed blank or froze on its last frame. Clicks and typing still reached the page, but nobody could see what they did.

#60 makes the panel open at once and say why it's blank. This PR makes it draw. The two are independent and can land in either order.

What happens on the PC

Measured on the PC with a throwaway Electron 44.10.0 app (Chromium 152, the version T3 ships), showing a webview whose page animates:

Window Screencast frames Direct screenshot Click
Visible 86 in 3 s 150 ms lands
Minimized 0 in 4 s 125 ms lands
Hidden (win.hide()) 0 in 3 s 125 ms lands
Covered by another window 0 in 4 s 125 ms lands
Minimized, capturePage() on the guest every 500 ms 8 in 5 s
Hidden, capturePage() on the guest every 250 ms 16 in 4 s
Covered, capturePage() on the guest every 500 ms 10 in 5 s
Minimized, capturePage() on the window's own page every 500 ms 0 in 5 s
Visible, page still, capturePage() on the guest every 500 ms 0 in 4 s

While capturePage() runs, Chromium counts the page as visible, so it draws one frame and the screencast sends it. Electron 44 has no way to hold that state (incrementCapturerCount() was removed), so the fix repeats the call. A capture took 10 to 25 ms.

Turning off Chromium's covered-window detection (--disable-features=CalculateNativeWinOcclusion) kept a covered window drawing at full rate, 115 frames in 4 s. It does nothing for a minimized window and changes the whole app, so this PR doesn't use it.

What changes

DesktopBrowserHost, the desktop end of the CDP relay, runs a small loop (pumpFrames) for a tab while a screencast of it runs:

  • Every 250 ms it checks how many screencast frames came, whether a capture ran (its own or a screenshot nudge's), and whether an input command came.
  • A frame no capture brought means the window draws, so the tab gets no capture for the next 1.5 s. A page that draws on its own, even once a second like a clock, gets none once one of its frames lands that way.
  • Otherwise the tab gets a capturePage() every tick for 3 s after an input or the stream's start, and after that every tick only while each capture brings a frame, else every 2 s. So a hidden page that someone is using, or that changes, draws about 4 frames a second. A still page gets no screencast frame from a capture, so it costs one capture every 2 s and no bandwidth.
  • One frame after a capture can't hold the full rate, since it may be the page's own. A clock in a window that shows, whose ticks keep landing just after captures, gets captures for its first 3 s and then none.
  • When a page that drew on its own stops, as when the window hides, the 3 s at the full rate start over.

Frame copies still go one at a time. The existing screenshot nudge already calls capturePage() for a screenshot stuck 500 ms (FORK.md, "Browser screenshots while Windows hides T3"), and screenshots go one at a time because Chromium below 157 can crash the whole app when a guest's renderer exits with a copy in flight (crbug.com/567321049). The loop shares the nudge's capture, now captureFrame:

  • A tick is skipped while a screenshot or another capture runs, and a screenshot waits for the loop's capture as it does for a nudge's.
  • Electron can't cancel a capture, so none starts while another is still running, even past the 5 s a screenshot waits for one. Before, a nudge could start a second one.
  • That wait is kept per guest instead of per attachment, so a guest attached again after the manager recovers its debugger still waits on an earlier capture. Before, the reattached guest's next screenshot or nudge could overlap it.

The last two also change the nudge. They came out of a review of the first commit. A second review found the clock case above: before, a clock whose first tick came after captures started got four captures a second forever.

What doesn't change

  • A visible tab that draws gets no captures, and its frames come as before.
  • The server, the web viewer and the wire format are untouched. No settings or stored data change. Rolling back means reverting the commits.
  • macOS and Linux run the same code. A window that shows draws there, so the loop only captures a still page someone watches: one capture every 2 s, after the first 3 s.

Risk

  • Crash exposure: at the fastest rate a capture is in flight about 4% of the time, only while someone watches a tab whose window is hidden or whose page is still. Before, it was one capture per stuck screenshot.
  • Cost: each capture is a GPU readback of the tab, 10 to 25 ms on the PC.

Testing

  • apps/desktop/src/preview/DesktopBrowserHost.fork.test.ts, new "a streamed tab in a hidden window" tests, with a fake guest and Effect's TestClock:
    • a capture each tick while each capture brings a frame, past 3 s;
    • no captures for a page that draws on its own, fast or once a second, then one 1.5 s after it stops;
    • a clock whose first tick comes after captures start gets 11 captures, then none over the next 10 s (the old loop captured every tick);
    • a still page slows to one capture every 2 s, and an input brings back the full rate;
    • the loop stops with the stream and starts again with the next;
    • a stream stopped and restarted within one tick starts at the full rate;
    • a screenshot waits for the loop's capture, and the loop waits for the screenshot;
    • a capture past its 5 s limit lets the screenshot go but no second capture start, from the loop or the screenshot's nudge, until it settles;
    • a guest detached and attached again keeps its screenshot waiting on the earlier capture.
  • The numbers above, from a probe app on the PC that isn't checked in.
  • The loop's rule, simulated tick by tick for each test's expectations, before CI ran them.
  • CI on this PR. vp run check:changed on a boat.dev machine didn't complete: the boat tool crashed on the first try and hung on the second.

Not yet seen end to end: the real T3 app on the PC with this change, viewed from the MacBook while T3's window is minimized. That needs a fork release with it installed on the PC.

Review focus

  • The rate policy: a 250 ms tick, 3 s at the full rate after an input, the full rate after that only while each capture brings a frame, else every 2 s, and 1.5 s of rest after a frame the page drew on its own. Is a hidden page that changes on its own every few seconds, with no input, shown often enough at one frame every 2 s?
  • The new rules in captureFrame and what they change for the existing screenshot nudge.

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

3mdistal and others added 3 commits November 18, 2026 19:07
A webview's screencast sends no frames while Windows counts T3's window
hidden (minimized, hidden or covered), so someone viewing the tab from
another device saw it freeze. Each capturePage() on the guest draws one
frame, so while a tab streams without drawing on its own, the host
captures it every 250 ms for 3 s after a frame or an input, then every
2 s, one frame copy at a time with screenshots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From review: a capture past its 5 s limit no longer lets another start
while Electron still runs it, and the wait goes by guest, so a guest
attached again still waits on it. A frame no capture brought now spares
the tab captures for a second, so a page that changes once a second
gets none. A stream restarted within a tick starts at the full rate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal and others added 2 commits November 18, 2026 19:53
…es going

A clock in a window that shows draws once a second. When its first tick came
after captures had started, each tick landed just after a capture, passed
for that capture's frame and reset the quiet count, so the tab got four
captures a second forever. Now a frame keeps the full rate only when the
capture before it brought one, so the next capture that brings none drops
the tab to every 2 s, where the clock's next tick shows the page draws on its
own. Inputs and the stream's start still give 3 s at the full rate, and so
does a page that stops drawing on its own, as when the window hides. Any
capturePage() counts, a screenshot nudge's too, and the rest after a page's
own frame is 1.5 s, so a clock's tick a little late still counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@3mdistal

Copy link
Copy Markdown
Owner Author

Landing on Alice's yes. At Nov 19, 10:08 AM ET she switched this task's row on her Task Priorities board to Agent with no comment, which accepts the suggested answer to its question.

The question:

Land the fix that explains a blank tab and the fix that keeps it drawing? The decision page has more.

The suggested answer:

Land both, then I make a fork release, install it on the PC and check a hidden tab from the MacBook.

Before merging: all checks pass on this head, fork/main hasn't moved since (19d8b32), and #60 and #61 merge together cleanly.

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

@3mdistal
3mdistal merged commit 0e1b527 into fork/main Nov 19, 2026
17 checks passed
3mdistal added a commit that referenced this pull request Nov 21, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s. Captures share the screenshot nudge's captureFrame: none starts while another still runs, and the wait goes by guest, so frame copies still go one at a time (crbug.com/567321049).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 21, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s. Captures share the screenshot nudge's captureFrame: none starts while another still runs, and the wait goes by guest, so frame copies still go one at a time (crbug.com/567321049).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s. Captures share the screenshot nudge's captureFrame: none starts while another still runs, and the wait goes by guest, so frame copies still go one at a time (crbug.com/567321049).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s.

Rebuilt on upstream's pingdotgg#40263, which prods a hidden guest with capturePage() while a screenshot waits and replaced the fork's screenshot nudge this patch built on; this sync drops that nudge. The pump's captureFrame counts in upstream's per-guest nativeCaptures and starts none while one of either still runs, and the pump skips a tick while a screenshot runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s.

Rebuilt on upstream's pingdotgg#40263, which prods a hidden guest with capturePage() while a screenshot waits and replaced the fork's screenshot nudge this patch built on; this sync drops that nudge. The pump's captureFrame counts in upstream's per-guest nativeCaptures and starts none while one of either still runs, and the pump skips a tick while a screenshot runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s.

Rebuilt on upstream's pingdotgg#40263, which prods a hidden guest with capturePage() while a screenshot waits and replaced the fork's screenshot nudge this patch built on; this sync drops that nudge. The pump's captureFrame counts in upstream's per-guest nativeCaptures and starts none while one of either still runs, and the pump skips a tick while a screenshot runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s.

Rebuilt on upstream's pingdotgg#40263, which prods a hidden guest with capturePage() while a screenshot waits and replaced the fork's screenshot nudge this patch built on; this sync drops that nudge. The pump's captureFrame counts in upstream's per-guest nativeCaptures and starts none while one of either still runs, and the pump skips a tick while a screenshot runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 30, 2026
… hidden (#61)

While T3's window on Windows is minimized, hidden or covered, a webview's screencast sends no frames, but each capturePage() on the guest draws one. While a tab streams, DesktopBrowserHost's pumpFrames checks it every 250 ms and captures each tick for 3 s after an input or the stream's start, then each tick only while each capture brings a frame, else every 2 s; a frame no capture brought means the window draws, so the tab gets none for 1.5 s.

Rebuilt on upstream's pingdotgg#40263, which prods a hidden guest with capturePage() while a screenshot waits and replaced the fork's screenshot nudge this patch built on; this sync drops that nudge. The pump's captureFrame counts in upstream's per-guest nativeCaptures and starts none while one of either still runs, and the pump skips a tick while a screenshot runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant