Fix Ghostty typing lag without owned userdata

Closed
LA
2mo ago
+199-154

Fixes https://github.com/manaflow-ai/cmux/issues/8808.

What happened

The issue was bisected to the Ghostty bump at ea51d55aa8. cmux's fork-only external iOS renderer always reacquired exact IOSurface slot zero for serial frames. Core Animation could therefore delay visible recomposition during slow or bursty typing because successive frames appeared to reuse the same surface identity. Upstream Ghostty is unaffected because it does not use cmux's external frame-lease path.

Austin Wang's https://github.com/manaflow-ai/ghostty/pull/145 fixes that root cause by rotating the serial frame slot, and Austin's already-merged https://github.com/manaflow-ai/cmux/pull/8848 correctly carries the rotation, bounded renderer, render-continuation, and terminal-input work.

What this follow-up changes

This PR keeps Austin's frame rotation and fast render path while replacing only the broader owned-userdata integration:

  • pins Ghostty at cfd39f39aaefa339a6620f124ab39ca0c478be11, the combined fork main produced by Abdulaziz Albahar's https://github.com/manaflow-ai/ghostty/pull/147
  • includes Lawrence Chen's https://github.com/manaflow-ai/ghostty/pull/146, which restores borrowed userdata, makes ghostty_surface_free finish teardown synchronously, and serializes free against cross-thread action callbacks
  • gives Ghostty a raw pointer to a minimal renderer-host UIView, not the complete terminal view
  • disables callback delivery at detach while retaining only that minimal host until the queued synchronous free returns
  • keeps render-continuation scheduling on the callback bridge that owns attachment state
  • preserves screen-anchored render-grid export, frame-slot rotation, bounded renderer scheduling, and redraw continuation delivery
  • adds regression coverage for detached bridge lifetime and stale render continuations after raw surface-address reuse

This avoids both failure modes: callbacks cannot target a detached terminal, and a wedged queued free cannot retain the complete terminal/session hierarchy indefinitely.

Artifact

The exact universal ReleaseFast framework is published at:

https://github.com/manaflow-ai/ghostty/releases/tag/xcframework-cfd39f39aaefa339a6620f124ab39ca0c478be11-crashsubdir-cmux-crash-v1

SHA-256: c958a781d4b8d1acf55fc7343858fb476aa6a766eba4e16cbe44072d1b788455

The checksum is pinned in scripts/ghosttykit-checksums.txt.

Validation

  • combined GhosttyKit build workflow passed
  • downloaded release archive checksum and structure validated
  • local universal ReleaseFast GhosttyKit build passed with Zig 0.15.2
  • clean iOS simulator app build passed against the combined pin
  • hosted GhosttyRuntimeActionTests passed 3/3 on final head b2c7fb0a0f
  • canonical autoreview exited 0 with zero findings, a clean policy gate, and a clean conflict gate
  • Greptile passed the final head at 5/5 and all actionable review threads are resolved
  • final tagged macOS app built, signed, launched, answered on its isolated lagfx3 socket, and was verified frontmost
  • package lockfile, workspace grouping, Xcode test-wiring, and diff guards passed
  • no user-facing strings changed; no localization catalog updates were required

Focused iPhone test proof: https://github.com/manaflow-ai/cmux/actions/runs/30182753042/job/89742127286

Tagged macOS build proof: https://github.com/manaflow-ai/cmux/actions/runs/30196997497

The aggregate iOS workflow remains red because package-conventions lint reports pre-existing repository-wide violations and unrelated CmuxMobileShell package tests fail in unchanged paths. The scoped iPhone job containing this PR's three regression tests passed.

The clean latest-upstream Ghostty and Zig upgrade remains a separate follow-up after this nightly correction is dogfooded.