Skip to content

App freezes and crashes under heavy parallel session load #336

@btessiau

Description

@btessiau

Problem

When running many CLI sessions in parallel (5+), the app progressively freezes and eventually becomes unresponsive.

Root Causes

1. Render flood overwhelms WebKit

Each parallel session fires OnStateChanged on every SDK event (tool start, phase change, turn start). With N sessions doing tool calls, the WebView's WebContent process gets starved — macOS logs show hundreds of WebProcess::updateFreezerStatus: isFreezable=1, error=-1 errors.

High-frequency event paths that trigger re-renders:

  • ToolExecutionStartEvent → phase change to Working
  • AssistantTurnStartEvent → phase change to Thinking
  • ToolExecutionCompleteEvent → permission denial check
  • WsBridgeClient.OnStateChanged → remote session sync

2. Process handle leaks

ServerManager.StartServerAsync and StopServer never dispose Process objects. OS handles accumulate across reconnect cycles. The SDK's StartCliServerAsync also leaks — crash log shows 468+ "No process is associated" unobserved exceptions from accessing Process.HasExited on GC'd handles.

3. Connection reset cascade

Under heavy load, the persistent copilot server drops connections (414 "Connection reset by peer" entries in crash log). Amplified by process handle exhaustion.

Evidence from crash.log

  • 468 × No process is associated with this object (process leak)
  • 414 × Connection reset by peer (server overwhelm)
  • 241 × updateFreezerStatus in macOS system logs (WebKit freeze)

Fix

  • Coalesce high-frequency OnStateChanged events with 150ms timer
  • Dispose Process handles in ServerManager and DevTunnelService

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions