Migrate away from deprecated instruments utility (#2903)
Summary: The "instruments" utility was deprecated in Xcode 12 and removed now from Xcode 13, causing all the iOS 15 / Xcode 13 builds to fail to work with Flipper. See deprecation notice here: https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes > The instruments command is now deprecated in favor of its replacement: xctrace. Use xctrace to record, import, and export data from Instruments .trace files. (36641078) The corresponding bug was reported here: https://github.com/facebook/flipper/issues/2896 That call should be replaced with `xcrun xctrace` run and that is what we are doing here. IMPORTANT: There was a workaround on killing the stale `instruments` proceses and that utility function is removed as part of this PR, as `instruments` were slow and inefficient, marked for deprecation more than a year ago. `xctrace` should not have that kind of issue and it doesn't make sense to keep this workaround now. ## Changelog The "instruments" call replaced with `xcrun xctrace` use, to align with deprecation introduced in Xcode 12 and offer Xcode 13 compatibility. Pull Request resolved: https://github.com/facebook/flipper/pull/2903 Test Plan: In order to test this we should run the Flipper desktop app and make sure it connects to the Simulator started out of Xcode 13 It fails to do so in `master` version right now, see https://github.com/facebook/flipper/issues/2896 Reviewed By: mweststrate Differential Revision: D31150276 Pulled By: passy fbshipit-source-id: 0b45ae23c15a8481a91b1effe814176b04adbf3e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
18fbde50f2
commit
795a3d30a0
@@ -10,7 +10,6 @@
|
||||
import React from 'react';
|
||||
import {Mutex} from 'async-mutex';
|
||||
import {exec as unsafeExec, Output} from 'promisify-child-process';
|
||||
import {killOrphanedInstrumentsProcesses} from '../../utils/processCleanup';
|
||||
import {reportPlatformFailures} from '../../../utils/metrics';
|
||||
import {promises, constants} from 'fs';
|
||||
import memoize from 'lodash.memoize';
|
||||
@@ -162,14 +161,14 @@ async function targets(
|
||||
|
||||
// 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.
|
||||
// But idb is MUCH more CPU efficient than xcrun, so
|
||||
// when installed, use it. This still holds true
|
||||
// with the move from instruments to xcrun.
|
||||
// TODO: Move idb availability check up.
|
||||
if (await memoize(isAvailable)(idbPath)) {
|
||||
return await idbListTargets(idbPath);
|
||||
} else {
|
||||
await killOrphanedInstrumentsProcesses();
|
||||
return safeExec('instruments -s devices')
|
||||
return safeExec('xcrun xctrace list devices')
|
||||
.then(({stdout}) =>
|
||||
stdout!
|
||||
.toString()
|
||||
@@ -184,7 +183,7 @@ async function targets(
|
||||
}),
|
||||
)
|
||||
.catch((e) => {
|
||||
console.warn('Failed to query instruments:', e);
|
||||
console.warn('Failed to query for devices using xctrace:', e);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {exec} from 'promisify-child-process';
|
||||
import {notNull} from '../utils/typeUtils';
|
||||
import {kill} from 'process';
|
||||
|
||||
// Kills any orphaned Instruments processes belonging to the user.
|
||||
//
|
||||
// In some cases, we've seen interactions between Instruments and the iOS
|
||||
// simulator that cause hung instruments and DTServiceHub processes. If
|
||||
// enough instances pile up, the host machine eventually becomes
|
||||
// unresponsive. Until the underlying issue is resolved, manually kill any
|
||||
// orphaned instances (where the parent process has died and PPID is 1)
|
||||
// before launching another instruments run.
|
||||
export async function killOrphanedInstrumentsProcesses() {
|
||||
const result = await exec('ps -e -o user,ppid,pid,comm');
|
||||
result.stdout
|
||||
?.toString()
|
||||
.split('\n')
|
||||
.filter(notNull)
|
||||
.map((a) => /^(\S+)\s+1\s+(\d+)\s+(.+)$/.exec(a))
|
||||
.filter(notNull)
|
||||
.filter((m) => m[1] === process.env.USER)
|
||||
.filter(
|
||||
(m) =>
|
||||
m[3] &&
|
||||
['/instruments', '/DTServiceHub'].some((name) => m[3].endsWith(name)),
|
||||
)
|
||||
.forEach((m) => {
|
||||
const pid = m[2];
|
||||
console.debug(`Killing orphaned Instruments process: ${pid}`);
|
||||
kill(parseInt(pid, 10), 'SIGKILL');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user