Skip to content

ci(zbugs-swift): keep stacks when a screenshot test's UI query is stuck - #237

Merged
tmm merged 1 commit into
mainfrom
ci/zbugs-screenshots-query-stacks
Nov 18, 2026
Merged

tmm merged 1 commit into
mainfrom
ci/zbugs-screenshots-query-stacks

Conversation

@tmm

@tmm tmm commented Nov 18, 2026

Copy link
Copy Markdown
Member

On #230, the iPhone's first UI query in testListPagesPastTheFirst200 hung for 41.7 s and failed with "Failed to get matching snapshots: Timed out while evaluating UI query" (job 134463464281). Its logs don't show why. With this change, the job saves the stacks the next time a query hangs.

What it does. While each xcodebuild test runs, a watcher reads its output, which is now also tee'd to a file. When the last line is an XCTest query step (Checking, Check for, Find, Get, Requesting, Capturing) and the log has been quiet for 15 s, the watcher writes stacks/<run>-<time>/ into the zbugs-screenshots artifact. It writes once per stall:

  • spindump.txt: 5 s of stacks from the app, the UI-test runner and testmanagerd, sampled together (spindump -onlyTarget -proc …)
  • log.txt: the last 20 lines of xcodebuild's output
  • top.txt: system load and the busiest processes

Nothing else about the run changes: no retries, skips or timeouts. xcodebuild's exit status still decides the run, now through PIPESTATUS.

Why 15 s. While XCTest waits for an element, it logs a check about once a second, so a quiet log after a query step means one query is stuck. In the 18 screenshot jobs since #204, the log went quiet for 15 s or more after a query in 3 jobs:

  • 41.7 s: the failure above
  • 25.9 s (job 132998103757) and 16.0 s (job 132507395044): Check for interrupting elements steps in jobs that passed

In the other 15 jobs, the longest quiet after a query was 11.5 s. So the watcher would have fired in 3 of 18 jobs, all of them stuck queries.

Checks. On a Mac satellite (macos-26, Xcode 26.3, iPhone 17 Pro on iOS 26.2), I ran the workflow's own "Take screenshots" script under bash -e, on the iPhone only:

  • App frozen for 30 s (SIGSTOP) once the test started waiting for the first IssueRow, twice:
    • Each run wrote one stacks/iPhone-*/ folder, 15 s after the freeze.
    • Its spindump held ZBugs (suspended), ZBugsUITests-Runner and testmanagerd.
    • Sampling and processing took 7 s.
    • The test passed once the app resumed.
  • No freeze (the CI iPhone pair, both tests): both passed and no stacks/ folder was written.

oxfmt --check passes. shellcheck flags only the intended word splitting of the PIDs and the log redirect outside sudo.

When a UI query has gone 15 s without an answer, the screenshots job now
saves a spindump of the app, the UI-test runner and testmanagerd, the end
of xcodebuild's log, and top, under stacks/ in the zbugs-screenshots
artifact. It is for the iPhone's first query that hung 41 s and timed out
in job 134463464281, whose cause the logs can't show. Nothing else about
the run changes: no retries, skips or timeouts.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ecca-7f5f-74f3-af23-3f0aaa149aa1
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit 03377a0 into main Nov 18, 2026
27 of 28 checks passed
@tmm
tmm deleted the ci/zbugs-screenshots-query-stacks branch November 18, 2026 09:48
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.

2 participants