Skip to content

Stop iOS simulator tests stalling in CI - #917

Open
sambitcreate wants to merge 4 commits into
mainfrom
fix/ios-test-isolation
Open

sambitcreate wants to merge 4 commits into
mainfrom
fix/ios-test-isolation

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

The blocking iOS build and simulator tests job has been failing or hanging on main and on PRs that touch no iOS code. This PR fixes the two causes found. It changes the CI harness and one test fixture. No product code changes.

What failed

Each run failed a different test. In every case that test had stalled for minutes, though it takes well under a second locally:

Run Job Test Duration Failure
main b2b5c35, 45266448643 138014789163 AidenChatTests.testUploadCleanupRevocationDoesNotDeadlockRemoval 228 s then xcodebuild crashed (IDERunOperation), no result bundle
#904, 45340108118 138251852553 same revocation test 596 s job cancelled at the 50-minute limit
#900, 45336499109 none 2,512 passed, then both clones went silent for about 13 minutes until the 50-minute limit
#901, 45365235736 138345806379 AidenSandboxedHTMLTests.testAPreviewPageMakesNoNetworkConnections 193 s 30 s page load timed out
#890, 45368050792 138355678757 same SandboxedHTML test 345 s 30 s page load timed out. Clone 2 also logged a 120 s timeout connecting to com.apple.instruments.deviceservice.lockdown
#915, 45376904656 138386215673 AidenNativeIntegrationTests.testReconcileEndsAnActivityFromAnOlderPairing 128 s in-memory demo machines took about 95 s to connect, past the scheduler's 10 s probe, so laptop read offline

Also reported tonight with the same shape: AidenBrowserRecordingOwnershipTests.testPresentedPlayerSurvivesUntilDismissalThenDeletesOnlyItsFile (5 s wait for the player) and AidenChatTests.testPreparationSurvivesTheChatComposerGivingWayToAQuestionCard followed by the same IDERunOperation crash.

Root cause 1: parallel simulator clones on the hosted runner

The XCTest step ran with the scheme's parallelizable = YES, so xcodebuild booted two clones of the simulator on the 3-core, 7 GB macos-26 runner.

Fix: both iOS jobs' XCTest step now pass -parallel-testing-enabled NO and run on one simulator. The scheme keeps parallelizable = YES for local Xcode. scripts/check-ci-policy.test.mjs asserts the flag, with the reason.

Root cause 2: a held fixture request could outlive the test's release

AidenChatProgressLifecycleURLProtocol is the static URL protocol AidenChatTests share. holdNextRequest(endingIn:) arms a hold, and releaseHeldRequest() completed only a request that was already held. If the request arrived after the test's release, as a late DELETE does on a stalled host, it was still held, and nothing would release it. testUploadCleanupRevocationDoesNotDeadlockRemoval then waits on completion.value until the URLSession request timeout, and longer if cleanup retries. A slow DELETE should fail the 2 s deleteArrived wait. Instead it stalled the test for 228 to 596 s, which is how this test pushed #904 past the job limit.

Fix:

  • releaseHeldRequest() now ends the hold. It completes a request that is already held, and clears the armed path and callback, so a request that arrives later goes through.
  • AidenChatTests.setUp calls reset() after beginTestEpoch(), so no test inherits an armed hold, response override or open event stream from a test that ended early. Requests from earlier tests were already cut off by the epoch header.

The #904 fixer found that this test passed 15 of 15 times alone, even with every core pegged, and failed only partway through a CI suite. That fits: alone, the DELETE always arrives inside the 2 s window.

Local verification

Xcode 27.1 (/Applications/Xcode.app), a dedicated iPhone 17 Pro iOS 26.5 simulator, the same scheme and flags as ci.yml:

  • Serial full suite, main's tree, before these changes: 2,569 passed, 0 failed, 8 skipped, in 273 s of test time. The host's load average was about 130 from other work. The test host reached about 1.6 GB.
  • Late-DELETE experiment. This was a temporary edit, not committed: the test released its hold before the gate let the DELETE start, which is what a DELETE slower than the 2 s wait looks like. With the old releaseHeldRequest(), the test took 61.9 s and failed three ways: the forced wait, finished after 3 s, and needsPairing. The test only got past await completion.value when the URLSession request timeout fired. With the fix, it took 1.9 s and failed only the forced wait.
  • Branch, full suite twice, -parallel-testing-enabled NO: 2,569 passed, 0 failed, 8 skipped both times. Test time was 226 s and 204 s. After the second run passed, xcodebuild spent about 4.5 minutes in its own simctl diagnose collection. I stopped that by hand. It came after the tests finished, so no test was involved.
  • Previously flaky tests, 5 repetitions each, with every core pegged by yes (load average 81): all 30 passed. The tests were the revocation and purge upload-cleanup tests, the question-card preparation test, the recording-player test, testReconcileEndsAnActivityFromAnOlderPairing and testAPreviewPageMakesNoNetworkConnections.
  • New fixture test testAReleasedHoldLetsALateRequestThrough (added for Pullfrog's finding): it fails 2 of 2 on the old releaseHeldRequest(), where the request stays parked past its 5 s wait. It passes 8 of 8 on the fix, in about 0.11 s each.
  • node --test scripts/check-ci-policy.test.mjs passes 19 of 19. If the flag is removed from ios-27 alone, it fails with an ios-27: message.

Known unrelated failure

Desktop tests (renderer-other) failed on 814a19d (job 138494591179). The only failure was packages/cli/tests/server-visuals.test.mjs:172, "an installed browser draws a chart offline into a picture and leaves no profile behind", after 15.3 s. That is the known Chrome cold-start timeout. #914 fixes it on main, and this PR does not touch it.

PRs this unblocks

#890, #900, #901, #904 and #915. None of them changes iOS code. Their iOS job should pass after a merge of main, or a rerun once this lands.

Docs

docs/ci.md describes the iOS job as running on one simulator, and has a dated flake entry for 2026-11-24.

releaseHeldRequest() only completed a request that was already held. A
request that arrived after the test's release stayed held with nobody to
release it, so a slow simulator turned a 2 s wait into a stall until the
URLSession timeout. Release now ends the hold, and each AidenChatTests test
starts by resetting the fixture's holds, overrides and open stream.
Two parallel clones on the 3-core, 7 GB hosted runner took 6-9 minutes to
boot, stalled whole test processes for minutes, and sometimes never
launched, hanging the job until its 50-minute limit. The suite's summed
test time is below the clones' wall time. Both iOS jobs now pass
-parallel-testing-enabled NO.

@pullfrog pullfrog 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.

Important

The late-request race fix and the two-lane serial-execution contract need deterministic coverage before merge.

Reviewed changes across the iOS CI workflow, shared chat-test URL protocol fixture, CI policy checks, and CI documentation.

  • Serial simulator execution disables parallel unit-test clones in both the blocking Xcode 26 and non-blocking Xcode 27 jobs.
  • Late hold release atomically disarms a pending request hold while still completing a request that has already arrived.
  • Per-test fixture cleanup rotates the request epoch and resets shared holds, overrides, counters, and streams before each chat test.
  • CI policy and documentation record the hosted-runner failure mode and guard the blocking iOS lane's serial flag.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread scripts/check-ci-policy.test.mjs Resolved
A fixture test arms a hold, releases it before the request starts, and
expects the request to be answered without a second release. It fails on
the old releaseHeldRequest() and passes on the fix. The CI policy test now
checks -parallel-testing-enabled NO in the ios-27 unit run too.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review, focusing on the deterministic late-request regression coverage and the serial-execution policy for both iOS lanes.

  • Covered release-before-arrival deterministically — Added a fixture-level test that releases an armed hold before starting its request, then verifies the request completes without a second release or hold callback.
  • Guarded both simulator lanes — Extended the CI policy assertion so removing -parallel-testing-enabled NO from either ios or ios-27 fails the policy test.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

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