Skip to content

improve: skip satisfied iOS screenshot readiness waits - #189040

Open
joshavant wants to merge 1 commit into
mainfrom
perf/ios-screenshot-readiness
Open

joshavant wants to merge 1 commit into
mainfrom
perf/ios-screenshot-readiness

Conversation

@joshavant

@joshavant joshavant commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

iOS release screenshots poll for root readiness even when the requested screen is already ready.

User Impact

No app UI changes. Screenshot capture can avoid redundant readiness polling while retaining every readiness condition, destination anchor, independent app launch, and capture.

Why This Change Was Made

Check each readiness condition immediately before entering its existing fallback wait. Preserve separate eight-second appearance and ready-value deadlines, including the non-screenshot launch path. Fastlane idle and animation waits remain unchanged.

Maintainer-requested continuation of the screenshot performance work in #188927. Screenshot-only experiments below do not qualify or upload a release. Do not merge until the measurements are complete.

Evidence

  • Existing Fastlane release-gate suite: 15 tests passed.
  • Pinned SwiftFormat 0.63.1 with the repository config: passed; git diff --check: passed.
  • Direct pinned SwiftLint reports the same pre-existing empty_count, file_length, and type_body_length violations on the pristine base and candidate. No suppressions added.
  • AutoReview/Codex reviewed base 95b5fa5fb78d1c39c0bd364ee3dc9f37a1750c1c through the final local patch, P0–P2: scoped-clean, no actionable findings. Local ClawSweeper was unavailable because its structured result contained an unsupported nextStep key; hosted ClawSweeper reviewed head 63db213a65d5ccdcc563c5e6fefb32ec9082f76a with no actionable findings.
  • Exact-head PR CI: green, including native screenshot capture and screenshot evidence validation. All checks settled.
  • Performance qualification failed; keep unmerged. The runtime-fixed cohort stopped with five baselines and four candidates when the declared acceptance became impossible to meet. Root admission improves, but complete capture results do not meet the median/p95 criteria. Full measurements and the stopping calculation are below. Earlier failed cohorts remain separate. Green PR CI does not qualify the latency improvement.

Measurement rule (declared before the first experiment)

Workload: committed pnpm ios:screenshots through the existing screenshot-only workflow, on xcode-27-xlarge, diagnostics timeline and startup probe disabled, host indexing disabled by the existing disposable-runner step. Freeze baseline at 95b5fa5fb78d1c39c0bd364ee3dc9f37a1750c1c and candidate at this PR's original head. Both experiment refs receive identical workflow-only log/result retention, excluded from this PR.

Screen one baseline/candidate pair, then, if promising, collect at least five samples per arm serially in ABAB order. Each sample uses a fresh hosted runner, fresh build, and fresh serial simulators. Do not mix warm repeats into the comparison.

Primary metric: sum of eight root-admission intervals, from the foreground-app wait to the first destination-anchor wait in the XCTest trace. Accept at least eight seconds lower median summed root-admission time, with all eight independent app launches, all assertions, and all nine iPhone/iPad/Watch images successful. Combined device-capture median must improve; per-device capture median and p95 must hold or improve. Report median, nearest-rank p95, range, complete capture-step wall time, attempt counts, and available host/resource identity. Investigate any metric worsening by 20% before proceeding. Root timing alone does not establish whole-pipeline savings. Revert the candidate if it has no measurable gain or weakens capture.

Preliminary screen results

  • Baseline run 41170329410: passed, all nine images; each iOS device succeeded on attempt one. Eight root-admission intervals totaled 19.48s; iPhone capture 125.50s, iPad capture 121.77s, combined 247.27s; complete capture step 713s.
  • Candidate run 41171264955: failed in testReleaseChatScreenshot at the preserved Mermaid button assertion. The other three iPhone tests passed; iPad/Watch were not reached. Root checks passed. The recording shows rendering in progress followed by the retryable fallback rather than a completed diagram. No complete candidate timing or speedup is claimed.
  • Same runner image xcode-27-arm64 / 20261026.0314.1; baseline observed five logical CPUs, 14 GiB RAM, Xcode 27.1 (27A9275). End-of-capture host snapshots are retained in the run logs.
  • Targeted traced candidate run 41172160221 passed all four original iPhone captures. Trace records an initial cancellation followed by document readiness in 2.63s and successful render/snapshot completion in 2.95s. It is diagnostic evidence, not a complete or comparable performance sample, and does not fix or explain the earlier failure.
  • The symptom predates this patch: run 41128864267 failed at the same chat assertion and its exported failure hierarchy contains the identical temporary-unavailability fallback. Its reviewed feature source f75786ca75eb279d3b7e46642855cfd9aa058e6a has byte-identical complete screenshot-test and renderer files to this PR's pristine base. The native root waits were still unconditional. This establishes the pre-existing symptom; the renderer's internal error remains unknown.
  • The original failed screen remains recorded above. It is not counted as a pass, discarded, or claimed fixed by the successful diagnostic run.

Replication campaign (declared before its first run)

The initial screen is inconclusive for complete capture time because the candidate failed with the independently verified pre-existing renderer symptom. Start a separate cohort of five full baseline/candidate pairs, serially in ABAB order, using the same two frozen refs, workload, hardware, cold-runner conditions, and original acceptance thresholds above. Report this cohort separately from the initial screen and the iPhone-only diagnostic. Stop on another capture failure for investigation; do not replace failed cohort samples with successful replays. Retain all attempt outcomes and report known residual renderer risk separately from latency measurements. The temporary renderer tracer is excluded from both benchmark arms and this PR. No code or timeout was changed in response to the failure.

No app uploads or merges are authorized in this campaign.

Replication outcome: stopped after the first pair

  • Baseline 41174201419: success, all nine images. Both iOS devices succeeded on attempt one, with four independent launches, terminations, and passing tests each. Capture diagnostics report at most one active simulator. Complete capture step: 719s.
  • Candidate 41175154845: workflow failure. All eight original iPhone/iPad tests passed on attempt one, including both Mermaid assertions; eight images were retained. Watch capture was never reached. Both device captures remained serial. The candidate's eight images and baseline's nine-image contact sheet were inspected and rendered correctly.
  • The failure is in the unchanged Watch runtime repair path: runtime inventory was empty, then the disk-image inventory reported two watchOS 27.0 / 24R362 registrations, one Ready and one Deleting, both with mountedPathExists: false. The existing safety guard at Fastfile line 294 rejected multiple registrations before deletion/download or Watch simulator creation. That repair function is byte-identical in baseline, candidate, and current main. This identifies the failing condition; it does not establish why the runner acquired duplicate registrations or rule out timing exposing the existing lifecycle defect.
  • Both runs used xcode-27-arm64 image 20261026.0314.1, Xcode 27.1 / 27A9275, five logical CPUs, and 15,032,385,536 bytes (14 GiB) RAM.

The following are descriptive single-pair iPhone/iPad measurements from an incomplete cohort, not accepted full-workload medians or p95 estimates. The failed candidate is excluded from successful full-workload statistics.

Metric Baseline Candidate (Watch missing) Change
Root admission, eight launches 20.30s 2.52s -87.59%
iPhone capture 128.67s 137.70s +7.02%
iPad capture 145.31s 126.86s -12.70%
Combined device capture 273.98s 264.56s -3.44%

All eight candidate root checks took the immediate path with no appearance/value polling waits, saving 17.78s in this pair. Overall iPhone capture was nevertheless 9.03s slower. No end-to-end speedup is claimed from a workflow that stopped before Watch.

The campaign stopped as declared: one successful baseline, one failed candidate, no replacement samples, no further dispatches. Five successful samples per arm, per-device median/p95 acceptance, and a complete candidate nine-image run remain unproven. Stabilize the observed Watch runtime lifecycle before spending more full-capture benchmark runs; retain the failed cohorts separately in any future comparison. The readiness patch is unchanged, PR CI remains green, and this PR remains unmerged.

Runtime-fixed replication cohort (declared before its first run)

The separate Watch runtime lifecycle fix is merged in 189217, with a passing long scanner-survival probe and all nine images through the production screenshot lane. The earlier failed cohorts above remain separate and are not replaced or counted as successful samples.

Freeze both new arms on merged base 07ec4dc256bda86b972462c360f47b48e3b29434:

  • Baseline: 4bb9edd1ffa1cacada27b445c3624984c0278b89 (bench/ios-readiness-fixed-baseline).
  • Candidate: 4e0ee9955224a5b91a050c68e620df242ba6c629 (bench/ios-readiness-fixed-candidate).

The arms contain identical runtime fixes and workflow-only evidence retention/host snapshots. Their only difference is this PR's immediate root-readiness checks. Keep the same committed pnpm ios:screenshots workload, xcode-27-xlarge, fresh hosted runners/builds/serial simulators, disabled resource timeline/startup probe, and existing disposable-runner indexing policy.

Collect five full baseline/candidate pairs serially in ABAB order. Retain every run receipt and outcome. Stop on a capture failure, changed image inventory/runner image, or a metric regression of at least 20%; never substitute green replays for failed samples.

Keep the original acceptance rule: at least eight seconds lower median summed root-admission time across eight independent launches; improve combined device-capture median; hold or improve per-device median and nearest-rank p95. Require all assertions, nine PNGs, first attempts, and at most one active simulator. Report counts, median/p95/range and complete capture-step wall time. No release uploads. Performance qualification is pending; this PR remains unmerged.

Runtime-fixed pair one: regression investigation

  • Baseline 41193885373 and candidate 41196107014 both succeeded with all nine images, eight passing independent launches/terminations, first capture attempts, and at most one active simulator. Both contact sheets were inspected; both Mermaid diagrams and Watch rendered correctly. Both runs normalized the same Watch runtime successfully.
  • Root admission fell from 19.85s to 5.35s (14.50s saved). All eight candidate checks took the immediate path without appearance/value polling.
  • Combined device capture increased from 239.69s to 301.78s (+25.90%); iPhone 101.29s to 130.31s (+28.65%); iPad 138.40s to 171.47s (+23.89%). Complete capture step increased from 738s to 962s (+30.35%). With one sample per arm these are individual observations, not qualified distribution estimates.
  • The controller stopped before another dispatch, as required. Investigation of the raw traces separates the combined 62.09s increase into 44.26s additional capture overhead outside the test suites, 21.36s additional time before the changed root checks, 10.97s additional post-root time, and 14.50s saved inside root admission. Before any test executes, build time was also 57.63s longer and the two iOS simulator boot/inventory phases were 80.41s longer. This establishes wider timing variation outside the changed checks; it does not identify its cause or establish the candidate's overall effect.
  • Runner image/version, Xcode, macOS, logical CPUs, and RAM match. Neither run reports swap traffic. High end-of-capture load alone is not evidence of resource starvation.

After this investigation, continue the remaining preregistered pairs from the same ledger and frozen heads. Preserve this slower candidate in every final statistic. No code, timeout, sample, final acceptance threshold, or regression alarm is changed. Any new regression alarm stops dispatch for investigation. The final five-pair acceptance still requires combined median improvement and no per-device median/p95 regression; this single pair does not qualify the PR.

Second baseline 41197676096 also succeeded with all nine images, first attempts, eight independent launches/terminations, and serial simulators. Root admission: 19.53s; iPhone/iPad capture: 126.12s / 140.37s; combined: 266.49s; complete capture step: 755s. Runner identity is unchanged. The controller stopped again because the previously investigated candidate remains above the iPad and complete-step alarm thresholds. This adds a second baseline observation, not a second candidate regression. Retain all three samples and continue to the second candidate after rechecking that the alarm is still driven by the same investigated run. Final acceptance remains unchanged and unproven.

Second candidate 41199075241 succeeded with all nine images, first attempts, eight independent launches/terminations, serial simulators, and the same runner identity. Root admission: 4.04s; iPhone/iPad capture: 111.68s / 122.87s; combined: 234.55s; complete capture step: 768s. Relative to the second baseline, combined device capture fell 31.94s and root admission fell 15.49s. Across both retained pairs, however, combined capture median remains 5.96% slower (253.09s baseline versus 268.165s candidate), and final acceptance is unproven. The controller again stopped on the previously investigated first candidate's iPad p95; the second candidate introduced no new maximum. Continue the remaining three pairs after this check, retaining the slow first candidate and unchanged final acceptance.

Third pair: baseline 41200630826 and candidate 41201812363 both succeeded with all nine images and unchanged capture invariants/runner identity. Baseline/candidate: root admission 19.06s / 1.83s; combined capture 266.26s / 250.40s; complete capture step 774s / 794s. At three samples per arm, root medians are 19.53s / 4.04s (15.49s saved); combined capture medians 266.26s / 250.40s (5.96% lower). Per-device worst cases still regress, and complete-step median is 39s slower. The alarm remains the already investigated first candidate's 962s complete step; no new candidate maximum appeared. Keep all samples and unchanged acceptance while collecting the final two pairs. Performance qualification remains incomplete.

Fourth pair: baseline 41202962704 and candidate 41204133914 both succeeded with all nine inspected images, first attempts, eight independent launches/terminations, serial simulators, and unchanged runner identity. Baseline/candidate: root admission 20.38s / 2.90s; iPhone capture 125.03s / 147.46s; iPad capture 116.74s / 155.76s; combined capture 241.77s / 303.22s; complete capture step 790s / 930s.

The controller stopped again before the final pair. This candidate adds a new combined-capture and iPhone maximum. Investigated its paired 61.45s combined increase: 41.23s additional capture overhead outside the suites, 25.09s additional pre-root time, 12.61s additional post-root time, offset by 17.48s saved in root admission. Build time was 1.89s lower; boot/inventory across all devices was 52.79s longer, principally the iPad phase (58.96s versus 101.03s). These traces locate the extra time but do not establish its underlying cause or rule out timing interactions. All eight candidate root checks used the immediate path. No assertions, source, timeouts, samples, or thresholds were changed. Retain both slow candidate observations. After this investigation collect the final preregistered pair; at four pairs combined-capture median is 8.69% slower and qualification remains unproven.

Runtime-fixed outcome: failed qualification

The controller stopped after final baseline 41205573885. Five baseline and four candidate samples were collected, in ABABABABA order. No fifth candidate was dispatched. Every run succeeded with all nine inspected images, first capture attempts, all eight independent app launches/terminations and assertions, and at most one active simulator. That is 72 passing screenshot tests and 81 expected PNGs. The frozen source and exact image inventory were verified for every run. No uploads or release qualification occurred.

Times below are seconds. Nearest-rank p95 equals the observed maximum at these sample counts; this is a small descriptive dataset, not a precise population-tail estimate. All slow samples are included.

Metric Baseline n=5: median / p95 / range Candidate n=4: median / p95 / range Median change
Root admission (8 launches) 19.530 / 20.380 / 19.060–20.380 3.470 / 5.350 / 1.830–5.350 -82.23%
Combined device capture 244.320 / 266.490 / 239.690–266.490 276.090 / 303.220 / 234.550–303.220 +13.00%
iPhone capture 123.280 / 126.120 / 101.290–126.120 126.465 / 147.460 / 111.680–147.460 +2.58%
iPad capture 138.400 / 142.980 / 116.740–142.980 141.770 / 171.470 / 122.870–171.470 +2.43%
Complete capture step 755.000 / 790.000 / 734.000–790.000 862.000 / 962.000 / 768.000–962.000 +14.17%

Root-admission median falls 16.06s, exceeding the eight-second component target. The full acceptance rule nevertheless fails: combined capture median is higher; both per-device medians and p95s are higher; complete capture-step median is 107s higher. This does not establish that the readiness patch causes all of the additional time. The two slow-candidate investigations above locate substantial time outside root admission but do not determine its underlying cause. No whole-pipeline speedup is claimed.

The final baseline makes rejection conclusive without another hosted run. With the four retained candidate combined times sorted as 234.55, 250.40, 301.78, 303.22, even adding a zero-second fifth candidate gives a 250.40s median, above the final baseline median of 244.32s. At n=5, nearest-rank p95 remains the maximum: adding a fifth candidate cannot lower the existing iPhone 147.46s or iPad 171.47s maxima below baseline 126.12s / 142.98s. The full-step candidate p95 also cannot fall below 962s versus baseline 790s. The prescribed five-sample positive qualification is not claimed; the stopped experiment already cannot satisfy its unchanged thresholds. No sample was removed, replaced, retried, or reclassified as a passing qualification.

All nine runs report runner image xcode-27-arm64 / 20261026.0314.1, Xcode 27.1 / 27A9275, macOS 27.0.1 / 26A434, five logical CPUs, and 15,032,385,536 bytes (14 GiB) RAM. Before/after host snapshots report no swap traffic. High end-of-capture load alone does not identify starvation. Startup/resource probes remained disabled. Queue waits are excluded from measured capture times.

Order Arm Run Root admission iPhone capture iPad capture Combined capture Complete capture step
1 baseline 41193885373 19.85 101.29 138.40 239.69 738
2 candidate 41196107014 5.35 130.31 171.47 301.78 962
3 baseline 41197676096 19.53 126.12 140.37 266.49 755
4 candidate 41199075241 4.04 111.68 122.87 234.55 768
5 baseline 41200630826 19.06 123.28 142.98 266.26 774
6 candidate 41201812363 1.83 122.62 127.78 250.40 794
7 baseline 41202962704 20.38 125.03 116.74 241.77 790
8 candidate 41204133914 2.90 147.46 155.76 303.22 930
9 baseline 41205573885 19.48 116.20 128.12 244.32 734

The experiment is stopped, no comparison run remains active, and this PR remains open and unmerged. The separate Watch runtime repair is already merged; these results add nine successful full-capture executions of that runtime-fixed source.

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@joshavant
joshavant marked this pull request as ready for review October 31, 2026 04:52
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR checks iOS screenshot readiness immediately before entering the existing fallback waits.

Example: The chat screenshot launch already exposes RootTabs.Ready with value ready:chat.

  • Before: The harness invokes both the existence wait and the ready-value predicate wait.
  • After: Immediate checks satisfy both conditions, so the harness proceeds to the destination anchor.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-correct, but the explicitly required performance experiment is still pending.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Release screenshot capture can spend time polling readiness conditions that are already satisfied.
Reason: The maintainer-authored direction has a clear automation benefit and minimal implementation cost, with a predeclared experiment determining whether the optimization should land.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open; the focused change preserves readiness guarantees, and no actionable code defect was found.

Priority: P3
Reviewed head: 63db213a65d5ccdcc563c5e6fefb32ec9082f76a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Controlled baseline/candidate screenshot captures with timing traces, preserved assertions, and all nine iPhone/iPad/Watch images have not yet been supplied.
Agent review details

How this fits together

The XCTest screenshot harness launches each requested app destination, checks its accessibility readiness marker and destination anchor, then passes capture to Fastlane.

flowchart TD
A[Screenshot command] --> B[Fastlane capture lane]
B --> C[Independent XCTest app launch]
C --> D[Readiness checks and fallback waits]
D --> E[Destination anchor assertion]
E --> F[Screenshot capture]
Loading

Technical review

Best possible solution:

Retain the minimal checks in the existing launch owner only if the declared experiment demonstrates faster capture with every readiness and image check preserved.

Do we have a high-confidence way to reproduce the issue?

Source confirms redundant wait invocation when readiness is already satisfied, but its runtime cost has not been established by completed measurements.

Is this the best way to solve the issue?

The patch is the smallest focused approach: it uses the existing launch owner, keeps both fallback deadlines, and adds no state, helper, or competing capture path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ebb10c7f6855.

Provenance checked

  • Root readiness existence and destination synchronization keeps the original intent (b85c0e2: Screenshot hardening added explicit root readiness and destination synchronization; fix(ios): stabilize Apple UI validation across runtimes #116487 subsequently retained destination-value synchronization for deterministic screenshot launches across supported runtimes.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • joshavant: Raw commit b85c0e2 adds apps/ios/UITests/OpenClawSnapshotUITests.swift:967 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b85c0e20644b; files: apps/ios/UITests/OpenClawSnapshotUITests.swift)
  • Vincent Koc: Raw commit 8a12343 adds apps/ios/UITests/OpenClawSnapshotUITests.swift:1022 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8a12343efe67; files: apps/ios/UITests/OpenClawSnapshotUITests.swift)

PR surface

Tests +2. Total +2 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 4 2 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 2 +2

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded screenshot-harness performance improvement with no app UI or production runtime change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the declared baseline/candidate screenshot experiment and publish its results before removing the merge pause.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 31, 2026, 1:08 AM ET / 05:08 UTC.

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

app: ios App: ios P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant