Skip to content

[Bug]: Agent preview recordings hold a soft, blocky frame while the page is idle #42439

Done

Description

@markusjura

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Serve the page below, for example with python3 -m http.server.
  2. In an agent thread, preview_open it, preview_resize to freeform 1512×982, and run preview_recording_start.
  3. Run preview_evaluate("reload()"), wait 3 s, then preview_recording_stop.
  4. Compare the last frame of the recording with a preview_snapshot of the page.
<body style="margin:0;background:#111;color:#ddd;font:14px system-ui">
<div id="t"></div>
<script>
  const rows = (cell) => Array.from({ length: 30 }, (_, i) =>
    `<div style="display:flex;gap:24px;align-items:center;height:30px;padding:0 32px;border-bottom:1px solid #222">${cell(i)}</div>`).join("");
  const content = () => (t.innerHTML = rows((i) =>
    `<span style="width:320px">Row ${i + 1}</span>
     <div style="width:260px;height:8px;border-radius:4px;background:#2a2a2a">
       <div style="width:${(i * 37) % 100}%;height:100%;border-radius:4px;background:hsl(${[20, 210, 280, 140][i % 4]} 80% 55%)"></div>
     </div>
     <span>${(i * 0.173 + 1).toFixed(2)}e-9</span>`));
  // Swaps the table for a skeleton, then back, like a page that loads its data.
  window.reload = () => { t.innerHTML = rows(() => '<div style="width:600px;height:10px;border-radius:5px;background:#222"></div>'); setTimeout(content, 300); };
  content();
</script>

Expected behavior

While the page is idle, the recording shows it as sharp as the snapshot.

Actual behavior

The frame after the reload is soft and blocky, with smeared edges and washed-out colors, and it stays on screen until the page changes again. The first frame after preview_recording_start is soft in the same way.

The 5 s recording has 6 frames at 0.23 Mbit/s. Against the 3024×1964 snapshot, the frame held after the reload measures 37.6 dB PSNR. With a 1 px element repainting every frame, the recording has 148 frames and the same frame measures 45.0 dB.

The cause, from main @ 68d6ef6:

  • recordingCompositor.ts draws the canvas only when the tab sends a new frame or an input indicator changes, so canvas.captureStream() only produces frames while the page changes.
  • createMediaRecorder sets the bitrate for a steady frame rate: 8.9 Mbit/s at 3024×1964 and 30 fps, about 37 KB per frame. A full repaint gets roughly one frame's share, and no later frame refines it.

Redrawing the last frame at the recording frame rate while the page is idle would let the encoder sharpen it. #24979 lists the same idea for the server browser path.

Impact

Minor bug or occasional failure

Version or commit

0.1.11 (Beta). The recording code is unchanged on main @ 68d6ef6.

Environment

macOS 27.0.1, Apple M4 Max, T3 Code (Beta) desktop app 0.1.11, Electron 44.10.1

Logs or stack traces

No response

Screenshots, recordings, or supporting files

Held frame from the repro, idle versus repainting every frame

Workaround

Keep the page repainting while recording, for example by running this before preview_recording_start:

const px = document.body.appendChild(document.createElement('div'));
px.style.cssText = 'position:fixed;right:0;bottom:0;width:1px;height:1px;pointer-events:none';
let k = 0;
(function tick() { px.style.background = k++ % 2 ? '#0001' : '#0002'; requestAnimationFrame(tick); })();

It raises the repro's bitrate from 0.23 to 0.82 Mbit/s.

Activity

  1. added
    bug
    needs-triage
    on Nov 24, 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

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions