mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix: warnings that name project files print control characters as visible escapes (#7863)
* fix: warnings that name project files print control characters as visible escapes The CLI already escaped control characters in the text its own commands print, but warnings from core, producer and engine went to the terminal raw. A composition whose sub-composition path held ESC or BEL still drove the terminal through the bundler's "Skipping sub-composition" warning in `info --media` and `snapshot`. terminalText moves to core so there is one sanitiser, the CLI imports it from there, and the library warnings that carry project text (the bundler, the producer logger, the file server, render path skips, asset load failures, FrameCapture, the import map, fonts, figma and atomic file warnings) pass that text through it. * fix: every library warning that carries project text escapes control characters
This commit is contained in:
@@ -35,6 +35,7 @@ import { createEnvelopeWalker } from "./audioVolumeEnvelope.js";
|
||||
import { riffChunks, wavFormatTag } from "./wavChunks.js";
|
||||
import { windowPrerollSeconds } from "./audioFxWarmup.js";
|
||||
import type { AudioVolumeKeyframe } from "./audioMixer.types.js";
|
||||
import { terminalText } from "@hyperframes/core";
|
||||
|
||||
export class AudioFxRenderError extends Error {
|
||||
constructor(message: string) {
|
||||
@@ -424,7 +425,9 @@ function chainPrerollSeconds(
|
||||
);
|
||||
if (capped) {
|
||||
console.warn(
|
||||
`Audio FX for track ${trackId}: the chain remembers longer than the ${limits.maxPrerollSeconds}s pre-roll cap, so its oldest repeats are cut at window seams`,
|
||||
terminalText(
|
||||
`Audio FX for track ${trackId}: the chain remembers longer than the ${limits.maxPrerollSeconds}s pre-roll cap, so its oldest repeats are cut at window seams`,
|
||||
),
|
||||
);
|
||||
}
|
||||
return seconds;
|
||||
|
||||
@@ -70,6 +70,7 @@ import {
|
||||
sourceTimeAt,
|
||||
timeAtSourceTime,
|
||||
type RateSpec,
|
||||
terminalText,
|
||||
} from "@hyperframes/core";
|
||||
import { readMasterFxChain, resolveAudioGroups } from "@hyperframes/core/audio-groups";
|
||||
import { applyAudioFxChain, AudioFxRenderError } from "./audioFxRender.js";
|
||||
@@ -1564,7 +1565,9 @@ export async function processCompositionAudio(
|
||||
// Fallback: if no duration was specified, probe the actual file
|
||||
if (element.end - element.start <= 0) {
|
||||
console.warn(
|
||||
`[audioMixer] ${element.id} has no data-duration or data-end; its length is unknown, so it plays to the end of its source`,
|
||||
terminalText(
|
||||
`[audioMixer] ${element.id} has no data-duration or data-end; its length is unknown, so it plays to the end of its source`,
|
||||
),
|
||||
);
|
||||
let metadata;
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { Page } from "puppeteer-core";
|
||||
import { pollSubCompositionTimelines } from "./frameCapture.js";
|
||||
|
||||
const PENDING_ID = "scene\u001b]0;title\u0007";
|
||||
|
||||
// The id scan returns a composition id that carries terminal controls; every other evaluate says "not ready".
|
||||
function pageWithPendingId(): Page {
|
||||
return {
|
||||
evaluate: vi.fn(async (expr: string | (() => unknown)) => {
|
||||
if (typeof expr === "function") return true;
|
||||
return expr.includes("m.push(id)") ? [PENDING_ID] : false;
|
||||
}),
|
||||
} as unknown as Page;
|
||||
}
|
||||
|
||||
function printedWarnings(warn: ReturnType<typeof vi.spyOn>): string {
|
||||
return warn.mock.calls.map((call: unknown[]) => call.join(" ")).join("\n");
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe("pollSubCompositionTimelines warnings that name compositions and scripts", () => {
|
||||
it("write control characters out as visible escapes when a script failed", async () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const outcome = await pollSubCompositionTimelines(pageWithPendingId(), 60_000, {
|
||||
intervalMs: 5,
|
||||
getScriptLoadFailures: () => ["http://localhost/a\u001b[2K.js"],
|
||||
scriptFailureGraceMs: 10,
|
||||
});
|
||||
|
||||
expect(outcome).toBe("script_failure");
|
||||
const printed = printedWarnings(warn);
|
||||
expect(printed).toContain("a\\x1b[2K.js");
|
||||
expect(printed).toContain("scene\\x1b]0;title\\x07");
|
||||
for (const control of ["\u001b", "\u0007"]) expect(printed).not.toContain(control);
|
||||
});
|
||||
|
||||
it("write control characters out as visible escapes when the wait times out", async () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const outcome = await pollSubCompositionTimelines(pageWithPendingId(), 30, { intervalMs: 5 });
|
||||
|
||||
expect(outcome).toBe("timeout");
|
||||
const printed = printedWarnings(warn);
|
||||
expect(printed).toContain("scene\\x1b]0;title\\x07");
|
||||
for (const control of ["\u001b", "\u0007"]) expect(printed).not.toContain(control);
|
||||
});
|
||||
});
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
RUNTIME_BOOTSTRAP_ATTR,
|
||||
SCENE_CALLBACK_ERROR_PREFIX,
|
||||
type RawAuthoredTiming,
|
||||
terminalText,
|
||||
} from "@hyperframes/core";
|
||||
|
||||
import { readReferenceBackground } from "./referenceBackground.js";
|
||||
@@ -1200,7 +1201,9 @@ async function initDrawElementOrTransparentBackground(
|
||||
session.deGateReason = reason;
|
||||
session.deFallbackTrigger = trigger;
|
||||
console.error(
|
||||
`[engine] fast capture falls back to ${session.launchCaptureMode} capture: ${message}`,
|
||||
terminalText(
|
||||
`[engine] fast capture falls back to ${session.launchCaptureMode} capture: ${message}`,
|
||||
),
|
||||
);
|
||||
await routeToFallback();
|
||||
};
|
||||
@@ -1305,8 +1308,10 @@ async function initDrawElementOrTransparentBackground(
|
||||
session.deGateReason = "3d_init_failed";
|
||||
session.deFallbackTrigger = "3d_init_failed";
|
||||
console.error(
|
||||
`[engine] fast capture falls back to ${session.launchCaptureMode} capture: ` +
|
||||
`3D projection init failed (${threeD.reason ?? "unknown"})`,
|
||||
terminalText(
|
||||
`[engine] fast capture falls back to ${session.launchCaptureMode} capture: ` +
|
||||
`3D projection init failed (${threeD.reason ?? "unknown"})`,
|
||||
),
|
||||
);
|
||||
await routeToFallback();
|
||||
return;
|
||||
@@ -1391,7 +1396,9 @@ async function cssEffectRiskFrames(
|
||||
return live && withFramesAfterCallback(live, scan.callbackFrom, fps, totalFrames);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`[engine] fast capture: effect scan failed (${error instanceof Error ? error.message : String(error)})`,
|
||||
terminalText(
|
||||
`[engine] fast capture: effect scan failed (${error instanceof Error ? error.message : String(error)})`,
|
||||
),
|
||||
);
|
||||
return null;
|
||||
} finally {
|
||||
@@ -2317,10 +2324,12 @@ export async function pollSubCompositionTimelines(
|
||||
if (failed.length > 0 && sinceFailure >= graceMs) {
|
||||
scriptFailureBail = true;
|
||||
console.warn(
|
||||
`[FrameCapture] Sub-composition timeline wait cut short after ${now - start}ms: ` +
|
||||
`script(s) failed (${failed.join(", ")}), so ` +
|
||||
`the timeline registration they carry can never arrive. ` +
|
||||
`Fix the script.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Sub-composition timeline wait cut short after ${now - start}ms: ` +
|
||||
`script(s) failed (${failed.join(", ")}), so ` +
|
||||
`the timeline registration they carry can never arrive. ` +
|
||||
`Fix the script.`,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -2350,12 +2359,16 @@ export async function pollSubCompositionTimelines(
|
||||
onPending?.(pendingIds);
|
||||
const missing = pendingIds.join(", ");
|
||||
if (scriptFailureBail) {
|
||||
console.warn(`[FrameCapture] Composition(s) still waiting on the failed script: ${missing}.`);
|
||||
console.warn(
|
||||
`[FrameCapture] Composition(s) still waiting on the failed script: ${terminalText(missing)}.`,
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
`[FrameCapture] Sub-composition timelines not registered after ${timeoutMs}ms: ${missing}. ` +
|
||||
`Compositions that load data asynchronously (e.g. fetch) must register window.__timelines[id] after setup completes. ` +
|
||||
`Compositions intentionally driven without GSAP timelines (CSS animations / rAF) can mark the host with data-no-timeline to skip this wait.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Sub-composition timelines not registered after ${timeoutMs}ms: ${missing}. ` +
|
||||
`Compositions that load data asynchronously (e.g. fetch) must register window.__timelines[id] after setup completes. ` +
|
||||
`Compositions intentionally driven without GSAP timelines (CSS animations / rAF) can mark the host with data-no-timeline to skip this wait.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
return scriptFailureBail ? "script_failure" : "timeout";
|
||||
@@ -2548,7 +2561,10 @@ function recordCaptureWarnings(session: CaptureSession, warnings: readonly Captu
|
||||
continue;
|
||||
}
|
||||
session.warnings.push(warning);
|
||||
console.warn(`[FrameCapture:${warning.code}] ${warning.message}`, warning.details ?? {});
|
||||
console.warn(
|
||||
`[FrameCapture:${warning.code}] ${terminalText(warning.message)}`,
|
||||
warning.details ?? {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3111,7 +3127,7 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
!quietRuntimeDetail(text) &&
|
||||
!loggedEarlierInRender(session, text)
|
||||
) {
|
||||
console.error(diagnostic.text);
|
||||
console.error(terminalText(diagnostic.text));
|
||||
}
|
||||
appendBrowserDiagnostic(session, diagnostic.text);
|
||||
|
||||
@@ -3127,7 +3143,7 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
const text = `[Browser:PAGEERROR] ${message}`;
|
||||
|
||||
// Benign play/pause race during frame capture — suppress terminal noise, keep in buffer.
|
||||
if (!isPlayPauseAbort(message)) console.error(text);
|
||||
if (!isPlayPauseAbort(message)) console.error(terminalText(text));
|
||||
|
||||
appendBrowserDiagnostic(session, text);
|
||||
});
|
||||
@@ -3255,8 +3271,10 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
pollVideosReady(page, skipVideoIds, pageReadyTimeout),
|
||||
waitForImagesReady(page, pageReadyTimeout, (failedImages) =>
|
||||
console.warn(
|
||||
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. ` +
|
||||
`Continuing render. Affected images may appear blank/missing in early frames.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. ` +
|
||||
`Continuing render. Affected images may appear blank/missing in early frames.`,
|
||||
),
|
||||
),
|
||||
),
|
||||
page.evaluate(`document.fonts?.ready`),
|
||||
@@ -3275,8 +3293,10 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
.join(", ");
|
||||
}, skipVideoIds);
|
||||
console.warn(
|
||||
`[FrameCapture] Some video elements did not decode within ${pageReadyTimeout}ms: ${failedVideos}. ` +
|
||||
`Continuing render. Affected videos will appear as blank/black frames.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Some video elements did not decode within ${pageReadyTimeout}ms: ${failedVideos}. ` +
|
||||
`Continuing render. Affected videos will appear as blank/black frames.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
recordReadiness(
|
||||
@@ -3398,8 +3418,10 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
pollVideosReady(page, bfSkipVideoIds, pageReadyTimeout),
|
||||
waitForImagesReady(page, pageReadyTimeout, (failedImages) =>
|
||||
console.warn(
|
||||
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. ` +
|
||||
`Continuing render. Affected images may appear blank/missing in early frames.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. ` +
|
||||
`Continuing render. Affected images may appear blank/missing in early frames.`,
|
||||
),
|
||||
),
|
||||
),
|
||||
page.evaluate(`document.fonts?.ready`),
|
||||
@@ -3418,8 +3440,10 @@ export async function initializeSession(session: CaptureSession): Promise<void>
|
||||
.join(", ");
|
||||
}, bfSkipVideoIds);
|
||||
console.warn(
|
||||
`[FrameCapture] Some video elements did not decode within ${pageReadyTimeout}ms: ${failedVideos}. ` +
|
||||
`Continuing render. Affected videos will appear as blank/black frames.`,
|
||||
terminalText(
|
||||
`[FrameCapture] Some video elements did not decode within ${pageReadyTimeout}ms: ${failedVideos}. ` +
|
||||
`Continuing render. Affected videos will appear as blank/black frames.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
recordReadiness(
|
||||
@@ -5449,7 +5473,7 @@ async function captureFrameCore(
|
||||
session.page,
|
||||
pageMotionBlurRecorder(session),
|
||||
).catch(() => null);
|
||||
if (blur) console.error(blur);
|
||||
if (blur) console.error(terminalText(blur));
|
||||
}
|
||||
|
||||
// Retain this freshly-captured buffer so the following static frames can reuse it.
|
||||
@@ -5815,9 +5839,11 @@ export async function captureFramesBatchPipelined(
|
||||
throw new DrawElementCaptureError(frameIndices[failedAt] ?? failedAt, reason, error);
|
||||
} else {
|
||||
console.error(
|
||||
`[engine] fast capture: batch produce failed at frame ` +
|
||||
`${frameIndices[failedAt] ?? "?"} (${error ?? "?"}); ` +
|
||||
`re-capturing ${frameIndices.length - failedAt} frame(s) per-frame`,
|
||||
terminalText(
|
||||
`[engine] fast capture: batch produce failed at frame ` +
|
||||
`${frameIndices[failedAt] ?? "?"} (${error ?? "?"}); ` +
|
||||
`re-capturing ${frameIndices.length - failedAt} frame(s) per-frame`,
|
||||
),
|
||||
);
|
||||
for (let i = failedAt; i < frameIndices.length; i++) {
|
||||
const frameIndex = frameIndices[i];
|
||||
@@ -5917,7 +5943,7 @@ export async function closeCaptureSession(session: CaptureSession): Promise<void
|
||||
undefined,
|
||||
pageMotionBlurRecorder(session),
|
||||
);
|
||||
if (blur) console.error(blur);
|
||||
if (blur) console.error(terminalText(blur));
|
||||
}
|
||||
// Realized static-dedup telemetry: how much the cache actually helped this
|
||||
// render (vs the prediction logged at arm time). Both capture paths
|
||||
|
||||
Reference in New Issue
Block a user