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:
committed by
Facebook GitHub Bot
parent
939b624dbb
commit
d423afd75d
@@ -81,9 +81,11 @@ async function queryDevices(store: Store, logger: Logger): Promise<any> {
|
||||
getActiveSimulators().then((devices) => {
|
||||
processDevices(store, logger, devices, 'emulator');
|
||||
}),
|
||||
getActiveDevices().then((devices) => {
|
||||
processDevices(store, logger, devices, 'physical');
|
||||
}),
|
||||
getActiveDevices(store.getState().settingsState.idbPath).then(
|
||||
(devices: IOSDeviceParams[]) => {
|
||||
processDevices(store, logger, devices, 'physical');
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -173,8 +175,8 @@ function getActiveSimulators(): Promise<Array<IOSDeviceParams>> {
|
||||
.catch((_) => []);
|
||||
}
|
||||
|
||||
function getActiveDevices(): Promise<Array<IOSDeviceParams>> {
|
||||
return iosUtil.targets().catch((e) => {
|
||||
function getActiveDevices(idbPath: string): Promise<Array<IOSDeviceParams>> {
|
||||
return iosUtil.targets(idbPath).catch((e) => {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
});
|
||||
@@ -233,12 +235,12 @@ async function isXcodeDetected(): Promise<boolean> {
|
||||
.catch((_) => false);
|
||||
}
|
||||
|
||||
export async function getActiveDevicesAndSimulators(): Promise<
|
||||
Array<IOSDevice>
|
||||
> {
|
||||
export async function getActiveDevicesAndSimulators(
|
||||
store: Store,
|
||||
): Promise<Array<IOSDevice>> {
|
||||
const activeDevices: Array<Array<IOSDeviceParams>> = await Promise.all([
|
||||
getActiveSimulators(),
|
||||
getActiveDevices(),
|
||||
getActiveDevices(store.getState().settingsState.idbPath),
|
||||
]);
|
||||
const allDevices = activeDevices[0].concat(activeDevices[1]);
|
||||
return allDevices.map((device) => {
|
||||
|
||||
Reference in New Issue
Block a user