Replay a UI scenario to amplify a suspected leak
replayScenarioDrive iOS Simulator through a sequence of UI actions to reproduce memory leaks. Repeat actions to amplify subtle leaks, and pair with state capture for deterministic debugging.
Instructions
[mg.scenario] Drive the iOS Simulator through a sequence of UI actions (tap, swipe, wait, type) and optionally repeat the sequence N times to amplify a leak that only manifests after iteration. Tied to verify-fix: pair with captureScenarioState before/after to make leak reproductions deterministic. Soft dependency on axe (https://github.com/cameroncooke/AXe) — when missing, returns a structured workaroundNotice with install instructions. Tap targets accept label, elementId, or explicit coords.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| simulatorUDID | Yes | UDID of the booted simulator. Use listTraceDevices to find one. | |
| actions | Yes | Ordered list of UI actions: { type: 'tap', label|elementId|coords }, { type: 'swipe', from, to }, { type: 'wait', seconds }, or { type: 'type', text }. | |
| repeat | No | Run the entire actions sequence this many times. Default 1. Use 5-10 to amplify subtle leaks that accumulate per repetition. | |
| settleBetweenActionsMs | No | Pause between consecutive actions in milliseconds. Default 500. Increase for animation-heavy flows. | |
| finalUITreePath | No | When provided, after the scenario completes the final UI tree is written here as JSON for the caller to verify the app ended in the expected state. | |
| screenshotDir | No | v1.15+. DebugSwift-inspired. When provided, captures a simulator screenshot after each action into `<screenshotDir>/iteration-{N}_step-{M}.png`. Useful for 'what was on screen when the leak fired?' context in verify-fix loops. Uses `xcrun simctl io ... screenshot` directly (no axe dependency). Screenshot capture failures are non-fatal: surfaced in `failures[]` but do not halt the scenario. |