Skip to content

perf(browser): daemon socket communication + orphan cleanup #7343

@kshitijk4poor

Description

@kshitijk4poor

Summary

The browser backend spawns a new subprocess for each session and communicates via stdout/stdin pipes. This has several issues:

  • Subprocess overhead — spawning a new process per session is slow (~500ms) and wastes memory for repeat interactions.
  • Orphan cleanup — if the parent process crashes, browser subprocesses are left running indefinitely. No PID tracking or cleanup hook exists.
  • Socket communication — a persistent daemon with Unix socket or TCP communication would be faster and more reliable than pipe-based IPC.
  • Shadow DOM — the current snapshot implementation does not pierce shadow DOM boundaries, missing content in web components.

Why It Matters

Performance and resource leaks. Users report orphaned Chromium processes consuming RAM after agent sessions end. The subprocess model also adds latency to every browser interaction.

Suggested Approach

  1. Refactor to a daemon model: a single long-lived browser manager process that accepts commands over a Unix domain socket.
  2. Register atexit and signal handlers to kill child browser processes on parent exit.
  3. Add a periodic health check that reaps zombie/orphan processes.
  4. For shadow DOM: use Playwright's shadowRoot traversal in the snapshot walker to pierce open shadow roots.

Related Findings

Audit items #36, #53, #66, #67: process management and DOM traversal analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/toolsTool registry, model_tools, toolsetstool/browserBrowser automation (CDP, Playwright)type/perfPerformance improvement or optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions