livedesk 0.1.457 → 0.1.458
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/package.json +5 -5
- package/diagnostics/livedesk-mac-physical-gate-core.mjs +389 -36
- package/diagnostics/livedesk-mode3-capture-smoke.mjs +140 -21
- package/hub/package.json +1 -1
- package/hub/src/remote-hub.js +28 -10
- package/package.json +6 -6
- package/web/dist/assets/index-JqqQ5DKN.js +25 -0
- package/web/dist/index.html +1 -1
- package/web/dist/assets/index-Bv9NFUjC.js +0 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import assert from 'node:assert/strict';
|
|
4
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
+
import { execFile, spawn, spawnSync } from 'node:child_process';
|
|
5
5
|
import { createHash, randomBytes } from 'node:crypto';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { chmod, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
@@ -13,13 +13,15 @@ import { fileURLToPath } from 'node:url';
|
|
|
13
13
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
14
14
|
import WebSocket from 'ws';
|
|
15
15
|
import {
|
|
16
|
+
buildMacDiagnosticResourceSample,
|
|
16
17
|
buildMacModifierProbeSteps,
|
|
17
18
|
buildMacModifierReleaseSteps,
|
|
18
19
|
classifyMacPhysicalGate,
|
|
20
|
+
createAsyncSingleFlightSampler,
|
|
19
21
|
noteMacModifierAfterAppliedAck,
|
|
20
22
|
noteMacModifierBeforeSend,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
parseMacLiveDeskRuntimeProcesses,
|
|
24
|
+
summarizeMacDiagnosticResourceSamples
|
|
23
25
|
} from './livedesk-mac-physical-gate-core.mjs';
|
|
24
26
|
import {
|
|
25
27
|
acquireMacDiagnosticLease,
|
|
@@ -38,6 +40,7 @@ const publicMacPhysicalDiagnostic = String(rawArguments[0] || '').toLowerCase()
|
|
|
38
40
|
const macPhysicalGate = process.argv.includes('--mac-physical-gate') || publicMacPhysicalDiagnostic;
|
|
39
41
|
const isWindows = process.platform === 'win32';
|
|
40
42
|
const isMacPhysicalGate = process.platform === 'darwin' && macPhysicalGate;
|
|
43
|
+
const MAC_PHYSICAL_RESOURCE_SAMPLE_INTERVAL_MS = 500;
|
|
41
44
|
if (macPhysicalGate && !isMacPhysicalGate) {
|
|
42
45
|
const message = 'Mac physical diagnostic requires macOS hardware; no LiveDesk process was started.';
|
|
43
46
|
if (publicMacPhysicalDiagnostic) {
|
|
@@ -313,9 +316,28 @@ function readMacProcessSnapshot() {
|
|
|
313
316
|
return String(result.stdout || '');
|
|
314
317
|
}
|
|
315
318
|
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
function readMacProcessResourceSnapshot() {
|
|
320
|
+
return new Promise((resolveSnapshot, rejectSnapshot) => {
|
|
321
|
+
execFile(
|
|
322
|
+
'/bin/ps',
|
|
323
|
+
['-axo', 'pid=,ppid=,comm=,%cpu=,rss=,args='],
|
|
324
|
+
{
|
|
325
|
+
encoding: 'utf8',
|
|
326
|
+
timeout: 2_000,
|
|
327
|
+
windowsHide: true,
|
|
328
|
+
maxBuffer: 4 * 1024 * 1024
|
|
329
|
+
},
|
|
330
|
+
(error, stdout, stderr) => {
|
|
331
|
+
if (error) {
|
|
332
|
+
rejectSnapshot(new Error(
|
|
333
|
+
`resource ps failed: ${String(stderr || error.message || error)}`
|
|
334
|
+
));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
resolveSnapshot(String(stdout || ''));
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
});
|
|
319
341
|
}
|
|
320
342
|
|
|
321
343
|
function readConflictingMacLiveDeskRuntimes() {
|
|
@@ -469,6 +491,10 @@ async function decodeKeyFrame(accessUnit, label) {
|
|
|
469
491
|
windowsHide: true
|
|
470
492
|
});
|
|
471
493
|
ownedDecoders.set(decoder, { directory, label });
|
|
494
|
+
if (isMacPhysicalGate && Number(decoder?.pid || 0) > 1) {
|
|
495
|
+
macOwnedDecoderPids.add(Number(decoder.pid));
|
|
496
|
+
requestMacResourceSample('steadyCapture');
|
|
497
|
+
}
|
|
472
498
|
let errors = '';
|
|
473
499
|
let settled = false;
|
|
474
500
|
let unsubscribeAbort = () => {};
|
|
@@ -566,12 +592,20 @@ let hub;
|
|
|
566
592
|
let agent;
|
|
567
593
|
let frameSocket;
|
|
568
594
|
const ownedDecoders = new Map();
|
|
595
|
+
const macOwnedDecoderPids = new Set();
|
|
569
596
|
let hubLogs = [];
|
|
570
597
|
let agentLogs = [];
|
|
571
598
|
let helperSampleTimer;
|
|
572
599
|
let helperMaxConcurrent = 0;
|
|
573
600
|
const helperObservedPids = new Set();
|
|
574
601
|
let helperFinalCount = 0;
|
|
602
|
+
let macResourcePhase = '';
|
|
603
|
+
const macResourceSamples = {
|
|
604
|
+
baseline: [],
|
|
605
|
+
steadyCapture: [],
|
|
606
|
+
afterCleanup: []
|
|
607
|
+
};
|
|
608
|
+
const macResourceSamplingErrors = new Set();
|
|
575
609
|
let macModifierProbe = { expectedAcks: 8, appliedAcks: 0, applied: [], errors: [] };
|
|
576
610
|
let macInitialPixelHash = '';
|
|
577
611
|
let macNextPixelHash = '';
|
|
@@ -590,12 +624,62 @@ let macRunError = '';
|
|
|
590
624
|
const macCleanupErrors = [];
|
|
591
625
|
const macSignalHandlers = new Map();
|
|
592
626
|
|
|
593
|
-
const
|
|
627
|
+
const collectMacResourceSample = async phase => {
|
|
628
|
+
if (!isMacPhysicalGate) {
|
|
629
|
+
return {
|
|
630
|
+
totalLiveDeskProcessCount: 0,
|
|
631
|
+
captureHelperCount: 0,
|
|
632
|
+
unownedLiveDeskPids: [],
|
|
633
|
+
processes: []
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
let sample;
|
|
637
|
+
try {
|
|
638
|
+
sample = buildMacDiagnosticResourceSample(
|
|
639
|
+
await readMacProcessResourceSnapshot(),
|
|
640
|
+
{
|
|
641
|
+
diagnosticPid: process.pid,
|
|
642
|
+
hubPid: hub?.pid,
|
|
643
|
+
agentPid: agent?.pid,
|
|
644
|
+
decoderPids: [...ownedDecoders.keys()]
|
|
645
|
+
.filter(decoder => decoder?.exitCode === null && decoder?.signalCode === null)
|
|
646
|
+
.map(decoder => decoder?.pid)
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
} catch {
|
|
650
|
+
const safePhase = String(phase || 'unassigned').replace(/[^a-z-]/gi, '') || 'unassigned';
|
|
651
|
+
macResourceSamplingErrors.add(`${safePhase}:unavailable`);
|
|
652
|
+
throw new Error(`Mac ${safePhase} process resource telemetry is unavailable.`);
|
|
653
|
+
}
|
|
654
|
+
helperMaxConcurrent = Math.max(helperMaxConcurrent, sample.captureHelperCount);
|
|
655
|
+
for (const helper of sample.processes.filter(record => record.role === 'capture-helper')) {
|
|
656
|
+
helperObservedPids.add(helper.pid);
|
|
657
|
+
}
|
|
658
|
+
if (Object.prototype.hasOwnProperty.call(macResourceSamples, phase)) {
|
|
659
|
+
const phaseSamples = macResourceSamples[phase];
|
|
660
|
+
phaseSamples.push(sample);
|
|
661
|
+
while (phaseSamples.length > 240) phaseSamples.shift();
|
|
662
|
+
}
|
|
663
|
+
return sample;
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const macResourceSampler = createAsyncSingleFlightSampler(collectMacResourceSample);
|
|
667
|
+
|
|
668
|
+
const sampleMacResources = phase => macResourceSampler.run(phase);
|
|
669
|
+
|
|
670
|
+
const requestMacResourceSample = phase => {
|
|
671
|
+
const pending = macResourceSampler.request(phase);
|
|
672
|
+
pending?.catch(() => {
|
|
673
|
+
// A later required sample reports persistent process telemetry failure.
|
|
674
|
+
});
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const sampleMacHelpers = async () => {
|
|
594
678
|
if (!isMacPhysicalGate) return [];
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
679
|
+
const sample = await sampleMacResources(macResourcePhase);
|
|
680
|
+
return sample.processes
|
|
681
|
+
.filter(record => record.role === 'capture-helper')
|
|
682
|
+
.map(record => ({ pid: record.pid }));
|
|
599
683
|
};
|
|
600
684
|
|
|
601
685
|
async function stopMacAgentAndSampleDrain() {
|
|
@@ -614,7 +698,7 @@ async function stopMacAgentAndSampleDrain() {
|
|
|
614
698
|
} finally {
|
|
615
699
|
const drainDeadline = Date.now() + 5_000;
|
|
616
700
|
do {
|
|
617
|
-
const helpers = sampleMacHelpers();
|
|
701
|
+
const helpers = await sampleMacHelpers();
|
|
618
702
|
helperFinalCount = helpers.length;
|
|
619
703
|
if (helperFinalCount === 0) break;
|
|
620
704
|
await delay(100);
|
|
@@ -641,8 +725,27 @@ async function writeMacPhysicalGateReport() {
|
|
|
641
725
|
while (true) {
|
|
642
726
|
const diagnostic = readDiagnosticState();
|
|
643
727
|
const stateToken = diagnosticStateToken(diagnostic);
|
|
728
|
+
const expectedSteadyProcesses = [
|
|
729
|
+
{ role: 'hub', pid: hub?.pid, ownedByDiagnostic: true },
|
|
730
|
+
{ role: 'remote-fast', pid: agent?.pid, ownedByDiagnostic: true },
|
|
731
|
+
...[...macOwnedDecoderPids].map(pid => ({
|
|
732
|
+
role: 'decoder',
|
|
733
|
+
pid,
|
|
734
|
+
ownedByDiagnostic: true
|
|
735
|
+
}))
|
|
736
|
+
];
|
|
737
|
+
const resources = {
|
|
738
|
+
sampleIntervalMs: MAC_PHYSICAL_RESOURCE_SAMPLE_INTERVAL_MS,
|
|
739
|
+
samplingErrors: [...macResourceSamplingErrors],
|
|
740
|
+
baseline: summarizeMacDiagnosticResourceSamples(macResourceSamples.baseline),
|
|
741
|
+
steadyCapture: summarizeMacDiagnosticResourceSamples(
|
|
742
|
+
macResourceSamples.steadyCapture,
|
|
743
|
+
{ expectedProcesses: expectedSteadyProcesses }
|
|
744
|
+
),
|
|
745
|
+
afterCleanup: summarizeMacDiagnosticResourceSamples(macResourceSamples.afterCleanup)
|
|
746
|
+
};
|
|
644
747
|
snapshot = {
|
|
645
|
-
schemaVersion:
|
|
748
|
+
schemaVersion: 2,
|
|
646
749
|
generatedAt,
|
|
647
750
|
runtimeId: clientRuntimeId,
|
|
648
751
|
requestedFps: 30,
|
|
@@ -665,6 +768,7 @@ async function writeMacPhysicalGateReport() {
|
|
|
665
768
|
},
|
|
666
769
|
modifier: macModifierProbe,
|
|
667
770
|
transport: macTransport,
|
|
771
|
+
resources,
|
|
668
772
|
diagnostic,
|
|
669
773
|
error: diagnostic.runError
|
|
670
774
|
};
|
|
@@ -688,6 +792,13 @@ async function writeMacPhysicalGateReport() {
|
|
|
688
792
|
`Mac physical gate helper: max=${helperMaxConcurrent}, final=${helperFinalCount}, `
|
|
689
793
|
+ `pids=${[...helperObservedPids].join(',') || '-'}.`
|
|
690
794
|
);
|
|
795
|
+
const resourceEvidence = snapshot.resources;
|
|
796
|
+
console.log(
|
|
797
|
+
`Mac physical gate resources: baseline=${resourceEvidence.baseline.totalLiveDeskProcessCount}, `
|
|
798
|
+
+ `steady-peak=${resourceEvidence.steadyCapture.totalLiveDeskProcessCountPeak}, `
|
|
799
|
+
+ `after-cleanup=${resourceEvidence.afterCleanup.totalLiveDeskProcessCount}, `
|
|
800
|
+
+ `samples=${resourceEvidence.steadyCapture.sampleCount}.`
|
|
801
|
+
);
|
|
691
802
|
console.log(
|
|
692
803
|
`Mac physical gate monitor: count=${macMonitorCount}, generation=${macInitialGeneration}->${macNextGeneration}, `
|
|
693
804
|
+ `pixels=${macInitialPixelHash.slice(0, 12) || '-'}->${macNextPixelHash.slice(0, 12) || '-'}.`
|
|
@@ -766,6 +877,12 @@ async function cleanupOwnedDiagnosticResources() {
|
|
|
766
877
|
}
|
|
767
878
|
}
|
|
768
879
|
if (!isMacPhysicalGate) return;
|
|
880
|
+
macResourcePhase = 'afterCleanup';
|
|
881
|
+
try {
|
|
882
|
+
await sampleMacResources(macResourcePhase);
|
|
883
|
+
} catch (error) {
|
|
884
|
+
recordMacCleanupError('resource-snapshot-after-cleanup', error);
|
|
885
|
+
}
|
|
769
886
|
const teardownPlan = buildMacDiagnosticTeardownPlan({
|
|
770
887
|
agentStopped,
|
|
771
888
|
hubStopped,
|
|
@@ -843,14 +960,12 @@ try {
|
|
|
843
960
|
macIsolation = await prepareMacDiagnosticIsolation();
|
|
844
961
|
if (isMacPhysicalGate) {
|
|
845
962
|
macDiagnosticAbort.throwIfRequested();
|
|
846
|
-
|
|
963
|
+
macResourcePhase = 'baseline';
|
|
964
|
+
await sampleMacResources(macResourcePhase);
|
|
965
|
+
macResourcePhase = '';
|
|
847
966
|
helperSampleTimer = setInterval(() => {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
} catch {
|
|
851
|
-
// The final synchronous sample reports a persistent ps failure.
|
|
852
|
-
}
|
|
853
|
-
}, 100);
|
|
967
|
+
requestMacResourceSample(macResourcePhase);
|
|
968
|
+
}, MAC_PHYSICAL_RESOURCE_SAMPLE_INTERVAL_MS);
|
|
854
969
|
helperSampleTimer.unref?.();
|
|
855
970
|
}
|
|
856
971
|
const isolatedHubEnvironment = isMacPhysicalGate
|
|
@@ -989,7 +1104,11 @@ try {
|
|
|
989
1104
|
frameSocket.on('message', handleMessage);
|
|
990
1105
|
});
|
|
991
1106
|
|
|
992
|
-
|
|
1107
|
+
if (isMacPhysicalGate) {
|
|
1108
|
+
macResourcePhase = 'steadyCapture';
|
|
1109
|
+
await sampleMacResources(macResourcePhase);
|
|
1110
|
+
}
|
|
1111
|
+
frameSocket.send(JSON.stringify({
|
|
993
1112
|
type: 'subscribe',
|
|
994
1113
|
deviceIds: [connectedDeviceId],
|
|
995
1114
|
autoStartLive: true,
|
package/hub/package.json
CHANGED
package/hub/src/remote-hub.js
CHANGED
|
@@ -690,21 +690,39 @@ const SUPPORTED_AGENT_OPERATIONS = new Set([
|
|
|
690
690
|
'logs.collect'
|
|
691
691
|
]);
|
|
692
692
|
|
|
693
|
-
function normalizeAgentOperation(value) {
|
|
694
|
-
const operation = safeString(value, 80).toLowerCase();
|
|
695
|
-
return SUPPORTED_AGENT_OPERATIONS.has(operation) ? operation : '';
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
693
|
+
function normalizeAgentOperation(value) {
|
|
694
|
+
const operation = safeString(value, 80).toLowerCase();
|
|
695
|
+
return SUPPORTED_AGENT_OPERATIONS.has(operation) ? operation : '';
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const REMOTE_INPUT_MONITOR_KEYS = Object.freeze([
|
|
699
|
+
'monitorIndex',
|
|
700
|
+
'MonitorIndex',
|
|
701
|
+
'screenIndex',
|
|
702
|
+
'ScreenIndex',
|
|
703
|
+
'displayIndex',
|
|
704
|
+
'DisplayIndex'
|
|
705
|
+
]);
|
|
706
|
+
|
|
707
|
+
function readRawRemoteInputMonitorIndex(input) {
|
|
708
|
+
for (const key of REMOTE_INPUT_MONITOR_KEYS) {
|
|
709
|
+
if (Object.prototype.hasOwnProperty.call(input, key)) {
|
|
710
|
+
return input[key];
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return undefined;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function normalizeRemoteInputEvent(value = {}) {
|
|
717
|
+
const input = value && typeof value === 'object' ? value : {};
|
|
718
|
+
const type = safeString(input.type || input.Type, 48);
|
|
701
719
|
const normalizedX = Number(input.normalizedX ?? input.NormalizedX);
|
|
702
720
|
const normalizedY = Number(input.normalizedY ?? input.NormalizedY);
|
|
703
721
|
const deltaX = Number(input.deltaX ?? input.DeltaX);
|
|
704
722
|
const deltaY = Number(input.deltaY ?? input.DeltaY);
|
|
705
723
|
const keyCode = Number(input.keyCode ?? input.KeyCode);
|
|
706
724
|
const location = Number(input.location ?? input.Location);
|
|
707
|
-
const monitorIndex =
|
|
725
|
+
const monitorIndex = parseExactLiveStreamMonitorIndex(readRawRemoteInputMonitorIndex(input));
|
|
708
726
|
const inputSeq = Number(input.inputSeq ?? input.InputSeq);
|
|
709
727
|
const issuedAtEpochMs = Number(input.issuedAtEpochMs ?? input.IssuedAtEpochMs);
|
|
710
728
|
const hubReceivedAtEpochMs = Number(input.hubReceivedAtEpochMs ?? input.HubReceivedAtEpochMs);
|
|
@@ -720,7 +738,7 @@ function normalizeRemoteInputEvent(value = {}) {
|
|
|
720
738
|
type,
|
|
721
739
|
// A missing monitor is not equivalent to the primary display. Control
|
|
722
740
|
// input must prove the exact monitor owned by its capture generation.
|
|
723
|
-
monitorIndex
|
|
741
|
+
monitorIndex,
|
|
724
742
|
normalizedX: Number.isFinite(normalizedX) ? Math.max(0, Math.min(1, normalizedX)) : undefined,
|
|
725
743
|
normalizedY: Number.isFinite(normalizedY) ? Math.max(0, Math.min(1, normalizedY)) : undefined,
|
|
726
744
|
button: safeString(input.button || input.Button, 24),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livedesk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"livedeskClientVersion": "0.1.
|
|
3
|
+
"version": "0.1.458",
|
|
4
|
+
"livedeskClientVersion": "0.1.212",
|
|
5
5
|
"buildFlavor": "production",
|
|
6
6
|
"description": "LiveDesk Hub and client launcher",
|
|
7
7
|
"type": "module",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"ws": "^8.18.3"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@livedesk/fast-linux-x64": "0.1.
|
|
54
|
-
"@livedesk/fast-osx-arm64": "0.1.
|
|
55
|
-
"@livedesk/fast-osx-x64": "0.1.
|
|
56
|
-
"@livedesk/fast-win-x64": "0.1.
|
|
53
|
+
"@livedesk/fast-linux-x64": "0.1.416",
|
|
54
|
+
"@livedesk/fast-osx-arm64": "0.1.416",
|
|
55
|
+
"@livedesk/fast-osx-x64": "0.1.416",
|
|
56
|
+
"@livedesk/fast-win-x64": "0.1.416"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|