fix: waitToSettleTimeoutMs was silently broken on iOS — 2x faster flows with tuned timeouts#3141
Open
qwertey6 wants to merge 4 commits intomobile-dev-inc:mainfrom
Open
fix: waitToSettleTimeoutMs was silently broken on iOS — 2x faster flows with tuned timeouts#3141qwertey6 wants to merge 4 commits intomobile-dev-inc:mainfrom
qwertey6 wants to merge 4 commits intomobile-dev-inc:mainfrom
Conversation
iOS simulators share the host's localhost, causing port collisions when
multiple Maestro processes target different sims simultaneously. Session
tracking was per-platform, so two processes on different devices would
interfere with each other's sessions.
Changes:
- Per-device session tracking: SessionStore keys are now
"{platform}_{deviceId}_{sessionId}" instead of "{platform}_{sessionId}"
- Add --driver-host-port CLI flag for explicit XCTest server port
- Auto-select available ports with isPortAvailable() check
- Refactor SessionStore from singleton to injectable class (DI)
- Add shouldCloseSession(platform, deviceId) for per-device shutdown
instead of global activeSessions().isEmpty()
- Add cross-process file locking to KeyValueStore (~/.maestro/sessions)
- Append PID to debug log directory to prevent parallel race
- Enable useJUnitPlatform() in maestro-cli (was missing)
- Add SessionStoreTest with 8 tests covering isolation and lifecycle
Verified: 3 iOS simulators + Android emulator running simultaneously,
all passing. Both --driver-host-port (explicit) and auto-port-selection
work correctly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Default --reinstall-driver to false: reuse a healthy running driver instead of killing and reinstalling on every run (~40s saved on iOS) - XCTestDriverClient checks isChannelAlive() before reinstalling — if the user explicitly passes --reinstall-driver, honor it - Cache extracted iOS build products per-device in ~/.maestro/build-products/<deviceId>/ with SHA-256 hash validation: skips extraction when source matches cache, re-extracts on upgrade - Reduce XCTest status check HTTP read timeout from 100s to 3s - Remove Thread.sleep(1000) heartbeat delay hack (no longer needed with per-device session tracking) Single device: ~52s → ~10-12s. Three devices parallel: ~54s → ~18s. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- iOS XCTest runner: add isVersionMatch() to XCTestInstaller interface. LocalXCTestInstaller compares SHA-256 hash of build products against a .running-hash marker written at startup. restartXCTestRunner now checks both isChannelAlive() AND isVersionMatch() — stale runners from a previous Maestro version are replaced automatically. - Android driver: add isDriverVersionCurrent() that hashes the bundled maestro-app.apk and maestro-server.apk, compares against stored hash in ~/.maestro/android-driver-hash. On mismatch, APKs are reinstalled even when reinstallDriver=false. - App binary cache (clearAppState): getCachedAppBinary now compares Info.plist of cached vs installed app. Stale cache from app updates is detected and refreshed before reinstall. Per-device cache dirs (~/.maestro/app-cache/<deviceId>/) prevent parallel races. - Add XCTestDriverClientTest (4 tests) and LocalSimulatorUtilsTest (3 tests) covering version mismatch, reuse, and cache behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On iOS, waitForAppToSettle has two tiers: a server-side screenshot hash check (Tier 1, hardcoded 3000ms) and a client-side hierarchy comparison fallback (Tier 2). The per-command waitToSettleTimeoutMs config only controlled Tier 2, so even waitToSettleTimeoutMs: 100 would still burn up to 3 seconds in Tier 1. Fix: use waitToSettleTimeoutMs as the total settle budget. Tier 1 runs with this timeout, and any remaining time goes to Tier 2: - swipe with waitToSettleTimeoutMs: 500 → capped at 500ms total - default (no config) → unchanged 3000ms behavior Wikipedia e2e flow with tuned timeouts: 25s vs 53s baseline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 10, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
waitToSettleTimeoutMswas silently broken on iOS. The per-command config existed in the YAML spec and was documented, but on iOS it only controlled the fallback tier — the primary 3-second screenshot hash check always ran regardless. Users who tried to optimize their flows withwaitToSettleTimeoutMson iOS got no benefit.Impact
waitToSettleTimeoutMsnow actually works on iOS: settingwaitToSettleTimeoutMs: 500on a swipe genuinely caps settle time at 500mswaitToSettleTimeoutMsset) uses unchanged 3000ms budgetRoot cause
iOS
waitForAppToSettlehas two tiers:waitToSettleTimeoutMsas timeout.The
waitToSettleTimeoutMsparameter only controlled Tier 2. Tier 1 always burned its full 3000ms budget regardless. SowaitToSettleTimeoutMs: 100meant: wait 3000ms for screenshots, THEN wait 100ms for hierarchy comparison. Total: 3100ms, not 100ms.Fix
Use
waitToSettleTimeoutMsas the total settle budget:totalTimeout(eitherwaitToSettleTimeoutMsor default 3000ms)Measured impact (Wikipedia e2e flow)
Changes
IOSDriver.kt—waitForAppToSettle()usestimeoutMsas total budget for both tiers, with remaining time passed to the hierarchy fallbackTesting
Manually verified with Wikipedia e2e flow on iOS simulator. All existing tests pass. Default behavior (no
waitToSettleTimeoutMs) unchanged.Issues fixed
Partially addresses #1528