mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix(producer): address review feedback on htmlInCanvas worker clamp
- Always log when html-in-canvas pins to 1 worker, not just on explicit --workers override (Vance, James) - Assert recommendScreenshot is true for htmlInCanvas detection — pins the load-bearing coupling with the screenshot paint-force protocol (Vance, Magi) - Skip capture calibration for htmlInCanvas auto-sized renders to avoid wasting 600ms–3s on an estimate that gets thrown away (Vance) - Add TODO documenting Chrome's two root-cause mechanisms: paint cache race and SwiftShader contention (James, Magi)
This commit is contained in:
@@ -426,6 +426,7 @@ describe("detectRenderModeHints", () => {
|
||||
const result = detectRenderModeHints(html);
|
||||
|
||||
expect(result.reasons.map((reason) => reason.code)).toContain("htmlInCanvas");
|
||||
expect(result.recommendScreenshot).toBe(true);
|
||||
});
|
||||
|
||||
it("does not flag htmlInCanvas for plain canvas elements without layoutsubtree", () => {
|
||||
|
||||
@@ -114,14 +114,17 @@ export function resolveRenderWorkerCount(
|
||||
log: ProducerLogger = defaultLogger,
|
||||
measuredCaptureCost?: CaptureCostEstimate,
|
||||
): number {
|
||||
// TODO(htmlInCanvas): workaround — Chrome's experimental drawElementImage
|
||||
// API (CanvasDrawElement) is non-deterministic across concurrent browser
|
||||
// instances due to paint-cache races and SwiftShader contention.
|
||||
// Remove this clamp once Chromium stabilizes CanvasDrawElement for
|
||||
// concurrent use.
|
||||
const reasonCodes = new Set(compiled.renderModeHints.reasons.map((r) => r.code));
|
||||
if (reasonCodes.has("htmlInCanvas")) {
|
||||
if (requestedWorkers !== undefined && requestedWorkers > 1) {
|
||||
log.warn(
|
||||
"[Render] html-in-canvas (drawElementImage) detected — overriding --workers to 1. " +
|
||||
"Chrome does not support concurrent drawElementImage across multiple workers and produces flickering artifacts.",
|
||||
);
|
||||
}
|
||||
log.warn(
|
||||
"[Render] html-in-canvas (drawElementImage) detected — pinning to 1 worker (Chrome concurrency limitation).",
|
||||
{ requestedWorkers },
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -584,6 +584,7 @@ describe("resolveRenderWorkerCount", () => {
|
||||
);
|
||||
|
||||
expect(workers).toBe(1);
|
||||
expect(log.warn).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("overrides explicit --workers when html-in-canvas is detected", () => {
|
||||
|
||||
@@ -1699,7 +1699,10 @@ export async function executeRenderJob(
|
||||
}
|
||||
| undefined;
|
||||
|
||||
if (job.config.workers === undefined && totalFrames >= 60) {
|
||||
const htmlInCanvasDetected = compiled.renderModeHints.reasons.some(
|
||||
(r) => r.code === "htmlInCanvas",
|
||||
);
|
||||
if (job.config.workers === undefined && totalFrames >= 60 && !htmlInCanvasDetected) {
|
||||
const outcome = await runCaptureCalibration({
|
||||
cfg,
|
||||
fileServer,
|
||||
|
||||
Reference in New Issue
Block a user