From 4f70219a474fdd28e389e7f77b0846d359641ac7 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 16 Mar 2021 20:08:53 -0700 Subject: [PATCH] Dispose iOS logs if logs plugin is not connected Summary: See D27047041 (https://github.com/facebook/flipper/commit/d293b2b0e588dee6ec1aff45042442975ed865a0) for more details. This diff makes sure the log listener is disposed if the Logs plugin is disabled / the logging is paused, rather than keeping the connection open all time. Reviewed By: nikoant Differential Revision: D27083966 fbshipit-source-id: 6f157c237519a0fde9591f1c2033621858863de0 --- desktop/app/src/devices/IOSDevice.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/desktop/app/src/devices/IOSDevice.tsx b/desktop/app/src/devices/IOSDevice.tsx index 5a49217de..44324d8d3 100644 --- a/desktop/app/src/devices/IOSDevice.tsx +++ b/desktop/app/src/devices/IOSDevice.tsx @@ -45,6 +45,7 @@ export default class IOSDevice extends BaseDevice { buffer: string; private recordingProcess?: ChildProcess; private recordingLocation?: string; + private iOSBridge: IOSBridge; constructor( iOSBridge: IOSBridge, @@ -55,7 +56,7 @@ export default class IOSDevice extends BaseDevice { super(serial, deviceType, title, 'iOS'); this.icon = 'mobile'; this.buffer = ''; - this.startLogListener(iOSBridge); + this.iOSBridge = iOSBridge; } async screenshot(): Promise { @@ -81,10 +82,12 @@ export default class IOSDevice extends BaseDevice { exec(command); } - teardown() { - if (this.log) { - this.log.kill(); - } + startLogging() { + this.startLogListener(this.iOSBridge); + } + + stopLogging() { + this.log?.kill(); } startLogListener(iOSBridge: IOSBridge, retries: number = 3) { @@ -207,6 +210,11 @@ export default class IOSDevice extends BaseDevice { } return null; } + + disconnect() { + this.stopScreenCapture(); + super.disconnect(); + } } // Used to strip the initial output of the logging utility where it prints out settings.