Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): preview snapshots no longer stall on Chromium's legacy capture path #32415

Closedjuliusmarmingewants to merge 5 commits intomain fromfix/issue-32410opened View on GitHub

juliusmarmingecommented

Problem

Desktop Browser snapshots intermittently fail with Preview automation snapshot timed out after 15000ms and can keep failing until the tab is replaced. The desktop browser host keeps a preview tab offscreen and makes it paintable only while Page.captureScreenshot is pending; on that path Chromium's legacy CDP capture can stop answering. Playwright turns on CDPScreenshotNewSurface whenever it launches Chromium or Electron itself, but T3 launches Electron on its own and attaches over CDP, so the desktop app never gets it.

Reproduced on main (83a3674ffd) on Linux x86_64 under Xvfb with the reporter's native probe, which wires a real Electron <webview> through T3's createCdpRelayConnection and calls the real ServerBrowserPage.snapshot 100 times: every run stalled within the first 5 snapshots (with --disable-gpu and without) and failed with The page was too busy to capture a snapshot in time… after 10 s.

Change

Before Electron is ready, desktop startup appends --enable-features=CDPScreenshotNewSurface on every platform. The value is merged into any existing --enable-features list, because Chromium keeps only the last value of a features switch (the same reason the Linux --disable-features merge exists). Nothing is added when the feature is already enabled or when the user turned it off with --disable-features.

Scope and approval

Fixes pingdotgg/t3code#32410

Verification

  • vp test run apps/desktop/src/app/DesktopPreReadyPlatform.test.ts apps/desktop/src/app/DesktopEarlyElectronStartup.test.ts: 29 passed. The new tests fail on main: on darwin, win32 and linux startup leaves no feature (expected [] to have the same members as [ 'CDPScreenshotNewSurface' ]), and an existing --enable-features list is not extended. A third test covers the --disable-features opt-out.
  • vp run check:changed: format, lint, knip, typecheck and tests pass.
  • Native probe, Electron 44.10.1 under Xvfb, --no-sandbox, startup through the real DesktopPreReadyPlatform.make of each side:
SideStartup enable-featuresRunsResult
Before (main 83a3674ffd)(none)3stalled at snapshot 4, 3, 3; each failed after ~10 s with the busy-page error, with 3.6–3.8 s captures before it
After (79958c1eb6)CDPScreenshotNewSurface3100/100 snapshots each, current pixels and accessibility text verified, median 63–64 ms, max 155 ms
After, launched with --enable-features=WebRTCPipeWireCapturerWebRTCPipeWireCapturer,CDPScreenshotNewSurface1100/100, max 139 ms

Driver: the reporter's probe gist (build.mjs, host.html, reproduce.cjs), run unchanged with PROBE_PRODUCTION=1.

Before transcript, run 1 (main)
{"event":"startup","features":""}
{"event":"snapshot","iteration":0,"feature":false,"ms":121,"size":[500,300],"rgb":[255,0,0],"tree":true}
{"event":"snapshot","iteration":1,"feature":false,"ms":84,"size":[500,300],"rgb":[0,0,255],"tree":true}
{"event":"snapshot","iteration":2,"feature":false,"ms":3594,"size":[500,300],"rgb":[255,0,0],"tree":true}
{"event":"snapshot","iteration":3,"feature":false,"ms":82,"size":[500,300],"rgb":[0,0,255],"tree":true}
{"event":"failure","iteration":4,"feature":false,"ms":10010,"message":"The page was too busy to capture a snapshot in time. Wait for it to settle and take another snapshot."}

Independent run on a physical Linux x64 GNOME/Wayland desktop (GPU and sandbox on), reported in this PR's comments: with no feature enabled, the same probe stalled at snapshot 12 after 10,011 ms with the busy-page error; with CDPScreenshotNewSurface enabled through DesktopPreReadyPlatform.make, 100/100 passed. That after-run used the equivalent change in pingdotgg/t3code#32412, not this head.

Startup switches in a real Electron process

Ubuntu 24.04 x64, Electron 44.10.1, Xvfb 1920×1080×24 with Openbox. 44 Electron processes ran the real DesktopPreReadyPlatform.make of each side before ready; all assertions pass. C=CDPScreenshotNewSurface, W=WaylandWpColorManagerV1, E/D=enable/disable list, ∅=absent. L rows use a stubbed hyprctl to reach the Linux Hyprland merge; they prove the two merges compose, not compositor behaviour.

RowStarting switches E / DBefore
80e62619f5
After
1b38b8ce40
Expected after
A0∅ / ∅; two calls∅ / ∅C / ∅Append C once
A1Empty, bare or whitespace E or D; six variantsNative empty values/presence retainedE=C; D preservedNormalize reads; preserve D presence
A2WebRTCPipeWireCapturer,UseOzonePlatform / ∅; two callsE unchangedExisting E,C / ∅Append once
A3Decorated unrelated entry, CExtra, lowercase C; outer spacesE unchangedOuter-trimmed E,C / ∅Exact-name match; retain parameters
A4C; Other,C; Other,*C with study/parameters; two calls eachUnchangedUnchangedNo enable append
A5∅ / CUnchangedUnchangedHonor opt-out
A6Other with study/parameters / Vulkan,C bare or decoratedUnchangedUnchangedPreserve both lists; no append
A7Other,C / Vulkan,CUnchangedUnchangedNo append
A8∅ then Other / VulkanUnchangedC then Other,C / VulkanPreserve unrelated disables
L1∅ / ∅∅ / WC / WBoth helpers compose
L2Other / VulkanOther / Vulkan,WOther,C / Vulkan,WPreserve both lists
L3Other / Vulkan,COther / Vulkan,C,WSamePreserve opt-out
L4Other,C / VulkanOther,C / Vulkan,WSameNo duplicate C

Full inputs and results: startup-table.md, startup-before.ndjson, startup-after.ndjson.

Integrated desktop app

Real desktop app of each side under Xvfb (--no-sandbox --disable-gpu), fresh isolated T3 home, T3CODE_DEV_SEED=0, snapshots driven through the production preview MCP tools on a synthetic page.

Runtime rowBefore
80e62619f5
After
1b38b8ce40
Observed
R3 shown → hidden → shown → reload28/28 fresh; median/max 49/77 ms28/28 fresh; 64/110 msReal desktop webview and IPC; hidden rect=(-100000,-100000), visible=false; reload loadId changes
R4 viewer + recording5/5 fresh; viewer first JPEG 23 ms; recording seed JPEG 15 ms5/5 fresh; viewer first JPEG 17 ms; recording seed JPEG 7 msViewer still refresh and continued frames; four snapshots during recording; stop succeeds
R5 minimize → restore3/3 fresh; median/max 47/64 ms3/3 fresh; 39/43 msNative minimized=true, capture; restored minimized=false, two captures
R6 native macOScannot-verify macoscannot-verify macosNo native macOS run; not attempted
R7 native Windowscannot-verify windowscannot-verify windowsNo native Windows run; not attempted

The stall did not reproduce in the integrated app on either side under Xvfb, so these rows show the flag causes no regression across hide/show, reload, recording, the viewer and minimize; the stall fix itself rests on the native probe above. Viewer JPEG refreshes after the first capture took 12–28 ms before and 5–7 ms after.

Recordings: desktop-before.mp4, desktop-after.mp4, desktop-before-after.mp4, preview-before.mp4, preview-after.mp4. Transcripts: runtime-table.md, runtime-before.ndjson, runtime-after.ndjson. Drivers and stubs (not committed): integrated-run.mjs, build-startup.mjs, startup-matrix.mjs, hyprctl, all-drivers-and-stubs.tar.gz.

What else changed: nothing beyond the three files in this diff. Both sides shared driver, page, flags and fresh-state recipe; ports, IDs, timestamps and encoder start-up time vary.

cannot-verify macos, cannot-verify windows: no native macOS or Windows run; those platforms are covered by the unit tests and by Playwright enabling the same feature by default on every platform. A minimized window was checked on Linux/Openbox only.

Verification log
  • Merged main (80e62619f5) without conflicts; vp run check:changed passes on 1b38b8ce40 (format, lint, knip, typecheck, 29 tests).
  • Review round 1: two independent reviewers, both MERGE, no findings.
  • Proof audit: pass 1 derived a 21-row matrix; pass 2 checked every capture and recording, rebuilt one startup row independently (matching), and found all Linux rows covered; macOS and Windows unverified as above.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 1b38b8ce4013459df0066f29528632bf26a3057f and 7e6c97c50ec09eb91f9a695712b26cb37dddde3f.

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • Trigger review

      No actionable comments were generated in the recent review.

      Walkthrough

      Startup resolves CDPScreenshotNewSurface against existing enable and disable feature values. Pre-ready launch arguments include the resolved enable switch when applicable. Tests cover macOS, Windows, and Linux.

      Changes: CDP screenshot feature switch

      Layer / File(s)Summary
      Feature switch resolution
      apps/desktop/src/app/DesktopEarlyElectronStartup.ts
      The resolver preserves existing feature entries. It returns null if the feature is already enabled or disabled; otherwise, it adds the feature to the enable value.
      Pre-ready launch integration and tests
      apps/desktop/src/app/DesktopPreReadyPlatform.ts, apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
      Pre-ready startup appends the resolved enable switch when present. Tests cover three platforms, retained enable entries, and an existing disable entry.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • pingdotgg/t3code#23022 — The issue describes an offscreen guest capture stall. This change enables a different CDP screenshot path.
      • pingdotgg/t3code#23514 — The issue reports an unbounded desktop Page.captureScreenshot. This change alters the CDP screenshot path; deadlines and queue recovery are not included.

      Possibly related PRs

      • pingdotgg/t3code#32412 — Both changes enable CDPScreenshotNewSurface before Electron is ready.
      • pingdotgg/t3code#28991 — It changes pre-ready configuration and boot timing, which affect when this change applies the screenshot switch.
      • pingdotgg/t3code#24133 — Both changes address desktop preview screenshot stalls, using different capture-path changes.

      Suggested reviewers: maria-rcks

      Merge Risk: Minimal · previous review ab788

      No actionable merge-blocking issue was found in the startup switch change.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title describes the desktop snapshot stall addressed by the change.
      Linked Issues checkPassed[#32410] Pre-ready startup enables CDPScreenshotNewSurface and preserves existing feature flags and explicit opt-outs. The current summary reports cross-platform enablement tests and tests for flag …
      Out of Scope Changes checkPassed[#32410] The startup changes and tests support the snapshot fix and preserve existing feature settings. No unrelated changes are identified in the whole-PR summary.
      Description checkPassedThe description covers the required Problem, Change, Scope and approval, and Verification sections. It links the related issue and gives detailed test and probe results, including platforms that were …
      Full details: Linked Issues check

      Explanation

      [#32410] Pre-ready startup enables CDPScreenshotNewSurface and preserves existing feature flags and explicit opt-outs. The current summary reports cross-platform enablement tests and tests for flag preservation and opt-out. The author reports a successful native snapshot probe. The incremental diff was unavailable; the current whole-PR evidence supports the assessment.

      Full details: Description check

      Explanation

      The description covers the required Problem, Change, Scope and approval, and Verification sections. It links the related issue and gives detailed test and probe results, including platforms that were not verified. It notes AI assistance but does not name the model and harness as the template requests; this omission does not make the otherwise complete description fail.

      Finishing Touches

      Generate docstrings

      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 79958c1eb6e297c7edc5529119bc597d5de0199a and ab7883384e93103b127db38b744f50a0699cec56.

      Files selected for processing: 1

      • apps/desktop/src/app/DesktopPreReadyPlatform.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Desktop startup now enables Chromium's newer screenshot capture path by default to prevent preview snapshot stalls, while respecting explicit disables. Adopting this product-default change requires human review.

      Notes:

      • No code objects were reviewed. Approvability was decided on eligibility alone.

      No code changes detected at 7e6c97c. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. [GPT-6.1 Sol][Codex] on behalf of shivam.

      Independent #32410 findings from corex's physical Linux x64 desktop, GNOME/Wayland, Electron 44.10.1, Playwright Core 1.60.0. Normal GPU rendering and sandbox remained enabled. The native probe used an embedded webview, the real createCdpRelayConnection and ServerBrowserPage.snapshot, with separate profile/state directories for each side. Its window used showInactive().

      This tested the earlier fix in https://github.com/pingdotgg/t3code/pull/32412 at 4fa36c54ae2e0d0e30db7983d4da716cfb358e3f, based on 83a3674ffd84ffb33de768210c806cb1ac53fd80, not this PR's head. With production startup bypassed and no enabled feature, 12 captures succeeded, then iteration 12 stalled for 10,011 ms and returned the busy-page error. Executing that fix's real DesktopPreReadyPlatform.make enabled CDPScreenshotNewSurface; all 100 captures passed checks for changing PNG pixels and current accessibility labels. I inspected the final blue image with button text Frame 99.

      Retained transcript excerpts:

      {"event":"failure","iteration":12,"feature":false,"ms":10011,"message":"The page was too busy to capture a snapshot in time. Wait for it to settle and take another snapshot."}
      {"event":"startup","features":"CDPScreenshotNewSurface"}
      {"event":"snapshot","iteration":99,"feature":false,"ms":45,"size":[500,300],"rgb":[0,0,255],"tree":true}

      The per-capture feature:false field is the unused manual override, not the effective feature setting. vp test run apps/desktop/src/app/DesktopPreReadyPlatform.test.ts also passed all seven tests at the earlier head. Fresh Codex review found no blocking code findings there.

      Limits: the probe bypasses DesktopBrowserHost and renderer IPC, so this is native capture-path evidence rather than a full packaged-app pass. Minimized windows and physical macOS/Windows were not tested. No tests were run against #32415. Test processes exited and temporary artifacts were cleaned up. Handing this job over to you; no duplicate PR or further changes.

    5. juliusmarminge added labelsbugfix

    6. juliusmarminge added labelspr:gate-failed

    7. Separate nonauthor exact-head source review — T3 desktop capture startup, 7 Nov 2026 (Refs pingdotgg/t3code#32410 #32412 #32415; downstream Wladefant/superboard#1777 #1779 #1782 #1798 #1899).

      Candidate: OPEN, unmerged ab7883384e93103b127db38b744f50a0699cec56 -> main@83a3674ffd84ffb33de768210c806cb1ac53fd80; 3 paths (DesktopEarlyElectronStartup.ts, DesktopPreReadyPlatform.ts, DesktopPreReadyPlatform.test.ts), author juliusmarminge. This is review only; no source custody or merge claim.

      Review: I read the complete three-file delta and relevant exact-head startup code and existing Linux feature-switch tests. resolveEnableFeaturesSwitch appends CDPScreenshotNewSurface into the existing enable-features list, avoids duplicate/parameterized entries via featureListNames, and preserves an explicit disable-features opt-out. It runs inside the synchronous pre-ready Electron setup on Windows, macOS and Linux, after any Linux-specific disable-feature adjustment. The old early-portal/password-store handling and credentials/session logic are not changed. The tests cover all three OS startup choices, existing enabled features, explicit disable and startup ordering. Compared #32412: this head retains caller-requested opt-out, unlike its unconditional append. No additional in-scope P1/P2 source defect demonstrated by this delta. This is not proof of physical host behavior.

      Actual CI, not just PR text: unfiltered all-event exact-head Actions inventory returned 22 runs. The relevant automatic CI run https://github.com/pingdotgg/t3code/actions/runs/42358732829 completed SUCCESS but checked out the generated PR merge candidate e1310c3b77bf95070fe048f24648a2fa0fc2fcf7 = this exact source head merged into the recorded base, not the raw head checkout. Its canonical Test job #128362403634 reports apps/desktop/src/app/DesktopPreReadyPlatform.test.ts 10/10, DesktopEarlyElectronStartup.test.ts 19/19, desktop package 1,032/1,032 tests; Build/Typecheck, Lint and Check succeeded. Server shard Test steps, Test Web, Release Smoke, Rust and physical/macOS-preview workflows were SKIPPED where applicable, not passed. Native Linux Xvfb and separate GNOME/Wayland 100-snapshot evidence is author/reporter-provided, not independently executed in this review; the separate GNOME proof used #32412's head. No physical macOS/Windows/minimized-window acceptance or packaged integration run claimed.

      Disposition: Source-level COMMENT / no new P1/P2; explicit upstream Macroscope Needs Human Approval for the default Chromium-feature choice remains a product gate, plus maintainers' normal landing rules. Do not treat this comment as a human approval or a fleet host/session/consent proof. No CI dispatch, host action or merge here.

    8. juliusmarminge removed labelspr:gate-failed

    9. juliusmarminge added labelspr:in-progress

    10. juliusmarminge removed labelspr:in-progress

    11. juliusmarminge added labelspr:gate-failed

    12. @@ -243,4 +292,7 @@
      243292 });
      244293 assert.deepEqual(events, ["pre-ready", "clerk"]);
      245294 assert.equal(registerSchemesMock.mock.calls.length, 1);
      246- assert.equal(appendSwitchMock.mock.calls.length, 0);
      295+ assert.deepEqual(
      296+ appendSwitchMock.mock.calls.map(([name]) => name),
      297+ ["enable-features"],
      298+ );
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This mock-call assertion repeats the feature-switch test and makes the unrelated startup-order test depend on the exact switch list. Could it be removed?

      -        assert.deepEqual(
      -          appendSwitchMock.mock.calls.map(([name]) => name),
      -          ["enable-features"],
      -        );
      Posted via Macroscope — Test Signal
    13. The automated pipeline stopped on this pull request and will not merge it:

      the capture step could not show the problem on the base commit, so there is nothing to prove fixed.

      On each build, opened the same synthetic changing page. Repeated 120 cycles: hide the right panel, close the floating preview, wait 250 ms, update the numbered page revision, request a screenshot and accessibility snapshot while hidden, show the right panel, wait 250 ms, request another snapshot. Both builds returned 240 fresh snapshots without timeout or busy-page errors. Corresponding screenshot hashes matched across builds. Recorded each complete sequence. Final stills came from identical screenshot pairs 500 ms apart. Uploaded evidence, stopped all launched processes, and removed both worktrees and scratch files.

      It stays open for a person to finish or close.

    14. tanstack-source added labelsbug

    15. Thanks for this. #32412 makes the same change and is the one being kept.

      #32412 enables the same screenshot surface and also handles the post-navigation “Unable to capture screenshot” failure reported after enabling it. That additional fix makes it the more complete change to carry forward.

      Your feature-list handling and explicit opt-out coverage are useful refinements to preserve when consolidating the fixes.

      Closing as a duplicate.

    16. juliusmarminge closed this

Sign in to join this conversation.