Skip to content

Commit ce1eb56

Browse files
fix: Simplify screenrecord termination (#1017)
1 parent 417ad3c commit ce1eb56

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/commands/recordscreen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ async function mergeScreenRecords(mediaFiles) {
322322
* @returns {Promise<boolean>}
323323
*/
324324
async function terminateBackgroundScreenRecording(adb, force = true) {
325-
const pids = (await adb.getPIDsByName(SCREENRECORD_BINARY)).map((p) => `${p}`);
326-
if (_.isEmpty(pids)) {
325+
const isScreenrecordRunning = async () => _.includes(await adb.listProcessStatus(), SCREENRECORD_BINARY);
326+
if (!await isScreenrecordRunning()) {
327327
return false;
328328
}
329329

330330
try {
331-
await adb.shell(['kill', force ? '-15' : '-2', ...pids]);
332-
await waitForCondition(async () => _.isEmpty(await adb.getPIDsByName(SCREENRECORD_BINARY)), {
331+
await adb.shell(['killall', force ? '-15' : '-2', SCREENRECORD_BINARY]);
332+
await waitForCondition(async () => !await isScreenrecordRunning(), {
333333
waitMs: PROCESS_SHUTDOWN_TIMEOUT,
334334
intervalMs: 500,
335335
});

0 commit comments

Comments
 (0)