From c22902f63ff5da760e286d615e084ed294598695 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 11 Dec 2018 11:35:30 +0200 Subject: [PATCH] fix: debugging in VSCode is not working on iOS Simulator When you've stopped on breakpoint in VSCode and apply a change in the code, CLI tries to restart application. However, at this point the command for killing the application may not kill it immediately and it needs 30 seconds. The problem is that the runtime loops indefinitely while on breakpoint. After some seconds (looks like 30), the OS kills the application. In order to resolve the issue, disconnect all sockets before stopping the application, so the runtime can successfully break the indefinite loop and after that application can be safely killed. --- lib/common/mobile/ios/device/ios-application-manager.ts | 5 ++++- .../ios/simulator/ios-simulator-application-manager.ts | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/common/mobile/ios/device/ios-application-manager.ts b/lib/common/mobile/ios/device/ios-application-manager.ts index 047206a25c..bab0b39f1d 100644 --- a/lib/common/mobile/ios/device/ios-application-manager.ts +++ b/lib/common/mobile/ios/device/ios-application-manager.ts @@ -8,7 +8,7 @@ export class IOSApplicationManager extends ApplicationManagerBase { constructor(protected $logger: ILogger, protected $hooksService: IHooksService, - private device: Mobile.IDevice, + private device: Mobile.IiOSDevice, private $errors: IErrors, private $iOSNotificationService: IiOSNotificationService, private $iosDeviceOperations: IIOSDeviceOperations, @@ -88,6 +88,9 @@ export class IOSApplicationManager extends ApplicationManagerBase { public async stopApplication(appData: Mobile.IApplicationData): Promise { const { appId } = appData; + this.device.destroyDebugSocket(appId); + this.device.destroyLiveSyncSocket(appId); + const action = () => this.$iosDeviceOperations.stop([{ deviceId: this.device.deviceInfo.identifier, ddi: this.$options.ddi, appId }]); try { diff --git a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts index b12ea3d4c8..4269ae0f42 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts @@ -47,7 +47,12 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { } public async stopApplication(appData: Mobile.IApplicationData): Promise { - return this.iosSim.stopApplication(this.device.deviceInfo.identifier, appData.appId, appData.projectName); + const { appId } = appData; + + this.device.destroyDebugSocket(appId); + this.device.destroyLiveSyncSocket(appId); + + await this.iosSim.stopApplication(this.device.deviceInfo.identifier, appData.appId, appData.projectName); } public async getApplicationInfo(applicationIdentifier: string): Promise {