perf(server): streamed browser tabs show about 50 fps instead of 25 #19462
main fromrefs/pull/19462/head·opened View on GitHubProblem#
A browser tab that reaches the app as a stream shows about 25 fps while the page animates or scrolls at 60 Hz. That covers the web client and mobile viewers, plus desktop tabs for environments the desktop did not launch, such as WSL or a remote Linux server. This is the stream-rate part of #17090.
The server acks each screencast frame 100 ms after it arrives (SCREENCAST_ACK_PACE_MS), and Chromium keeps only three unacked frames by default. That caps a viewer at three frames per 100 ms. Once the 60 Hz frame timing is added, the result is about 25 fps. The comment next to the constant expected "near 30 fps".
To reproduce: open the web client, open Browser in a thread's right panel, load any page that animates (the test page used below moves a bar every frame), and count the frames drawn on the panel's canvas.
Change#
attachViewer now passes maxFramesInFlight: 6 to Page.startScreencast, so six frames can wait for their ack. The 100 ms ack pacing, the reduced-quality frames while scrolling, the settle still and the viewer's backpressure are unchanged.
- Chromium only sends screencast frames when the page repaints, so a still page sends none before or after this change.
maxFramesInFlightis in Chrome 154, the versionPreviewBrowserpins (154.0.8037.92). Playwright's protocol types predate it, so the parameters are built in a variable instead of an object literal.- An older Chromium that lacks the parameter ignores it and keeps its default. I checked this with Playwright's headless shell build 1223.
Scope and approval#
#17090 has no maintainer triage yet, so this is submitted as a small, focused fix. One parameter changes, it is covered by a test, and it fixes a frame cap that falls below what the code's own comment expects.
- In scope: the viewer stream's frames-in-flight limit only.
- Out of scope: the rest of #17090 (GPU flags,
--force-device-scale-factor=2and the native webview for WSL), recording frame rate (#19442) and picture-in-picture (#19163). - A maintainer call: six is my choice, not a measured optimum. It roughly doubles the rate and the bandwidth while a page moves. If you would rather have a lower ceiling, four or five works the same way at a lower rate. The idea comes from @Luzivog's measurements on #17090, which used ten.
Verification#
In the app#
I ran the dev server with main's ServerBrowser.ts, then with this branch, and used the same headless Chromium client both times. The client opened Browser in a thread, loaded the animated test page, and counted the frames drawn on the panel's canvas over three 5-second windows (script).
| Server | Frames drawn per second | Median gap | 95th percentile gap |
|---|---|---|---|
main | 25.8, 25.8, 25.6 | 17–34 ms | 68–85 ms |
| This PR | 51.4, 51.4, 51.4 | 16.8 ms | 34 ms |
The screenshot shows the test running in the app. A still frame looks the same before and after, so the frame rate is in the table. The before screenshot is also uploaded.
The median observed app rate rises from 25.8 to 51.4 fps: +25.6 fps, approximately 99%, for this animated page. The 95th-percentile frame gap falls from 68–85 ms to 34 ms. These are three short windows on one machine, not a distribution across devices or networks.
Motion recording#
Watch the 16-second before/after recording · Raw capture results
The recording shows two eight-second captures of the actual web client's Browser panel on the same animated test page. The baseline uses this branch with only maxFramesInFlight omitted (Chromium's default window); the second uses the six-frame window. Both retain the 100 ms stream ACK pacing. This capture measured 201 canvas draws in 8.001 seconds (25.1/s) before and 413 in 8.001 seconds (51.6/s) after, consistent with the earlier three-window comparison. These are additional short runs, not a device-wide performance estimate.
Environment: macOS arm64, pinned Chrome for Testing headless shell 154.0.8037.92, isolated dev state. The recording crops out the sidebar and hides an unrelated provider-update notification. Captions show the measured capture mean. Outer-browser CDP frames were recorded with immediate ACKs, their timing preserved, and the MP4 encoded at 60 fps by repeating frames as necessary; no motion interpolation was applied. The video is visual evidence of the viewer stream, while the canvas-draw counts are the throughput measurement. The PR implementation was restored after the baseline capture, and the worktree is clean.
Cost, measured directly against Chrome 154#
This benchmark launches the pinned Chrome with the server's launch flags, sends the same screencast parameters as the viewer (JPEG quality 70, 1280×800) and acks each frame 100 ms after it arrives. Each run uses a fresh tab and lasts 8 seconds (raw results).
| Page | Default: fps / Chrome CPU / MB/s | Six in flight: fps / Chrome CPU / MB/s |
|---|---|---|
| Animated canvas | 25.9 / 0.96 cores / 0.28 | 51.6 / 1.04 cores / 0.56 |
| Scrolling list | 25.7 / 0.71 cores / 1.84 | 51.3 / 0.80 cores / 3.66 |
| Still page | 0 / 0 / 0 | 0 / 0 / 0 |
In this fixture, animated-canvas Chrome CPU rises from 0.96 to 1.04 cores (approximately 8%), and scrolling-list CPU rises from 0.71 to 0.80 cores (approximately 13%). Encoded frame traffic rises from 0.28 to 0.56 MB/s for the canvas and 1.84 to 3.66 MB/s for scrolling (approximately 2×). The still-page observation was zero streamed frames during the measurement window; this does not claim zero total browser CPU or memory usage. The server's own per-frame work (base64 decode and the WebSocket send) also doubles while a page moves. I did not measure that separately.
The viewer stops and restarts the screencast whenever scrolling starts and settles, so I checked that the limit survives a restart. Over four stop-and-start cycles at alternating scales, the stream stayed at 51 fps with six in flight and 25.5–26 fps without (script).
Observable browser regression and scoped checks#
ServerBrowser.test.tsretains the mocked viewer-start assertion as a wiring check. That assertion alone cannot prove Chromium supports or obeys the parameter.ServerBrowserScreencast.test.tsuses the app-pinned Chrome for Testing headless shell (154.0.8037.92 on this macOS arm64 run). SixPage.screencastFrameevents arrive without ACKs, remain capped while the page paints 30 more frames, then one additional event arrives after each of three ACKs. The test caches the pinned browser in the worktree.t3/screencast-testdirectory, installing it if absent.- The browser test checks the exact
Browser.getVersionresponse against the app pin, so a different installed browser cannot silently stand in for Chrome 154. It observes actual CDP frame delivery, rather than a fakesendaccepting an object literal. A browser that ignores the limit would stop at the default window and fail to deliver the requested six frames.
Verification on f0b469f7cbc11419255a804eab147eb46dc5aaf8:
vp test run apps/server/src/preview/ServerBrowser.test.ts apps/server/src/preview/ServerBrowserScreencast.test.ts
vp run --filter t3 typecheck
vp lint apps/server/src/preview/ServerBrowser.test.ts apps/server/src/preview/ServerBrowserScreencast.test.ts
The two focused files pass: 37 tests. Server typecheck, targeted lint, formatting, and diff checks pass. The protocol regression establishes the in-flight/ACK behavior; the separately uploaded app measurements establish the observed throughput. The browser test does not assert that every viewer must sustain 50 fps under arbitrary load.
Not checked#
- I measured on macOS (Apple Silicon). I did not run it on WSL or a remote Linux server, or over T3 Connect, where the doubled bandwidth matters most.
- I did not test a mobile viewer.
- Six is a measured working choice, not a demonstrated optimum. More frames and bytes can increase load on the server, relay, and viewer. Server CPU, process memory, and slow-link end-to-end latency were not separately measured.
Review, verification analysis, and PR description prepared with OpenAI Codex (GPT-6.1 Sol) in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — The PR changes the default streaming behavior for all server browser viewers, allowing roughly twice as many in-flight frames and correspondingly increasing active-page CPU, bandwidth, and server frame work. The change is focused and tested, but the unconditional product-default and resource-impact changes warrant human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).💡 Codex Review#
Here are some automated review suggestions for this pull request.
Reviewed commit:
a435cde4e2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@@ -492,3 +492,12 @@492492 ).pipe(Effect.provide(layer)),493493 );494494495+it.live("lets six screencast frames wait for their ack, twice Chromium's default", () =>496+ Effect.scoped(497+ Effect.gen(function* () {498+ const { browser, tabId } = yield* ready;499+ yield* browser.attachViewer(viewerInput(tabId, false));500+ const session = contexts[0]!.sessions.at(-1)!;501+ expect(session.send).toHaveBeenCalledWith(502+ "Page.startScreencast",503+ expect.objectContaining({ format: "jpeg", quality: 70, maxFramesInFlight: 6 }),Verify the frame window through observable behavior
The fake
makeSession().sendblindly resolves every command and never emits aPage.screencastFrame, so this test only mirrors the new object literal. It will remain green if the pinned browser ignores or rejectsmaxFramesInFlight, or if a later browser bump changes its semantics, even though the user-visible throughput does not improve; replace it with a focused browser-level test that counts delivered frames across acknowledgements.AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
Note
GPT-6 Luna is responding on behalf of Luke.
I added a browser-level regression test using T3's pinned Chrome for Testing headless shell. On this macOS arm64 run,
Browser.getVersionreported Chrome 154.0.8037.92. The test observed six screencast frames with no ACKs, confirmed the count stayed at six through 30 more page paints, then observed one additional frame after each of three ACKs. The separateServerBrowser.test.tscheck still verifies the server requestsmaxFramesInFlight: 6.ServerBrowser.test.tsandServerBrowserScreencast.test.tspass (37 tests); the server typecheck, targeted lint, formatting, and diff checks pass. This run exercised the macOS arm64 pinned browser; other platform binaries were not run here. The test caches the browser under the worktree's.t3/screencast-test, installing it there on first run if needed.No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
08acb808-c1e0-4913-ae50-1210a85e8cce
📥 Commits
-
Reviewing files that changed from the base of the PR and between a435cde4e27bdee0d54c844f764f4f1aec55b92c and f0b469f7cbc11419255a804eab147eb46dc5aaf8.
📒 Files selected for processing: 2
-
apps/server/src/preview/ServerBrowser.test.tsapps/server/src/preview/ServerBrowserScreencast.test.ts
🚧 Files skipped from review as they are similar to previous changes: 1
-
- apps/server/src/preview/ServerBrowser.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
-
📝 Walkthrough
-
Viewer screencasts now set Chromium’s
maxFramesInFlightto 6. The 100 ms acknowledgement pace remains unchanged. Tests check the screencast options and verify frame delivery after acknowledgements.Changes: Viewer screencast configuration
Layer / File(s) Summary Configure and test screencast frames
apps/server/src/preview/ServerBrowser.ts,apps/server/src/preview/ServerBrowser.test.tsThe screencast call sets maxFramesInFlightto 6 with the existing JPEG settings and acknowledgement pace. A test checks the JPEG quality and frame limit.Verify Chromium frame acknowledgements
apps/server/src/preview/ServerBrowserScreencast.test.tsAn integration test launches the pinned Chrome executable, paints an animated canvas, and verifies that acknowledging captured frames permits additional frames. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
f0b46-
No merge-blocking issue is established for the viewer frame-limit change; it is ready for normal merge checks.
Security architecture risk: 🔵 Low · up to
a435c-
The change permits more work for active browser streams while preserving existing access checks, buffering limits and disconnect cleanup. No new security boundary violation was identified, but aggregate resource impact has not been independently established.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The changed exposure is increased frame concurrency and potential processing and network work for existing active viewers on the server and its browser process. The parameter remains server-controlled and does not select another page, data store or credential context. Per-viewer bounds remain, but they do not establish an aggregate concurrent-viewer resource budget.
Trust Boundaries and Controls
- observed — The existing WebSocket path authenticates orchestration-read scope and derives mutation authority separately from preview-operate scope. Viewer-supplied dimensions and quality are capped. The attachment retains its read-only gate and controller checks; the PR does not change these controls or the captured tab identity.
Resilience and Maintainability Implications
- observed — Failure-containment mechanisms remain unchanged: the output queue drops beyond 64 items, transport handling disconnects viewers exceeding its write or outstanding-acknowledgement limits, and scoped release stops and detaches the CDP session. Capture operations serialize through a lock, pause screencasts and resume them in a finally block; viewer cleanup removes ownership and membership, and clears the settle timer.
-
Pre-merge checks:
4-
Passed checks: 4 passed-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title is concise, uses conventional commit syntax, and accurately states the main performance change from about 25 fps to about 50 fps for streamed browser tabs. Description check The description fully covers the required Problem, Change, Scope and approval, and Verification sections. It provides reproduction steps, implementation details, scope rationale, focused test results,…
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Note
Written by
gpt-6.1-solon behalf of MariaThanks for measuring the viewer stream in the app. Raising the frames-in-flight limit from three to six changes the default frame rate and roughly doubles bandwidth while a page moves, which needs prior approval. The PR says #17090 has not received maintainer triage and that six is a contributor-chosen ceiling. Please bring these measurements to that issue or an Ideas discussion and obtain approval for the target rate and bandwidth tradeoff before requesting reconsideration.
maria-rcks closed this
Note
Written by
gpt-6.1-solon behalf of Luke@maria-rcks Understood. The default frame-rate and bandwidth trade-off needs maintainer approval. I'll leave this closed.
Sign in to join this conversation.
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
a435cdeℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.