Use idb to poll for devices, if it is installed

Summary:
Bringing the pkd CPU usage fix to open source releases.

Now when idb is installed, Flipper will always use it to check for devices, and only fallback to instruments if not.

Fixes https://github.com/facebook/flipper/issues/1028

Reviewed By: passy

Differential Revision: D23293675

fbshipit-source-id: 6ff3e89167f5f6d4130f197b2a675202334d0e7d
This commit is contained in:
John Knox
2020-08-24 07:51:58 -07:00
committed by Facebook GitHub Bot
parent 573bf8a940
commit 39a465b8b8

View File

@@ -59,8 +59,12 @@ async function targets(idbPath: string): Promise<Array<DeviceTarget>> {
if (process.platform !== 'darwin') {
return [];
}
if (GK.get('flipper_use_idb_to_list_devices')) {
await memoize(checkIdbIsInstalled)(idbPath);
// Not all users have idb installed because you can still use
// Flipper with Simulators without it.
// But idb is MUCH more CPU efficient than instruments, so
// when installed, use it.
if (await memoize(isAvailable)(idbPath)) {
return safeExec(`${idbPath} list-targets --json`).then(({stdout}) =>
stdout
.toString()