@hyperframes/producer 0.10.4 → 0.10.7
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/README.md +8 -0
- package/dist/compileWorker.js +11 -13
- package/dist/distributed.js +74 -45
- package/dist/healthWorkerThread.js +11 -5
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +66 -66
- package/dist/index.js +155 -60
- package/dist/public-server.js +152 -54
- package/dist/services/healthWorker.d.ts +8 -11
- package/dist/services/healthWorkerThread.d.ts +1 -1
- 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/README.md
CHANGED
|
@@ -55,6 +55,14 @@ server never listens without a token. It listens on `127.0.0.1` unless you pass
|
|
|
55
55
|
token yourself. `createProducerApp` without `authToken`, and `createRenderHandlers`
|
|
56
56
|
always, check no caller: serve them only behind your own authentication.
|
|
57
57
|
|
|
58
|
+
`startServer` also answers `GET /health` on a second port, `PRODUCER_HEALTH_PORT` (default
|
|
59
|
+
`9848`), from its own thread, so a health probe is answered while a render keeps the main
|
|
60
|
+
thread busy. That port listens on the same address as the server itself, so it is loopback
|
|
61
|
+
only by default: a probe from another host needs `hostname` or `PRODUCER_HOST` set to an
|
|
62
|
+
address that host can reach, which also needs a token. A connection there that does not send
|
|
63
|
+
a whole request within a few seconds, or sits idle, is closed, and open connections are
|
|
64
|
+
capped at 64. Set `PRODUCER_DISABLE_HEALTH_WORKER=1` to leave the second port closed.
|
|
65
|
+
|
|
58
66
|
A request's `projectDir` must resolve, symlinks included, inside
|
|
59
67
|
`projectsDir` (`PRODUCER_PROJECTS_DIR`, default: the working directory). Its `entryFile`
|
|
60
68
|
must stay inside that project, and `outputPath` must be inside `rendersDir`
|
package/dist/compileWorker.js
CHANGED
|
@@ -1987,7 +1987,7 @@ async function parseSubCompositions(html, projectDir2, downloadDir2, visited = /
|
|
|
1987
1987
|
}
|
|
1988
1988
|
return { subCompositions };
|
|
1989
1989
|
}
|
|
1990
|
-
function promoteCssImportsToLinkTags(html) {
|
|
1990
|
+
function promoteCssImportsToLinkTags(html, budget) {
|
|
1991
1991
|
const { document: document2 } = parseHTML4(html);
|
|
1992
1992
|
const head = document2.querySelector("head");
|
|
1993
1993
|
if (!head) return html;
|
|
@@ -1996,18 +1996,16 @@ function promoteCssImportsToLinkTags(html) {
|
|
|
1996
1996
|
const styleEls = document2.querySelectorAll("style");
|
|
1997
1997
|
for (const styleEl of styleEls) {
|
|
1998
1998
|
const original = styleEl.textContent || "";
|
|
1999
|
-
|
|
2000
|
-
let
|
|
2001
|
-
importRe
|
|
2002
|
-
while ((match = importRe.exec(original)) !== null) {
|
|
1999
|
+
const rulesBetweenImports = [];
|
|
2000
|
+
let keptTo = 0;
|
|
2001
|
+
for (const match of original.matchAll(importRe)) {
|
|
2003
2002
|
const url = match[1] ?? "";
|
|
2004
2003
|
if (!url.startsWith("http://") && !url.startsWith("https://")) continue;
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
}
|
|
2004
|
+
rulesBetweenImports.push(original.slice(keptTo, match.index));
|
|
2005
|
+
keptTo = match.index + match[0].length;
|
|
2006
|
+
if (seenUrls.has(url)) continue;
|
|
2009
2007
|
seenUrls.add(url);
|
|
2010
|
-
|
|
2008
|
+
budget.chargeElements(ENTRY_PAGE, 2);
|
|
2011
2009
|
const preload = document2.createElement("link");
|
|
2012
2010
|
preload.setAttribute("rel", "preload");
|
|
2013
2011
|
preload.setAttribute("href", url);
|
|
@@ -2018,8 +2016,8 @@ function promoteCssImportsToLinkTags(html) {
|
|
|
2018
2016
|
link.setAttribute("href", url);
|
|
2019
2017
|
head.appendChild(link);
|
|
2020
2018
|
}
|
|
2021
|
-
if (
|
|
2022
|
-
styleEl.textContent =
|
|
2019
|
+
if (keptTo > 0) {
|
|
2020
|
+
styleEl.textContent = rulesBetweenImports.join("") + original.slice(keptTo);
|
|
2023
2021
|
}
|
|
2024
2022
|
}
|
|
2025
2023
|
return document2.toString();
|
|
@@ -3066,7 +3064,7 @@ async function compileWithAssets(projectDir2, htmlPath2, downloadDir2, options2,
|
|
|
3066
3064
|
...options2.abortSignal ? [options2.abortSignal] : []
|
|
3067
3065
|
]);
|
|
3068
3066
|
const fontSheetHtml = await inlineExternalFontStylesheets(
|
|
3069
|
-
promoteCssImportsToLinkTags(sanitizedHtml),
|
|
3067
|
+
promoteCssImportsToLinkTags(sanitizedHtml, budget),
|
|
3070
3068
|
budget,
|
|
3071
3069
|
remoteFetches
|
|
3072
3070
|
);
|
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) {
|
|
@@ -4298,7 +4314,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
4298
4314
|
}
|
|
4299
4315
|
return { subCompositions };
|
|
4300
4316
|
}
|
|
4301
|
-
function promoteCssImportsToLinkTags(html) {
|
|
4317
|
+
function promoteCssImportsToLinkTags(html, budget) {
|
|
4302
4318
|
const { document: document2 } = parseHTML5(html);
|
|
4303
4319
|
const head = document2.querySelector("head");
|
|
4304
4320
|
if (!head) return html;
|
|
@@ -4307,18 +4323,16 @@ function promoteCssImportsToLinkTags(html) {
|
|
|
4307
4323
|
const styleEls = document2.querySelectorAll("style");
|
|
4308
4324
|
for (const styleEl of styleEls) {
|
|
4309
4325
|
const original = styleEl.textContent || "";
|
|
4310
|
-
|
|
4311
|
-
let
|
|
4312
|
-
importRe
|
|
4313
|
-
while ((match = importRe.exec(original)) !== null) {
|
|
4326
|
+
const rulesBetweenImports = [];
|
|
4327
|
+
let keptTo = 0;
|
|
4328
|
+
for (const match of original.matchAll(importRe)) {
|
|
4314
4329
|
const url = match[1] ?? "";
|
|
4315
4330
|
if (!url.startsWith("http://") && !url.startsWith("https://")) continue;
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
}
|
|
4331
|
+
rulesBetweenImports.push(original.slice(keptTo, match.index));
|
|
4332
|
+
keptTo = match.index + match[0].length;
|
|
4333
|
+
if (seenUrls.has(url)) continue;
|
|
4320
4334
|
seenUrls.add(url);
|
|
4321
|
-
|
|
4335
|
+
budget.chargeElements(ENTRY_PAGE, 2);
|
|
4322
4336
|
const preload = document2.createElement("link");
|
|
4323
4337
|
preload.setAttribute("rel", "preload");
|
|
4324
4338
|
preload.setAttribute("href", url);
|
|
@@ -4329,8 +4343,8 @@ function promoteCssImportsToLinkTags(html) {
|
|
|
4329
4343
|
link.setAttribute("href", url);
|
|
4330
4344
|
head.appendChild(link);
|
|
4331
4345
|
}
|
|
4332
|
-
if (
|
|
4333
|
-
styleEl.textContent =
|
|
4346
|
+
if (keptTo > 0) {
|
|
4347
|
+
styleEl.textContent = rulesBetweenImports.join("") + original.slice(keptTo);
|
|
4334
4348
|
}
|
|
4335
4349
|
}
|
|
4336
4350
|
return document2.toString();
|
|
@@ -5377,7 +5391,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5377
5391
|
...options.abortSignal ? [options.abortSignal] : []
|
|
5378
5392
|
]);
|
|
5379
5393
|
const fontSheetHtml = await inlineExternalFontStylesheets(
|
|
5380
|
-
promoteCssImportsToLinkTags(sanitizedHtml),
|
|
5394
|
+
promoteCssImportsToLinkTags(sanitizedHtml, budget),
|
|
5381
5395
|
budget,
|
|
5382
5396
|
remoteFetches
|
|
5383
5397
|
);
|
|
@@ -8678,7 +8692,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
|
|
|
8678
8692
|
import { existsSync as existsSync13, readdirSync, statfsSync } from "node:fs";
|
|
8679
8693
|
import { join as join18 } from "node:path";
|
|
8680
8694
|
import {
|
|
8681
|
-
classifyCaptureFailure as
|
|
8695
|
+
classifyCaptureFailure as classifyCaptureFailure3,
|
|
8682
8696
|
frameFileExtension,
|
|
8683
8697
|
captureFrame,
|
|
8684
8698
|
captureFrameToBufferPipelined as captureFrameToBufferPipelined2,
|
|
@@ -8966,7 +8980,7 @@ function resolveCaptureRange(frameRange, totalFrames) {
|
|
|
8966
8980
|
return { rangeStart: frameRange?.startFrame ?? 0, rangeEnd: frameRange?.endFrame ?? totalFrames };
|
|
8967
8981
|
}
|
|
8968
8982
|
function planTransientResume(error, ctx) {
|
|
8969
|
-
const failure =
|
|
8983
|
+
const failure = classifyCaptureFailure3(error, { signal: ctx.abortSignal });
|
|
8970
8984
|
const missing = findMissingFrameRanges(ctx.rangeFrames, ctx.framesDir, ctx.frameExt);
|
|
8971
8985
|
const [firstMissing] = missing;
|
|
8972
8986
|
if (!firstMissing) return null;
|
|
@@ -9060,8 +9074,7 @@ import {
|
|
|
9060
9074
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
9061
9075
|
createCaptureSession as createCaptureSession7,
|
|
9062
9076
|
initTransparentBackground as initTransparentBackground2,
|
|
9063
|
-
initializeSession as initializeSession7
|
|
9064
|
-
spawnStreamingEncoder as spawnStreamingEncoder3
|
|
9077
|
+
initializeSession as initializeSession7
|
|
9065
9078
|
} from "@hyperframes/engine";
|
|
9066
9079
|
import { fpsToNumber as fpsToNumber7 } from "@hyperframes/core";
|
|
9067
9080
|
|
|
@@ -9108,8 +9121,7 @@ import {
|
|
|
9108
9121
|
formatFfmpegError,
|
|
9109
9122
|
MIXED_AUDIO_FILENAME as MIXED_AUDIO_FILENAME2,
|
|
9110
9123
|
resolveConfig,
|
|
9111
|
-
runFfmpeg as runFfmpeg6
|
|
9112
|
-
spawnStreamingEncoder as spawnStreamingEncoder4
|
|
9124
|
+
runFfmpeg as runFfmpeg6
|
|
9113
9125
|
} from "@hyperframes/engine";
|
|
9114
9126
|
import {
|
|
9115
9127
|
clearGifFramesBeforeNext,
|
|
@@ -9249,10 +9261,7 @@ function startEncodeProgress(job, stage, onProgress) {
|
|
|
9249
9261
|
function resolveEngineConfig(input) {
|
|
9250
9262
|
return input.engineConfig ?? input.job.config.producerConfig ?? resolveConfig();
|
|
9251
9263
|
}
|
|
9252
|
-
function
|
|
9253
|
-
return Math.max(1, Math.floor(cpuCount) - Math.floor(workerCount));
|
|
9254
|
-
}
|
|
9255
|
-
function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
9264
|
+
function videoEncoderOptions(input, engineCfg) {
|
|
9256
9265
|
const { job, preset } = input;
|
|
9257
9266
|
return {
|
|
9258
9267
|
fps: job.config.fps,
|
|
@@ -9272,8 +9281,7 @@ function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
|
9272
9281
|
// keyframes that survive `-f concat -c copy` at assemble time. In-process
|
|
9273
9282
|
// renders leave both undefined → preserves the existing open-GOP output.
|
|
9274
9283
|
lockGopForChunkConcat: input.lockGopForChunkConcat === true,
|
|
9275
|
-
gopSize: input.gopSize
|
|
9276
|
-
softwareEncoderThreads
|
|
9284
|
+
gopSize: input.gopSize
|
|
9277
9285
|
};
|
|
9278
9286
|
}
|
|
9279
9287
|
function canEncodeWhileCapturing(input, workerCount, cpuCount) {
|
|
@@ -9289,9 +9297,8 @@ async function readLandedFrame(workerPath, mergedPath) {
|
|
|
9289
9297
|
}
|
|
9290
9298
|
return readFile2(mergedPath);
|
|
9291
9299
|
}
|
|
9292
|
-
function encodeWhileCapturing(input, totalFrames
|
|
9300
|
+
function encodeWhileCapturing(input, totalFrames) {
|
|
9293
9301
|
const engineCfg = resolveEngineConfig(input);
|
|
9294
|
-
const softwareEncoderThreads = captureBudget ? overlapEncoderThreads(captureBudget.workerCount, captureBudget.cpuCount) : void 0;
|
|
9295
9302
|
const stop = new AbortController();
|
|
9296
9303
|
const signal = input.abortSignal ? AbortSignal.any([input.abortSignal, stop.signal]) : stop.signal;
|
|
9297
9304
|
const landed = /* @__PURE__ */ new Map();
|
|
@@ -9304,10 +9311,10 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
9304
9311
|
};
|
|
9305
9312
|
signal.addEventListener("abort", nudge, { once: true });
|
|
9306
9313
|
let reportFed = null;
|
|
9307
|
-
const encoder =
|
|
9314
|
+
const encoder = spawnCaptureEncoder(
|
|
9308
9315
|
input.videoOnlyPath,
|
|
9309
9316
|
{
|
|
9310
|
-
...videoEncoderOptions(input, engineCfg
|
|
9317
|
+
...videoEncoderOptions(input, engineCfg),
|
|
9311
9318
|
imageFormat: "jpeg"
|
|
9312
9319
|
},
|
|
9313
9320
|
signal,
|
|
@@ -9508,8 +9515,14 @@ var RenderQualityError = class extends Error {
|
|
|
9508
9515
|
);
|
|
9509
9516
|
this.warnings = warnings;
|
|
9510
9517
|
this.name = "RenderQualityError";
|
|
9518
|
+
const failed = warnings.filter((warning) => warning.code === "sub_timeline_script_failure");
|
|
9519
|
+
if (failed.length > 0 && failed.every((warning) => warning.details?.scriptThrew === true)) {
|
|
9520
|
+
this.code = "COMPOSITION_SCRIPT_FAILED";
|
|
9521
|
+
}
|
|
9511
9522
|
}
|
|
9512
9523
|
warnings;
|
|
9524
|
+
/** Set only when the composition's own script threw: rendering it again fails the same way. */
|
|
9525
|
+
code;
|
|
9513
9526
|
};
|
|
9514
9527
|
function applyRenderWarningPolicy(job, captureWarnings, log = defaultLogger) {
|
|
9515
9528
|
job.warnings ??= [];
|
|
@@ -9660,7 +9673,7 @@ function isRecoverableParallelCaptureError(error) {
|
|
|
9660
9673
|
if (error instanceof RenderStageStalledError) return true;
|
|
9661
9674
|
const message = normalizeErrorMessage(error);
|
|
9662
9675
|
if (!message.includes("[Parallel] Capture failed")) return false;
|
|
9663
|
-
const kind =
|
|
9676
|
+
const kind = classifyCaptureFailure4(error).kind;
|
|
9664
9677
|
return kind === "transient_browser" || kind === "protocol_timeout";
|
|
9665
9678
|
}
|
|
9666
9679
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
@@ -9681,6 +9694,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9681
9694
|
let attempt = 0;
|
|
9682
9695
|
let transientRetriesUsed = 0;
|
|
9683
9696
|
let initializationRetriesUsed = 0;
|
|
9697
|
+
let memoryRetriesUsed = 0;
|
|
9684
9698
|
let pendingTransientRetry = false;
|
|
9685
9699
|
const rangeStart = options.frameRangeStart ?? 0;
|
|
9686
9700
|
while (true) {
|
|
@@ -9780,7 +9794,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9780
9794
|
attempt++;
|
|
9781
9795
|
} catch (caught) {
|
|
9782
9796
|
const error = attemptSignal?.aborted && !options.abortSignal?.aborted ? attemptSignal.reason : caught;
|
|
9783
|
-
const failure =
|
|
9797
|
+
const failure = classifyCaptureFailure4(error, { signal: options.abortSignal });
|
|
9784
9798
|
if (failure.kind === "cancelled") {
|
|
9785
9799
|
throw error;
|
|
9786
9800
|
}
|
|
@@ -9830,6 +9844,24 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9830
9844
|
pendingTransientRetry = true;
|
|
9831
9845
|
continue;
|
|
9832
9846
|
}
|
|
9847
|
+
const fitWorkers = memoryRetriesUsed === 0 && failure.kind === "memory_exhaustion" ? captureMemoryRetryWorkers2(error) : void 0;
|
|
9848
|
+
if (options.allowRetry && currentWorkers > 1 && fitWorkers !== void 0) {
|
|
9849
|
+
memoryRetriesUsed++;
|
|
9850
|
+
const nextWorkers2 = Math.min(fitWorkers, currentWorkers - 1);
|
|
9851
|
+
options.log.warn(
|
|
9852
|
+
"[Render] Capture stopped before memory ran out; retrying missing frames with fewer workers.",
|
|
9853
|
+
{
|
|
9854
|
+
fromWorkers: currentWorkers,
|
|
9855
|
+
toWorkers: nextWorkers2,
|
|
9856
|
+
missingFrames: remainingCount,
|
|
9857
|
+
error: failure.message
|
|
9858
|
+
}
|
|
9859
|
+
);
|
|
9860
|
+
currentWorkers = nextWorkers2;
|
|
9861
|
+
missingRanges = remaining;
|
|
9862
|
+
attempt++;
|
|
9863
|
+
continue;
|
|
9864
|
+
}
|
|
9833
9865
|
if (!madeProgress) {
|
|
9834
9866
|
options.log.warn(
|
|
9835
9867
|
"[Render] Capture attempt made no forward progress; composition is likely structurally broken, not retrying.",
|
|
@@ -13798,7 +13830,7 @@ import { join as join34 } from "node:path";
|
|
|
13798
13830
|
import {
|
|
13799
13831
|
assertSwiftShader,
|
|
13800
13832
|
BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
|
|
13801
|
-
classifyCaptureFailure as
|
|
13833
|
+
classifyCaptureFailure as classifyCaptureFailure5,
|
|
13802
13834
|
computeWorkerSizing as computeWorkerSizing2,
|
|
13803
13835
|
closeCaptureSession as closeCaptureSession11,
|
|
13804
13836
|
createCaptureSession as createCaptureSession11,
|
|
@@ -13910,7 +13942,7 @@ function observedChunkCaptureMode(perfs) {
|
|
|
13910
13942
|
}
|
|
13911
13943
|
var PROBE_SELECTED_SCREENSHOT = "[renderChunk] probe selected screenshot capture";
|
|
13912
13944
|
function shouldRetryChunkCaptureWithScreenshot(error) {
|
|
13913
|
-
const failure =
|
|
13945
|
+
const failure = classifyCaptureFailure5(error);
|
|
13914
13946
|
if (failure.kind === "cancelled" || failure.kind === "memory_exhaustion") return false;
|
|
13915
13947
|
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
13948
|
}
|
|
@@ -14401,10 +14433,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14401
14433
|
const captureSession = session;
|
|
14402
14434
|
session = null;
|
|
14403
14435
|
verifyStarted = Date.now();
|
|
14404
|
-
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpuBudget2()) ? encodeWhileCapturing(encodeInput, framesInChunk
|
|
14405
|
-
workerCount: chunkWorkerCount,
|
|
14406
|
-
cpuCount: cpuBudget2()
|
|
14407
|
-
}) : null;
|
|
14436
|
+
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpuBudget2()) ? encodeWhileCapturing(encodeInput, framesInChunk) : null;
|
|
14408
14437
|
await observeRenderStage(
|
|
14409
14438
|
new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
|
|
14410
14439
|
"capture_chunk",
|
|
@@ -3,10 +3,14 @@ import { createServer } from "node:http";
|
|
|
3
3
|
import { parentPort, workerData } from "node:worker_threads";
|
|
4
4
|
var startTime = Date.now();
|
|
5
5
|
var port = Number(workerData?.port ?? 9848);
|
|
6
|
+
var hostname = typeof workerData?.hostname === "string" && workerData.hostname ? workerData.hostname : "127.0.0.1";
|
|
7
|
+
var closeAfterMs = Number(workerData?.closeAfterMs) > 0 ? Number(workerData.closeAfterMs) : 5e3;
|
|
8
|
+
var MAX_CONNECTIONS = 64;
|
|
6
9
|
if (!parentPort) {
|
|
7
10
|
throw new Error("[healthWorkerThread] must run inside a worker_thread");
|
|
8
11
|
}
|
|
9
|
-
var
|
|
12
|
+
var options = { connectionsCheckingInterval: Math.min(1e3, closeAfterMs) };
|
|
13
|
+
var server = createServer(options, (req, res) => {
|
|
10
14
|
if (req.method === "GET" && (req.url === "/health" || req.url?.startsWith("/health?"))) {
|
|
11
15
|
const body = JSON.stringify({
|
|
12
16
|
status: "ok",
|
|
@@ -25,9 +29,11 @@ var server = createServer((req, res) => {
|
|
|
25
29
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
26
30
|
res.end("Not found");
|
|
27
31
|
});
|
|
28
|
-
server.
|
|
29
|
-
server.requestTimeout =
|
|
30
|
-
server.
|
|
32
|
+
server.headersTimeout = closeAfterMs;
|
|
33
|
+
server.requestTimeout = closeAfterMs;
|
|
34
|
+
server.keepAliveTimeout = closeAfterMs;
|
|
35
|
+
server.setTimeout(closeAfterMs * 2);
|
|
36
|
+
server.maxConnections = MAX_CONNECTIONS;
|
|
31
37
|
server.on("error", (err) => {
|
|
32
38
|
parentPort?.postMessage({
|
|
33
39
|
type: "listen-error",
|
|
@@ -35,7 +41,7 @@ server.on("error", (err) => {
|
|
|
35
41
|
});
|
|
36
42
|
setTimeout(() => parentPort?.close(), 50);
|
|
37
43
|
});
|
|
38
|
-
server.listen(port,
|
|
44
|
+
server.listen(port, hostname, () => {
|
|
39
45
|
parentPort?.postMessage({ type: "listening", port });
|
|
40
46
|
});
|
|
41
47
|
parentPort.on("message", (msg) => {
|
|
@@ -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"
|