Skip to content

refactor(ios-runner): drop the XCTest tap fallback on simulators - #5354

Open
thymikee wants to merge 4 commits into
mainfrom
perf/ios-sim-hid-tap-no-fallback
Open

thymikee wants to merge 4 commits into
mainfrom
perf/ios-sim-hid-tap-no-fallback

Conversation

@thymikee

@thymikee thymikee commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

A simulator tap is only its touchscreen HID contact (#5350). When that contact cannot be prepared or never goes down, the tap answers UNSUPPORTED_OPERATION with the HID reason and one shared hint (restart the simulator, then rebuild the runner), and sends nothing: no XCTest event record, no xctest-coordinate-tap fallback. The refusal is a typed RunnerGestureRefusedWithoutFallback that performSynthesizedGesture (and alert activation) answers before any fallback policy. Physical devices keep the XCTest record and its fallback. ADR 0011's simulator amendment is updated.

Consequence: on a simulator whose display size is unreadable (#4091), a portrait tap now refuses instead of dispatching through the XCTest record.

Value

  • Simulator tap routes: 2 (HID, XCTest record) → 1.
  • XCTest tap-synthesis stubs in unit tests: 4 → 0; tests stub RunnerSimulatorTouch preparation and a recording prepared touch instead.
  • Cross-app check before this change: 333/333 taps took the HID route, 0 unavailable.

Validation

At 7314eaa, on a fresh iPhone 17 Pro iOS 27.0 simulator: pnpm build:xcuitest:ios with unit tests, then xcodebuild test-without-building for the 47 tests that use the changed stubs (all of RunnerRequestPanelTests, SynthesizedTapContextTests, and the reworked alert, command, sequence and #4091 tests): Executed 47 tests, with 1 test skipped and 0 failures (the skip is the host-dependent placed-window case). CI owns the remaining gates.

🤖 Generated with Claude Code


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.77 MB 6.78 MB +810 B
Package (unpacked) 6.77 MB 6.77 MB +810 B
Package (download) 2.07 MB 2.07 MB +165 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 29.0 ms 30.5 ms +1.5 ms
CLI --help 54.0 ms 59.3 ms +5.3 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 1f857e8. The verdict and the full list are in the summary comment.

@thymikee

thymikee commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

The code at 1f857e8 looks correct, and all 23 checks pass at that head, including the runner unit tests on iOS simulator destinations. No conflicts are known. Live evidence at this head is still missing, so this is not ready to merge yet.

Not verified here: whether SpringBoard-owned system alert windows (passed as resolvedWindow) resolve a display ID and touchscreen sender on every supported runtime. On base, those taps fell back to the XCTest record. Now they refuse. Not verified here: how often RunnerSimulatorTouch.prepare fails on supported simulators, and the 333/333 cross-app figure has no artifact attached. The 47-test simulator run was at 7314eaa, and 1f857e8 adds the Alert.swift refusal catch. Please run a tap on a system alert button on a simulator at this head. The output should show either the HID dispatch succeeding or UNSUPPORTED_OPERATION with zero coordinate taps. Please attach it.

Not blocking, take or leave: (1) the no-fallback rule lives in a thrown error raised only inside simulatorHIDTap. Pre-dispatch refusals from pointGestureTarget (SynthesizedInteraction.swift:97-98) return .unsupported, and with a readable tree the caller still runs the XCUICoordinate tap. On a #4091 simulator, a portrait tap refuses but a landscape tap goes through XCUICoordinate. Either state the rule in the policy owner or narrow the ADR sentence to the HID-preparation case. (2) The refusal hint at RunnerTests+SynthesizedInteraction.swift:651 always says to retry after foregrounding the app, which does not help a broken simulator runtime. A restart-the-simulator or rebuild-the-runner hint fits those reasons. (3) That hint text duplicates RunnerTests+ScreenEdgeGesture.swift:46, so one shared hint would do. (4) The "contact never went down" branch at RunnerTests+SynthesizedInteraction.swift:641 has no test. One case with a prepared touch that returns a message and touchDown false would cover it.

Simplicity question: under #if targetEnvironment(simulator), could SynthesizedGesturePolicyKind.coordinateTap.allowsXCTestCoordinateFallback return false, with simulatorHIDTap returning .unsupported(message, hint) for prepare and no-touch-down failures? Then RunnerGestureRefusedWithoutFallback and its catches in performSynthesizedGesture and activateAlertButton could go. One rule in the owner would cover HID failures and pointGestureTarget refusals alike, and the ADR sentence would become true.

thymikee and others added 4 commits December 3, 2026 13:35
A simulator tap is now only its touchscreen HID contact. A contact that
cannot be prepared, or never goes down, throws
RunnerGestureRefusedWithoutFallback: performSynthesizedGesture answers it
as an UNSUPPORTED_OPERATION refusal with the HID reason and a hint, and no
XCTest event record or XCUICoordinate tap runs in its place. Physical
devices keep the XCTest record and its fallback.

The unit tests stub RunnerSimulatorTouch preparation and the lit-panel
probe's prepared touch instead of XCTest tap synthesis, and the tests that
asserted an XCTest fallback on a simulator now assert the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the ADR wording

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tact that never went down

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the perf/ios-sim-hid-tap-no-fallback branch from 1f857e8 to 16489d4 Compare December 3, 2026 12:35
@thymikee

thymikee commented Dec 3, 2026 •

Copy link
Copy Markdown
Member Author

Live evidence at 16489d4 (this PR's head, rebased on current main), iPhone 18 Pro, iOS 27.0 simulator, runner built from this head and passed with --ios-xctestrun-file. Maps shows its "Enable Notifications" prompt. Pressing it raises the SpringBoard-owned alert "“Maps” Would Like to Send You Notifications". Pressing the alert's Allow button dispatches through the HID contact (outcome=performed, second pair of log lines) and the alert closes. No coordinate tap ran.

$ agent-device press @e7 (Enable Notifications)
Tapped @e7 (201, 748)

$ agent-device snapshot -i
Page: com.apple.Maps
App: com.apple.Maps
Snapshot: 5 nodes
Simulator AX snapshot unavailable (foreground-owner-unverified); used XCTest for this capture, while another surface owned the foreground.
@e1 [alert] "“Maps” Would Like to Send You Notifications"
@e2 [button] "Don’t Allow"
@e3 [button] "Allow"
@e4 [text] [same label as parent]
@e5 [text] "Notifications may include alerts, sounds, and icon badges. These can be configured in Settings."

$ agent-device press @e3 (Allow, SpringBoard alert button)
Tapped @e3 (275, 518)

$ agent-device snapshot -i
Page: com.apple.Maps
App: com.apple.Maps
Snapshot: 55 visible nodes
(...trimmed)
@e1 [application] "Maps"
@e2 [window] "Maps.Application.Standard"

--- runner log (simctl log stream, filtered) ---
2026-12-03 13:36:01.474 AGENT_DEVICE_RUNNER_SIMULATOR_TOUCHSCREEN display=1 registryID=778835616971358216 Transport=<missing> Product=<missing> Built-In=1 displayUUID=6C802DE6-7770-476D-8257-24DD4DB76CBA
2026-12-03 13:36:01.535 AGENT_DEVICE_RUNNER_SIMULATOR_HID_TAP outcome=performed prepareMs=5.0 dispatchMs=60.1
2026-12-03 13:36:08.667 AGENT_DEVICE_RUNNER_SIMULATOR_TOUCHSCREEN display=1 registryID=778835616971358216 Transport=<missing> Product=<missing> Built-In=1 displayUUID=6C802DE6-7770-476D-8257-24DD4DB76CBA
2026-12-03 13:36:08.719 AGENT_DEVICE_RUNNER_SIMULATOR_HID_TAP outcome=performed prepareMs=3.4 dispatchMs=51.9

Changes for the review items:

  • Item 4: the "contact never went down" branch has a test. testSelectorTapRefusesWithoutAnXCTestCoordinateWhenThePreparedContactNeverWentDown prepares a touch whose dispatchTap returns a message with touchDown false. The tap answers UNSUPPORTED_OPERATION with the HID message and hint, and observeCoordinateTaps counts 0 coordinate taps. It shares its body with the existing prepare-failure test.
  • Items 2 and 3: the refusal hint is now one constant, simulatorHIDRefusalHint ("Restart the simulator. If the failure persists, rebuild the runner."). simulatorHIDTapRefusal and prepareScreenEdgeTouch both use it.
  • Item 1 and the simplicity question are done in refactor(ios-runner): drop the XCTest coordinate gesture fallback #5359: it removes RunnerGestureRefusedWithoutFallback and the coordinate fallback rule entirely, so pointGestureTarget refusals and HID failures follow one rule. The shared hint carries through its rename to RunnerGestureNotSent.

Tests passed on this change before the clean rebase onto main (the live run above used the rebased head): the new test, the prepare-failure selector tap, alert activation refusal and synthesized sequence tap refusal tests. pnpm check:native-dupes passed.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 16489d4

Since the review of 1f857e8: 0 new · 0 still open · 1 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (64dd30eae755).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

This branch has not been deployed

No deployments
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