Fix high pkd CPU usage issue

Summary:
Running `instruments -s devices` causes the `pkd` process in catalina to spike to ~100% for a few seconds.

Flipper runs this command every 3 seconds to poll for devices.
This switches it to use `idb list-targets` instead which is much more performant.

Currently switched off in the open-source version while we make sure it's working well. If you set the GK value 'flipper_use_idb_to_list_devices' to true, then you'll get the new behaviour.

Reviewed By: passy

Differential Revision: D23102067

fbshipit-source-id: 9e17155d938a4fe326e082511f747444e4b533a2
This commit is contained in:
John Knox
2020-08-13 03:46:36 -07:00
committed by Facebook GitHub Bot
parent 939b624dbb
commit d423afd75d
6 changed files with 88 additions and 49 deletions

View File

@@ -342,28 +342,30 @@ export default class CertificateProvider {
// It's a simulator, the deviceId is in the filepath.
return Promise.resolve(matches[1]);
}
return iosUtil.targets().then((targets) => {
if (targets.length === 0) {
throw new Error('No iOS devices found');
}
const deviceMatchList = targets.map((target) =>
this.iOSDeviceHasMatchingCSR(
deviceCsrFilePath,
target.udid,
appName,
csr,
).then((isMatch) => {
return {id: target.udid, isMatch};
}),
);
return Promise.all(deviceMatchList).then((devices) => {
const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id);
if (matchingIds.length == 0) {
throw new Error(`No matching device found for app: ${appName}`);
return iosUtil
.targets(this.store.getState().settingsState.idbPath)
.then((targets) => {
if (targets.length === 0) {
throw new Error('No iOS devices found');
}
return matchingIds[0];
const deviceMatchList = targets.map((target) =>
this.iOSDeviceHasMatchingCSR(
deviceCsrFilePath,
target.udid,
appName,
csr,
).then((isMatch) => {
return {id: target.udid, isMatch};
}),
);
return Promise.all(deviceMatchList).then((devices) => {
const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id);
if (matchingIds.length == 0) {
throw new Error(`No matching device found for app: ${appName}`);
}
return matchingIds[0];
});
});
});
}
androidDeviceHasMatchingCSR(