perf(platform-ios): overlap XCTest agent build with simulator boot#171
Open
V3RON wants to merge 2 commits into
Open
perf(platform-ios): overlap XCTest agent build with simulator boot#171V3RON wants to merge 2 commits into
V3RON wants to merge 2 commits into
Conversation
The XCTest agent build (xcodebuild build-for-testing, destination generic/platform=iOS Simulator) does not need a booted device, only the later launch phase does. Kick off the build immediately after resolving the simulator udid so it overlaps with bootSimulator/waitForBoot instead of running strictly after it, cutting startup time on simulator runs with permissions enabled, especially on a cold build cache. prepare() is idempotent and ensureStarted() already calls it internally, so calling it early and awaiting it again before ensureStarted() is safe. The permissions-disabled path is unchanged (xctestAgent stays null).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What is this?
On iOS simulator runs with
permissionsenabled, Harness built the XCTest permission agent strictly after the simulator finished booting, even though the build phase never touches the simulator. This serialized two independent, often lengthy operations for no reason—most noticeably on a coldxcodebuildcache (e.g. right after an Xcode version bump).How does it work?
In
getAppleSimulatorPlatformInstance, the XCTest agent controller is now constructed as soon as the simulator's udid is known (before boot), andprepare()(the build-only phase,xcodebuild build-for-testingagainstgeneric/platform=iOS Simulator) is kicked off immediately without being awaited. The simulator boot/waitForBoot/install/harness-JS-override sequence then runs as before, unaffected by the build. Once that sequence finishes, the outstandingpreparePromiseis awaited first (so a build failure still surfaces and fails startup), followed byensureStarted(), which internally re-callsprepare()—a no-op since it's idempotent—before launching the agent process against the now-booted device.This is safe because:
prepare()only depends on the udid, which is already known before boot, and never touches the booted device (the run phase,test-without-buildingagainstid=<udid>, is untouched and still runs after boot).prepare()is idempotent (if (prepared) return), so calling it early and lettingensureStarted()call it again is a no-op..catchat creation to avoid an unhandled-rejection warning if boot fails first, while still beingawaited inside thetryblock so the real error is surfaced and the existingfinallycleanup (dispose agent, clear the harness JS override, shut down the simulator if Harness booted it) still runs correctly on any failure path.permissionsis disabled,xctestAgentstaysnullandpreparePromiseisundefined, so behavior is byte-for-byte unchanged.getApplePhysicalDevicePlatformInstanceis untouched—physical device runs don't boot a simulator, so there's nothing to overlap.Why is this useful?
The two operations are independent, so running them concurrently removes dead time from Harness startup on simulator runs with permission auto-acceptance enabled. The win is largest on cold build caches, such as right after an Xcode version bump, where the XCTest agent build can take a while and previously ran back-to-back with the simulator boot instead of alongside it.