Skip to content

fix(macos): stop renderer injection hot loops - #310

Open
ImcLiuQian wants to merge 3 commits into
Fei-Away:mainfrom
ImcLiuQian:lt_home_panel_compat
Open

fix(macos): stop renderer injection hot loops#310
ImcLiuQian wants to merge 3 commits into
Fei-Away:mainfrom
ImcLiuQian:lt_home_panel_compat

Conversation

@ImcLiuQian

Copy link
Copy Markdown

Summary / 摘要

  • Make renderer root-class application idempotent so our own class mutation no longer re-triggers the observer hot loop.
  • Make early bootstrap a single, bounded lifecycle with explicit cleanup; avoid duplicate observers/timers across reconnects and navigation.
  • Reject auxiliary routes such as /avatar-overlay, and close the CDP socket when domain setup fails.
  • Add regression coverage for repeated injection, reconnect, navigation/renderer replacement, timeout cleanup, target filtering, and handshake failure.

Root cause / 根因

Live CDP A/B evidence confirms a Dream Skin self-triggered renderer loop: with injection enabled, the observed renderer ran ensure at about 9/s and spent about 14.1% of one core in style recalculation; after Dream Skin cleanup, style recalculation dropped to about 0.015%. An independent root/body observer saw no external class writer, while applyRootState() unconditionally rewrote the watched root class.

The historical 7.5 GiB / 200–320% CPU incident cannot be attributed solely to Dream Skin because no historical heap/socket snapshot exists. This PR fixes the confirmed Dream Skin hot loop, allocation churn, repeated bootstrap state, and handshake socket leak without claiming it was the only contributor to that high-water event.

Type / 类型

  • Bug fix / 缺陷修复

Platform / 平台

  • macOS

Self-check / 自测

  • CODEX_DREAM_SKIN_SKIP_DOCTOR=1 /bin/bash macos/tests/run-tests.sh passed
  • node macos/tests/injector-bootstrap.test.mjs — 7/7
  • node macos/tests/renderer-inject.test.mjs — passed
  • Live verify through installed loopback-CDP runtime
  • status-dream-skin-macos.sh --json --deep: session active, injector alive, CDP OK
  • Responsive smoke: 1200×900 = 2 columns; 680×900 = 1 column; no horizontal overflow

Runtime evidence / 运行时证据

A bounded 60s post-fix sample showed ensure at about 0.28/s, style recalculation about 0.32% of one core, fixed DOM/style/chrome node counts, and JS heap 374→321 MiB. Point-in-time main Renderer samples stayed far below the historical incident (roughly 6.7–16.9% CPU, 498–590 MiB RSS), but these are observations rather than a controlled long-duration baseline.

Only injector.mjs and renderer-inject.js were synced to the installed runtime for verification. Existing local CSS/theme customization was preserved; Codex itself was not restarted.

Security / 安全

  • Does not modify official Codex install / asar / signatures
  • Does not silently write API Base URL or keys
  • CDP remains loopback-oriented (127.0.0.1)

Notes / 补充

  • Exact candidate: 88d853b1a9854b4a7b34fcd78f8c81d2b8f8f269
  • Fresh independent exact-HEAD review: APPROVE, no P0–P3 findings.
  • No rebase was performed. The existing lt_home_panel_compat branch was used as requested, so this PR also contains its two earlier home-layout commits.
  • Full test without the skip flag reaches Doctor and reports the intentional source-vs-installed CSS customization difference; the test suite itself is green.

liutian added 3 commits July 20, 2026 17:43
Change-Id: I5357f5ff349f8d559a037909c63b67be0351a4d7
Change-Id: Icef8f4936e3bfcfd20fd96e3df125c605f288538
Change-Id: Ib5d2ba2f81fe69cb7290bf567eeffdba85951313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant