Fix idb device duplicates

Summary:
idb sometimes returns duplicates when we query targets. It leads us to removing valid devices and reconnecting to them again. Eventually, it starves the idb thread pool.
This diff removes the duplicates from the idb output.

Reviewed By: jknoxville

Differential Revision: D32099320

fbshipit-source-id: 7d8b756360f82557000ea5aa037a249b33be9961
This commit is contained in:
Andrey Goncharov
2021-11-03 08:09:43 -07:00
committed by Facebook GitHub Bot
parent 2e7015388c
commit bffd58b3a6
2 changed files with 18 additions and 1 deletions

View File

@@ -133,12 +133,16 @@ export class IOSDeviceManager {
const config = getFlipperServerConfig();
const isXcodeInstalled = await iosUtil.isXcodeDetected();
const isIdbAvailable = await iosUtil.isAvailable(config.idbPath);
console.debug(
`[conn] queryDevices. isXcodeInstalled ${isXcodeInstalled}, isIdbAvailable ${isIdbAvailable}`,
);
return Promise.all(
this.getAllPromisesForQueryingDevices(isXcodeInstalled, isIdbAvailable),
);
}
private processDevices(activeDevices: IOSDeviceParams[]) {
console.debug('[conn] processDevices', activeDevices);
if (!this.iosBridge) {
throw new Error('iOS bridge not yet initialized');
}
@@ -148,6 +152,10 @@ export class IOSDeviceManager {
.filter((device) => device.info.os === 'iOS')
.map((device) => device.serial),
);
console.debug(
'[conn] processDevices -> currentDeviceIDs',
currentDeviceIDs,
);
for (const activeDevice of activeDevices) {
const {udid, type, name} = activeDevice;