You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web-server): pace sidebar screencast acks and skip duplicate frames - #1309
…plicate frames
Chrome re-captures and re-encodes after every screencast acknowledgement, so a
fully static page kept the headless browser, the relay and the viewer decoding
loop busy at full frame rate. Identical pictures are no longer re-delivered to
viewers, and acknowledgements back off (capped at 500ms) while consecutive
frames are unchanged; fresh input or a changed picture resumes the base pace.
The change reduces work for static sidebar pages, but some paths still ACK too often or skip backoff, and a throttled frame can leave the viewer on an older picture until the page changes again. These are minor issues worth fixing before merge. No severe failure is indicated.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Applicability reference: AGENTS.md: # Repository Guidelines `npm start` / `npm start web` rebuild and relaunch the user's Desktop / Web and may restart the shared Host; `npm stop` stops all local codexhost services across worktrees.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复侧栏浏览器在页面完全静止时仍满帧率截帧投屏的问题(200%+ CPU)。根因:CDP
Page.startScreencast下 Chrome 在每次收到Page.screencastFrameAck后都会重新截帧并编码,服务端按 30fps 固定节奏回执 ACK,且对内容完全相同的帧也无条件投递,导致无头 Chrome 持续 PNG 编码、Node 中转持续转发、前端 WebKit 逐帧createImageBitmap+ PNG 解码的闭环满载。改动(packages/web-server,最小修复):
sidebar-browser-cast.ts:sample()返回是否真正做了前后帧比较(compared);acknowledge()对内容未变化的帧做指数退避(interval 翻倍,上限 500ms),画面变化后立即恢复基础帧率;新增resetPace()。sidebar-browser-tab.ts:screencast 帧与上一帧完全相同时不再向 viewer 重复投递(前端保留上一帧,省去重复 PNG 解码);用户输入时调用resetPace()立即恢复全速,保证交互反馈延迟不受退避影响。sidebar-browser-quality.ts:PictureSample导出并增加可选compared字段。Related issues
fixes #1296
UI Demo
No visual changes: 静止页面显示内容不变,仅降低静止时的截帧/编码/解码频率。
Test plan
npx tsc -b packages/web-server/tsconfig.json --pretty false通过(范围化类型检查,仅本包依赖图)。node --import tsx --test test/sidebar-browser-quality.test.ts test/sidebar-browser-delivery.test.ts test/sidebar-browser-tab.test.ts:10 通过 0 失败。npx prettier --check与npx eslint对改动文件均通过。