Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): restore recording and macOS rendering after Electron 43 #9001

MergedStiensWout(GitHub profile, opens in a new tab)merged 17 commits intomain fromrefs/pull/9001/headmerged by juliusmarminge View on GitHub

Electron 43 broke browser preview recording on desktop and could leave restored previews blank on macOS.

Recording now uses getDisplayMedia(), with the desktop process routing each request to the preview tab that armed it. Arms are exclusive, expire after 10 seconds, and are cleared when the tab, webview, or main window closes. Renderer handoffs are serialized so multiple tabs can record concurrently without claiming the wrong guest.

While a preview is being recorded or captured for picture-in-picture, the host window and the guest WebContents are unthrottled. Capture-active guests remain composited behind the app instead of being parked outside the window, so hidden threads keep running JavaScript and producing complete recording frames. Replacement guests inherit the capture state, and throttling is restored after the final consumer stops.

On macOS, inactive preview webviews remain paintable while parked offscreen without being reported as actively rendering to preview automation. Linux and Windows continue to suspend previews that have no active rendering consumer.

This includes Guillermo Casanova’s work from #8957 with commit authorship preserved.

Focused desktop and web preview tests, lint, formatting, and desktop, web, and contracts typechecks pass. No documentation files changed.

Linux package proof

Built and launched the production x64 AppImage from 0e6eefb7c. The packaged user agent reports Electron 43.4.1 and Chromium 150.0.7871.224. AppImage SHA-256: c88763a1e35f5e9be34a135b290c51c1fd15a97b271dc260706775f56c6e9afd.

Thread A recorded while Thread B was foregrounded. B then recorded concurrently, saved first, and A remained active when returning to its thread. While B was foregrounded and both recordings were active, A advanced from 1,313 to 1,376 interval ticks and from 6,457 to 6,828 animation frames over 6.22 seconds.

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/5c8ffafb-a77c-4e43-a213-d4f8c150b906/pr9001-thread-a-background-recording-playback.mp4

The Thread A samples below are one second apart and cover the hidden interval. Wall time advances by one second, interval ticks by 10, and animation frames by about 60 in every sample. The raw WebM’s largest frame-packet gap is 90 ms.

Thread A one-second background recording samples

Made with GPT-5.6-sol through the Codex harness in T3 Code.


Note

Medium Risk Recording now depends on a fragile main/renderer display-media handshake and exclusive arming; regressions could break capture, leak throttling, or mis-route streams, though behavior is heavily covered by new desktop and web tests.

Overview Restores desktop preview recording after Electron 43 by dropping the removed getMediaSourceId / chromeMediaSource: "tab" path in favor of getDisplayMedia, with the main process routing each request through a per-session setDisplayMediaRequestHandler. A tab must arm capture first; only that tab’s next matching host-frame request gets its webview frame, with a 10s stale-arm timeout and fast-fail PreviewRecordingArmConflictError when two tabs contend. The renderer calls getDisplayMedia only after main process runs executeJavaScript on DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER, and serializes the arm-to-capture handoff while allowing multiple active recorders once streams are acquired.

Contract and IPC: startScreencast / startRecording now return void; DesktopPreviewRecordingSource and size-unavailable errors are removed in favor of arm/capture errors.

Compositor / throttling: Frame capture tracks per-guest setBackgroundThrottling, restores it on stop/replace, and parks capture-active hidden webviews at (0,0) behind the app so Electron still composites. On macOS, inactive guests can stay visibility: visible offscreen via keepPaintableWhenInactive to avoid Electron 43 blanking, without treating them as actively rendering for automation.

Renderer recording queues display-media grants, supports cancelling starts before grant (BrowserRecordingStartCancelledError), and suppresses error toasts for those cancellations in the preview UI.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0e6eefb7c1e1de2e377f439019af1d053c6e20a1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix recording capture flow and macOS rendering after Electron 43

  • Replaces the legacy getUserMedia and chromeMediaSource flow with navigator.mediaDevices.getDisplayMedia, coordinating capture starts via an armed pendingRecording slot and a renderer gesture trigger (DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER).
  • Adds per-WebContents background throttling control during frame capture, disabling it on active tabs and restoring it when capture stops.
  • Keeps inactive webviews paintable on macOS by passing keepPaintableWhenInactive to resolveHostedBrowserWebviewWrapperStyle based on isMacPlatform.
  • Risk: DesktopPreviewBridge.recording.startScreencast now returns void instead of DesktopPreviewRecordingSource; consumers must rely on in-renderer capture initiation and BrowserRecordingStartCancelledError for pre-grant cancellations.
Macroscope summarized 0e6eefb.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a broad Electron 43 compatibility migration spanning desktop capture routing, renderer media acquisition, IPC contracts, throttling, asynchronous lifecycle handling, and macOS compositing. It changes existing production behavior and introduces substantial cross-process coordination, so the interaction and resource-management paths warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b8e5193ec9c7a86d7e2ffd80337966f3b64027f5. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. [gpt-5.6-sol] RESPONDING ON BEHALF OF WOUT:


      Linux verification for 7fe685e8e:

      • Built the production x64 AppImage from this commit.
      • Verified the packaged runtime reports Electron 43.4.1 and Chromium 150.0.7871.224.
      • Launched it under Xvfb with isolated state, recorded a moving local browser preview, and stopped through the desktop UI.
      • T3 Code saved a valid AV1 WebM at 842x700; the video below shows the active recording state and the final Recording saved confirmation.

      https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/305c964e-1c83-4bdd-a634-f32f34d2e80c/pr9001-linux-electron43-recording-proof.mp4

    5. StiensWout(GitHub profile, opens in a new tab)commented

      [gpt-5.6-sol] RESPONDING ON BEHALF OF WOUT:


      Superseded: the earlier proof exposed the remaining bug. Thread A’s saved video repeated its last composited frame while the thread was hidden, even though the recording control stayed active.

      The PR now keeps capture-active guests composited and unthrottled. This is the current Thread A proof from 0e6eefb7c: 23.77 seconds, 713 constant-rate H.264 frames, and no detected frozen span longer than 134 ms.

      https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/5c8ffafb-a77c-4e43-a213-d4f8c150b906/pr9001-thread-a-background-recording-playback.mp4

      Additional proof:

      While B was foregrounded and both tabs were recording, A advanced 63 interval ticks and 371 animation frames over 6.22 seconds. Its app-saved 23.75-second WebM contains 712 frames that continue through the hidden interval.

    6. juliusmarminge merged thisef7014d

    7. juliusmarminge closed this

Sign in to join this conversation.