mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(render): retry explicit parallel capture timeouts (#2331)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { shouldAllowAdaptiveCaptureRetry } from "./captureStage.js";
|
||||
|
||||
describe("shouldAllowAdaptiveCaptureRetry", () => {
|
||||
it("keeps timeout recovery enabled when the initial worker count was explicit", () => {
|
||||
expect(shouldAllowAdaptiveCaptureRetry(6, true)).toBe(true);
|
||||
});
|
||||
|
||||
it("does not retry an already sequential capture", () => {
|
||||
expect(shouldAllowAdaptiveCaptureRetry(1, true)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -133,6 +133,19 @@ export interface CaptureStageResult {
|
||||
captureBeyondViewport?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An explicit worker count selects the initial concurrency; it must not disable
|
||||
* recovery after a worker times out. The adaptive loop only retries missing
|
||||
* frames, requires forward progress, and halves workers until sequential, so it
|
||||
* remains bounded while preserving already-captured work.
|
||||
*/
|
||||
export function shouldAllowAdaptiveCaptureRetry(
|
||||
workerCount: number,
|
||||
_explicitlyConfigured: boolean,
|
||||
): boolean {
|
||||
return workerCount > 1;
|
||||
}
|
||||
|
||||
export async function runCaptureStage(input: CaptureStageInput): Promise<CaptureStageResult> {
|
||||
const {
|
||||
fileServer,
|
||||
@@ -200,7 +213,7 @@ export async function runCaptureStage(input: CaptureStageInput): Promise<Capture
|
||||
framesDir,
|
||||
totalFrames,
|
||||
initialWorkerCount: workerCount,
|
||||
allowRetry: job.config.workers === undefined,
|
||||
allowRetry: shouldAllowAdaptiveCaptureRetry(workerCount, job.config.workers !== undefined),
|
||||
frameExt: needsAlpha ? "png" : "jpg",
|
||||
captureOptions: buildCaptureOptions(),
|
||||
createBeforeCaptureHook: createRenderVideoFrameInjector,
|
||||
|
||||
Reference in New Issue
Block a user