From d1dd4d3c1e709b03292ab27ba38fc070ccf31f8b Mon Sep 17 00:00:00 2001 From: orca-bug-scan-bot Date: Fri, 3 Jul 2026 21:18:59 -0700 Subject: [PATCH] fix: address pr-bug-scan validated finding from #7174 Made resolveServeSimExecutable() lazy in IosEmulatorBackend via a cached getter; constructor no longer triggers the startup cpSync+xattr on darwin first-launch. --- .../emulator/backends/ios-emulator-backend.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/emulator/backends/ios-emulator-backend.ts b/src/main/emulator/backends/ios-emulator-backend.ts index 8d3c31604e4..7d7d84353d9 100644 --- a/src/main/emulator/backends/ios-emulator-backend.ts +++ b/src/main/emulator/backends/ios-emulator-backend.ts @@ -46,14 +46,25 @@ export class IosEmulatorBackend implements EmulatorBackend { logcat: false } - private readonly serveSimExecutable: ServeSimExecutable + private serveSimExecutableCache: ServeSimExecutable | undefined private readonly waitForEndpointReady: (endpoint: string) => Promise constructor(options: EmulatorBridgeOptions = {}) { - this.serveSimExecutable = resolveServeSimExecutable() this.waitForEndpointReady = options.waitForEndpointReady ?? waitForServeSimEndpointReady } + // Why: resolving the executable can materialize the serve-sim runtime (a + // recursive copy + xattr subprocess on darwin first-launch-per-version), so + // defer it to first actual use. Constructing this backend at app startup + // (inside app.whenReady, before the main window opens) must not block the + // main thread on that work. + private get serveSimExecutable(): ServeSimExecutable { + if (!this.serveSimExecutableCache) { + this.serveSimExecutableCache = resolveServeSimExecutable() + } + return this.serveSimExecutableCache + } + isSupportedOnHost(): boolean { return platform() === 'darwin' }