Skip to content

perf(ios): detect a presented system surface from the bridge via AX hit test, replacing the host-side process probe #2485

Open

Description

@thymikee

Purpose

Decide "is a registered system-surface host presenting over this app" by presentation, not process liveness, so a host that lingers after dismissal stops routing every capture to the slow XCTest runner.

Status since this issue was written

The design was accepted (2026-10-09 Decision: comment, comment 6077564899) and the host-side probe was deleted: #4172 (8c416a75, released v0.21.37) removed packages/platform-apple/src/system-surface-presence.ts and moved the check guest-side — the route names host executables in the bridge request (packages/capture-kit/src/snapshot-router/router.ts:274) and the bridge reads the process table with sysctl (apple/snapshot-bridge/SnapshotBridgeSurfaceHosts.m), refusing system-surface-host-present.

The false positive this issue owns is still there. The shipped check is still a liveness check, just inside the bridge: the router still distinguishes system-surface-host-lingering for a host that outlives its dismissal (router.ts:58,567), processExecutable is still in contracts/fixtures/ios-system-surface-hosts.json:7,13, and no applicationAtCoordinate: hit test exists anywhere in apple/. The bonus also remains: createLaunchObservationProbe calls source.acquire directly and sends no host list (packages/platform-apple/src/snapshot-observability.ts:116), so launch observation still reports observable off an occluded tree.

Required behavior

Re-aimed at the shipped bridge path, verified against origin/main 3c68c19ed3:

  1. Replace the sysctl process-table check in apple/snapshot-bridge/SnapshotBridgeSurfaceHosts.m with a presentation test, keeping respondsToSelector: guards and a typed failure when the private selector is absent, as apple/snapshot-bridge/SnapshotBridgeRuntime.m already does elsewhere.
  2. Refuse with the existing system-surface-presented disposition instead of system-surface-host-present when a registered host is presenting (packages/capture-kit/src/snapshot-router/refusal-policy.ts:109), and stop emitting system-surface-host-lingering (router.ts:58,567) once presentation, not liveness, decides the route.
  3. Drop processExecutable from contracts/fixtures/ios-system-surface-hosts.json and both parity consumers once nothing matches on it, keeping the bundle-id registry the Swift runner uses.
  4. Have the launch-observation probe take the same answer by routing through the code path that sends surfaceHostExecutables (packages/platform-apple/src/snapshot-observability.ts:116), so an occluded tree can no longer read observable.
  5. Verify absent, presented, and dismissed-but-lingering through the production bridge on a real sheet, not a unit seam, and keep both refusals out of the bridge circuit's disable path.

Per the accepted decision: one hit test at the centre detects a sheet but does not establish general foreground ownership (see #2696); do not present it as one.

Completion

The lingering-host false positive is gone; the routed refusals name presentation; processExecutable is deleted; live-validated through the production bridge on a real sheet, including the dismissed-but-lingering case.

Activity

  1. thymikee commented on Oct 9, 2026

    @thymikee
    MemberAuthor

    Decision: accepted. system-surface-presence.ts checks whether a process is running and caches positive results, so it can't tell a host process that's still around from a sheet that's actually presented. The issue's presented and dismissed controls show this.

    Scope:

  2. thymikee commented on Nov 23, 2026

    @thymikee
    MemberAuthor

    Current state: body rewritten against origin/main 3c68c19 (2026-11-23 maintainer sweep, T105). The host-side pgrep/ps probe was deleted by #4172 (v0.21.37) and replaced by a sysctl liveness check inside the bridge guest, so the lingering-host false positive this issue owns survives; the contract is re-aimed at the shipped bridge path and the still-missing hit test, and the launch-observation gap is kept.
    Previous body is preserved at the issue's edit history (the Edited marker in the header) and archived locally; no copy is republished here.

  3. apex-sentinel-staging commented on Nov 23, 2026

    @apex-sentinel-staging

    Apex Sentinel · Issue review

    Suggested label: bug

    The issue reports a concrete existing false-positive: a lingering iOS system-surface host is still detected via a sysctl process-table/liveness check and routed incorrectly/slowly, and it specifies the presentation-based hit-test fix with code references. It is actionable as written, despite containing detailed implementation notes and references that should be treated as data.

    Required sections

    • Steps to reproduce (missing)
    • Expected and actual behavior (missing)
    • Version or environment (missing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions