@hyperframes/producer 0.10.4 → 0.10.6
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/dist/distributed.js +63 -32
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +66 -66
- package/dist/index.js +138 -45
- package/dist/public-server.js +135 -39
- package/dist/services/render/captureCost.d.ts +4 -0
- package/dist/services/render/captureStageError.d.ts +1 -0
- package/dist/services/render/stages/captureEncoder.d.ts +3 -0
- package/dist/services/render/stages/captureSegmentedStage.d.ts +3 -2
- package/dist/services/render/stages/captureStreamingStage.d.ts +4 -3
- package/dist/services/render/stages/encodeStage.d.ts +1 -26
- package/dist/services/renderOrchestrator.d.ts +2 -0
- package/package.json +8 -8
package/dist/distributed.js
CHANGED
|
@@ -348,7 +348,7 @@ import {
|
|
|
348
348
|
getSystemTotalMb,
|
|
349
349
|
LOW_MEMORY_TOTAL_MB_THRESHOLD,
|
|
350
350
|
assertConfiguredFfmpegBinariesExist,
|
|
351
|
-
resolveBrowserGpuMode,
|
|
351
|
+
resolveBrowserGpuMode as resolveBrowserGpuMode2,
|
|
352
352
|
probedHardwareGpu,
|
|
353
353
|
resolveHeadlessShellPath,
|
|
354
354
|
compositionRequiresWebGpu as compositionRequiresWebGpu2,
|
|
@@ -356,7 +356,8 @@ import {
|
|
|
356
356
|
explainDrawElementDisabled,
|
|
357
357
|
chromeMajorCeiling,
|
|
358
358
|
scaleProtocolTimeoutForComposition,
|
|
359
|
-
|
|
359
|
+
captureMemoryRetryWorkers as captureMemoryRetryWorkers2,
|
|
360
|
+
classifyCaptureFailure as classifyCaptureFailure4,
|
|
360
361
|
cloneCaptureWarning,
|
|
361
362
|
isMemoryExhaustionError as isMemoryExhaustionError2,
|
|
362
363
|
isTransientBrowserError as isTransientBrowserError2,
|
|
@@ -1660,8 +1661,7 @@ import {
|
|
|
1660
1661
|
initializeSession as initializeSession2,
|
|
1661
1662
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
|
|
1662
1663
|
resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
|
|
1663
|
-
shouldDisableBrowserPoolForParallelWorker
|
|
1664
|
-
spawnStreamingEncoder as spawnStreamingEncoder2
|
|
1664
|
+
shouldDisableBrowserPoolForParallelWorker
|
|
1665
1665
|
} from "@hyperframes/engine";
|
|
1666
1666
|
|
|
1667
1667
|
// src/services/render/captureStageError.ts
|
|
@@ -1687,6 +1687,7 @@ function withWorkerPageErrors(consoleLines, workerLines) {
|
|
|
1687
1687
|
// src/services/render/captureStageError.ts
|
|
1688
1688
|
var CaptureStageError = class extends CaptureFailure {
|
|
1689
1689
|
browserConsole;
|
|
1690
|
+
memoryRetryUsed = false;
|
|
1690
1691
|
constructor(input) {
|
|
1691
1692
|
const classified = classifyCaptureFailure(input.cause);
|
|
1692
1693
|
super({
|
|
@@ -1774,6 +1775,8 @@ import {
|
|
|
1774
1775
|
captureFrameToBuffer,
|
|
1775
1776
|
captureFrameToBufferPipelined,
|
|
1776
1777
|
captureFramesBatchPipelined,
|
|
1778
|
+
captureMemoryRetryWorkers,
|
|
1779
|
+
classifyCaptureFailure as classifyCaptureFailure2,
|
|
1777
1780
|
closeCaptureSession,
|
|
1778
1781
|
createCaptureSession,
|
|
1779
1782
|
createFrameReorderBuffer,
|
|
@@ -1787,8 +1790,7 @@ import {
|
|
|
1787
1790
|
recaptureDrawElementFrameForVerify,
|
|
1788
1791
|
completeDeferredDrawElementInit,
|
|
1789
1792
|
initializeSession,
|
|
1790
|
-
prepareCaptureSessionForReuse
|
|
1791
|
-
spawnStreamingEncoder
|
|
1793
|
+
prepareCaptureSessionForReuse
|
|
1792
1794
|
} from "@hyperframes/engine";
|
|
1793
1795
|
|
|
1794
1796
|
// src/services/render/stallClock.ts
|
|
@@ -1810,6 +1812,17 @@ function createStallClock(now = () => Date.now()) {
|
|
|
1810
1812
|
};
|
|
1811
1813
|
}
|
|
1812
1814
|
|
|
1815
|
+
// src/services/render/stages/captureEncoder.ts
|
|
1816
|
+
import { spawnStreamingEncoder } from "@hyperframes/engine";
|
|
1817
|
+
function spawnCaptureEncoder(...[outputPath, options, signal, config]) {
|
|
1818
|
+
return spawnStreamingEncoder(
|
|
1819
|
+
outputPath,
|
|
1820
|
+
{ ...options, belowNormalPriority: true },
|
|
1821
|
+
signal,
|
|
1822
|
+
config
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1813
1826
|
// src/services/render/stages/captureStreamingStage.ts
|
|
1814
1827
|
var DEFAULT_CAPTURE_STALL_MS = 6e4;
|
|
1815
1828
|
var SESSION_INIT_STALL_MS = 3e5;
|
|
@@ -1933,10 +1946,13 @@ import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
|
|
|
1933
1946
|
import {
|
|
1934
1947
|
calculateOptimalWorkers,
|
|
1935
1948
|
captureFrameToBuffer as captureFrameToBuffer3,
|
|
1949
|
+
clearStaticDedupAnchor,
|
|
1936
1950
|
closeCaptureSession as closeCaptureSession3,
|
|
1937
1951
|
computeWorkerSizing,
|
|
1938
1952
|
createCaptureSession as createCaptureSession3,
|
|
1939
|
-
initializeSession as initializeSession3
|
|
1953
|
+
initializeSession as initializeSession3,
|
|
1954
|
+
readChromeCpuSeconds,
|
|
1955
|
+
resolveBrowserGpuMode
|
|
1940
1956
|
} from "@hyperframes/engine";
|
|
1941
1957
|
var CAPTURE_CALIBRATION_TARGET_MS = 600;
|
|
1942
1958
|
var MAX_MEASURED_CAPTURE_COST_MULTIPLIER = 8;
|
|
@@ -2007,7 +2023,7 @@ async function measureCaptureCostFromSession(session, totalFrames, fps, log, fir
|
|
|
2007
2023
|
}
|
|
2008
2024
|
} finally {
|
|
2009
2025
|
session.staticFrames = savedStaticFrames;
|
|
2010
|
-
session
|
|
2026
|
+
clearStaticDedupAnchor(session);
|
|
2011
2027
|
}
|
|
2012
2028
|
const estimate = estimateMeasuredCaptureCostMultiplier(samples);
|
|
2013
2029
|
if (estimate.p95Ms !== void 0) {
|
|
@@ -8678,7 +8694,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
|
|
|
8678
8694
|
import { existsSync as existsSync13, readdirSync, statfsSync } from "node:fs";
|
|
8679
8695
|
import { join as join18 } from "node:path";
|
|
8680
8696
|
import {
|
|
8681
|
-
classifyCaptureFailure as
|
|
8697
|
+
classifyCaptureFailure as classifyCaptureFailure3,
|
|
8682
8698
|
frameFileExtension,
|
|
8683
8699
|
captureFrame,
|
|
8684
8700
|
captureFrameToBufferPipelined as captureFrameToBufferPipelined2,
|
|
@@ -8966,7 +8982,7 @@ function resolveCaptureRange(frameRange, totalFrames) {
|
|
|
8966
8982
|
return { rangeStart: frameRange?.startFrame ?? 0, rangeEnd: frameRange?.endFrame ?? totalFrames };
|
|
8967
8983
|
}
|
|
8968
8984
|
function planTransientResume(error, ctx) {
|
|
8969
|
-
const failure =
|
|
8985
|
+
const failure = classifyCaptureFailure3(error, { signal: ctx.abortSignal });
|
|
8970
8986
|
const missing = findMissingFrameRanges(ctx.rangeFrames, ctx.framesDir, ctx.frameExt);
|
|
8971
8987
|
const [firstMissing] = missing;
|
|
8972
8988
|
if (!firstMissing) return null;
|
|
@@ -9060,8 +9076,7 @@ import {
|
|
|
9060
9076
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
9061
9077
|
createCaptureSession as createCaptureSession7,
|
|
9062
9078
|
initTransparentBackground as initTransparentBackground2,
|
|
9063
|
-
initializeSession as initializeSession7
|
|
9064
|
-
spawnStreamingEncoder as spawnStreamingEncoder3
|
|
9079
|
+
initializeSession as initializeSession7
|
|
9065
9080
|
} from "@hyperframes/engine";
|
|
9066
9081
|
import { fpsToNumber as fpsToNumber7 } from "@hyperframes/core";
|
|
9067
9082
|
|
|
@@ -9108,8 +9123,7 @@ import {
|
|
|
9108
9123
|
formatFfmpegError,
|
|
9109
9124
|
MIXED_AUDIO_FILENAME as MIXED_AUDIO_FILENAME2,
|
|
9110
9125
|
resolveConfig,
|
|
9111
|
-
runFfmpeg as runFfmpeg6
|
|
9112
|
-
spawnStreamingEncoder as spawnStreamingEncoder4
|
|
9126
|
+
runFfmpeg as runFfmpeg6
|
|
9113
9127
|
} from "@hyperframes/engine";
|
|
9114
9128
|
import {
|
|
9115
9129
|
clearGifFramesBeforeNext,
|
|
@@ -9249,10 +9263,7 @@ function startEncodeProgress(job, stage, onProgress) {
|
|
|
9249
9263
|
function resolveEngineConfig(input) {
|
|
9250
9264
|
return input.engineConfig ?? input.job.config.producerConfig ?? resolveConfig();
|
|
9251
9265
|
}
|
|
9252
|
-
function
|
|
9253
|
-
return Math.max(1, Math.floor(cpuCount) - Math.floor(workerCount));
|
|
9254
|
-
}
|
|
9255
|
-
function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
9266
|
+
function videoEncoderOptions(input, engineCfg) {
|
|
9256
9267
|
const { job, preset } = input;
|
|
9257
9268
|
return {
|
|
9258
9269
|
fps: job.config.fps,
|
|
@@ -9272,8 +9283,7 @@ function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
|
9272
9283
|
// keyframes that survive `-f concat -c copy` at assemble time. In-process
|
|
9273
9284
|
// renders leave both undefined → preserves the existing open-GOP output.
|
|
9274
9285
|
lockGopForChunkConcat: input.lockGopForChunkConcat === true,
|
|
9275
|
-
gopSize: input.gopSize
|
|
9276
|
-
softwareEncoderThreads
|
|
9286
|
+
gopSize: input.gopSize
|
|
9277
9287
|
};
|
|
9278
9288
|
}
|
|
9279
9289
|
function canEncodeWhileCapturing(input, workerCount, cpuCount) {
|
|
@@ -9289,9 +9299,8 @@ async function readLandedFrame(workerPath, mergedPath) {
|
|
|
9289
9299
|
}
|
|
9290
9300
|
return readFile2(mergedPath);
|
|
9291
9301
|
}
|
|
9292
|
-
function encodeWhileCapturing(input, totalFrames
|
|
9302
|
+
function encodeWhileCapturing(input, totalFrames) {
|
|
9293
9303
|
const engineCfg = resolveEngineConfig(input);
|
|
9294
|
-
const softwareEncoderThreads = captureBudget ? overlapEncoderThreads(captureBudget.workerCount, captureBudget.cpuCount) : void 0;
|
|
9295
9304
|
const stop = new AbortController();
|
|
9296
9305
|
const signal = input.abortSignal ? AbortSignal.any([input.abortSignal, stop.signal]) : stop.signal;
|
|
9297
9306
|
const landed = /* @__PURE__ */ new Map();
|
|
@@ -9304,10 +9313,10 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
9304
9313
|
};
|
|
9305
9314
|
signal.addEventListener("abort", nudge, { once: true });
|
|
9306
9315
|
let reportFed = null;
|
|
9307
|
-
const encoder =
|
|
9316
|
+
const encoder = spawnCaptureEncoder(
|
|
9308
9317
|
input.videoOnlyPath,
|
|
9309
9318
|
{
|
|
9310
|
-
...videoEncoderOptions(input, engineCfg
|
|
9319
|
+
...videoEncoderOptions(input, engineCfg),
|
|
9311
9320
|
imageFormat: "jpeg"
|
|
9312
9321
|
},
|
|
9313
9322
|
signal,
|
|
@@ -9508,8 +9517,14 @@ var RenderQualityError = class extends Error {
|
|
|
9508
9517
|
);
|
|
9509
9518
|
this.warnings = warnings;
|
|
9510
9519
|
this.name = "RenderQualityError";
|
|
9520
|
+
const failed = warnings.filter((warning) => warning.code === "sub_timeline_script_failure");
|
|
9521
|
+
if (failed.length > 0 && failed.every((warning) => warning.details?.scriptThrew === true)) {
|
|
9522
|
+
this.code = "COMPOSITION_SCRIPT_FAILED";
|
|
9523
|
+
}
|
|
9511
9524
|
}
|
|
9512
9525
|
warnings;
|
|
9526
|
+
/** Set only when the composition's own script threw: rendering it again fails the same way. */
|
|
9527
|
+
code;
|
|
9513
9528
|
};
|
|
9514
9529
|
function applyRenderWarningPolicy(job, captureWarnings, log = defaultLogger) {
|
|
9515
9530
|
job.warnings ??= [];
|
|
@@ -9660,7 +9675,7 @@ function isRecoverableParallelCaptureError(error) {
|
|
|
9660
9675
|
if (error instanceof RenderStageStalledError) return true;
|
|
9661
9676
|
const message = normalizeErrorMessage(error);
|
|
9662
9677
|
if (!message.includes("[Parallel] Capture failed")) return false;
|
|
9663
|
-
const kind =
|
|
9678
|
+
const kind = classifyCaptureFailure4(error).kind;
|
|
9664
9679
|
return kind === "transient_browser" || kind === "protocol_timeout";
|
|
9665
9680
|
}
|
|
9666
9681
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
@@ -9681,6 +9696,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9681
9696
|
let attempt = 0;
|
|
9682
9697
|
let transientRetriesUsed = 0;
|
|
9683
9698
|
let initializationRetriesUsed = 0;
|
|
9699
|
+
let memoryRetriesUsed = 0;
|
|
9684
9700
|
let pendingTransientRetry = false;
|
|
9685
9701
|
const rangeStart = options.frameRangeStart ?? 0;
|
|
9686
9702
|
while (true) {
|
|
@@ -9780,7 +9796,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9780
9796
|
attempt++;
|
|
9781
9797
|
} catch (caught) {
|
|
9782
9798
|
const error = attemptSignal?.aborted && !options.abortSignal?.aborted ? attemptSignal.reason : caught;
|
|
9783
|
-
const failure =
|
|
9799
|
+
const failure = classifyCaptureFailure4(error, { signal: options.abortSignal });
|
|
9784
9800
|
if (failure.kind === "cancelled") {
|
|
9785
9801
|
throw error;
|
|
9786
9802
|
}
|
|
@@ -9830,6 +9846,24 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9830
9846
|
pendingTransientRetry = true;
|
|
9831
9847
|
continue;
|
|
9832
9848
|
}
|
|
9849
|
+
const fitWorkers = memoryRetriesUsed === 0 && failure.kind === "memory_exhaustion" ? captureMemoryRetryWorkers2(error) : void 0;
|
|
9850
|
+
if (options.allowRetry && currentWorkers > 1 && fitWorkers !== void 0) {
|
|
9851
|
+
memoryRetriesUsed++;
|
|
9852
|
+
const nextWorkers2 = Math.min(fitWorkers, currentWorkers - 1);
|
|
9853
|
+
options.log.warn(
|
|
9854
|
+
"[Render] Capture stopped before memory ran out; retrying missing frames with fewer workers.",
|
|
9855
|
+
{
|
|
9856
|
+
fromWorkers: currentWorkers,
|
|
9857
|
+
toWorkers: nextWorkers2,
|
|
9858
|
+
missingFrames: remainingCount,
|
|
9859
|
+
error: failure.message
|
|
9860
|
+
}
|
|
9861
|
+
);
|
|
9862
|
+
currentWorkers = nextWorkers2;
|
|
9863
|
+
missingRanges = remaining;
|
|
9864
|
+
attempt++;
|
|
9865
|
+
continue;
|
|
9866
|
+
}
|
|
9833
9867
|
if (!madeProgress) {
|
|
9834
9868
|
options.log.warn(
|
|
9835
9869
|
"[Render] Capture attempt made no forward progress; composition is likely structurally broken, not retrying.",
|
|
@@ -13798,7 +13832,7 @@ import { join as join34 } from "node:path";
|
|
|
13798
13832
|
import {
|
|
13799
13833
|
assertSwiftShader,
|
|
13800
13834
|
BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
|
|
13801
|
-
classifyCaptureFailure as
|
|
13835
|
+
classifyCaptureFailure as classifyCaptureFailure5,
|
|
13802
13836
|
computeWorkerSizing as computeWorkerSizing2,
|
|
13803
13837
|
closeCaptureSession as closeCaptureSession11,
|
|
13804
13838
|
createCaptureSession as createCaptureSession11,
|
|
@@ -13910,7 +13944,7 @@ function observedChunkCaptureMode(perfs) {
|
|
|
13910
13944
|
}
|
|
13911
13945
|
var PROBE_SELECTED_SCREENSHOT = "[renderChunk] probe selected screenshot capture";
|
|
13912
13946
|
function shouldRetryChunkCaptureWithScreenshot(error) {
|
|
13913
|
-
const failure =
|
|
13947
|
+
const failure = classifyCaptureFailure5(error);
|
|
13914
13948
|
if (failure.kind === "cancelled" || failure.kind === "memory_exhaustion") return false;
|
|
13915
13949
|
return /HeadlessExperimental\.beginFrame/i.test(failure.message) || /beginFrame probe timeout/i.test(failure.message) || failure.message.includes(PROBE_SELECTED_SCREENSHOT) || /Another frame is pending|Frame still pending/i.test(failure.message);
|
|
13916
13950
|
}
|
|
@@ -14401,10 +14435,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14401
14435
|
const captureSession = session;
|
|
14402
14436
|
session = null;
|
|
14403
14437
|
verifyStarted = Date.now();
|
|
14404
|
-
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpuBudget2()) ? encodeWhileCapturing(encodeInput, framesInChunk
|
|
14405
|
-
workerCount: chunkWorkerCount,
|
|
14406
|
-
cpuCount: cpuBudget2()
|
|
14407
|
-
}) : null;
|
|
14438
|
+
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpuBudget2()) ? encodeWhileCapturing(encodeInput, framesInChunk) : null;
|
|
14408
14439
|
await observeRenderStage(
|
|
14409
14440
|
new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
|
|
14410
14441
|
"capture_chunk",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "902af35de9e8d59903bf866fd6e0dec48f5430b88d3bc93f79f1129bd2153560",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|