Skip to content

Commit f3e5b81

Browse files
jrusso1020claude
andauthored
test(engine): pin the motion blur sweep defects A to O by their symptoms (heygen-com#7149)
Adds 13 text-free fixtures from the 60-composition capture motion blur sweep and one test per defect, each pinned by its current symptom so it fails once the fix lands. Pins use the existing outside and inside invariants where they see the defect, and a second check against the engine's 32-sample sub-frame blur where they do not (E, J, K, M). Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent aa34cff commit f3e5b81

3 files changed

Lines changed: 576 additions & 0 deletions

File tree

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import { readFileSync } from "node:fs";
2+
import { createRequire } from "node:module";
3+
import { resolve } from "node:path";
4+
5+
// One composition per defect from the 60-composition motion blur sweep. Each is 640x360, 30 fps, 1 s,
6+
// and its mover #m travels x 0 to 480 between 0.25 s and 0.75 s (32 px a frame). No text anywhere, so
7+
// no pin depends on how a host rasterises glyphs.
8+
9+
export type Tier = "capture" | "filter";
10+
11+
interface SweepFixture {
12+
name: string;
13+
width: 640;
14+
height: 360;
15+
dpr: 1;
16+
durationSeconds: 1;
17+
fps: 30;
18+
html(blur: "on" | "off", tier: Tier): string;
19+
}
20+
21+
const repoRoot = resolve(import.meta.dirname, "../../../../../..");
22+
const GSAP = readFileSync(
23+
createRequire(resolve(repoRoot, "packages/core/package.json")).resolve("gsap/dist/gsap.min.js"),
24+
"utf8",
25+
);
26+
27+
const BASE_CSS = `
28+
* { margin: 0; padding: 0; box-sizing: border-box }
29+
html, body { width: 640px; height: 360px; overflow: hidden; background: #000 }
30+
#root { position: relative; width: 640px; height: 360px; overflow: hidden;
31+
background: linear-gradient(135deg, #1d3557 0%, #457b9d 50%, #2a9d8f 100%) }
32+
.deco { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: #f1faee }
33+
.m { position: absolute; left: 40px; top: 140px; width: 120px; height: 80px; background: #e76f51; border: 4px solid #fff }`;
34+
35+
const DECO = Array.from(
36+
{ length: 9 },
37+
(_, i) => `<div class="deco" style="left:${20 + i * 70}px;top:${30 + (i % 3) * 110}px"></div>`,
38+
).join("");
39+
40+
const MOVER = `<div id="m" class="m"></div>`;
41+
const SLIDE = `tl.fromTo("#m", { x: 0 }, { x: 480, duration: 0.5, ease: "none" }, 0.25);`;
42+
const STRIPES = `<div style="position:absolute;inset:0;background:repeating-linear-gradient(90deg,#000 0 20px,#fff 20px 40px)"></div>`;
43+
44+
interface Spec {
45+
name: string;
46+
css?: string;
47+
body?: string;
48+
script?: string;
49+
}
50+
51+
const rootAttrs = (blur: "on" | "off", tier: Tier): string =>
52+
blur === "off"
53+
? 'data-motion-blur="off"'
54+
: `data-motion-blur="on" data-motion-blur-tier="${tier}"`;
55+
56+
function sweepFixture(spec: Spec): SweepFixture {
57+
return {
58+
name: spec.name,
59+
width: 640,
60+
height: 360,
61+
dpr: 1,
62+
durationSeconds: 1,
63+
fps: 30,
64+
html: (blur, tier) => `<!doctype html><html><head><meta charset="utf-8"><style>
65+
${BASE_CSS}
66+
${spec.css ?? ""}
67+
</style></head><body>
68+
<div id="root" data-composition-id="root" data-start="0" data-duration="1" data-width="640" data-height="360" ${rootAttrs(blur, tier)}>${DECO}${spec.body ?? MOVER}</div>
69+
<script>${GSAP}</script><script>
70+
window.__timelines = window.__timelines || {};
71+
const tl = gsap.timeline({ paused: true });
72+
${spec.script ?? SLIDE}
73+
tl.set({}, {}, 1);
74+
window.__timelines.root = tl;
75+
</script>
76+
</body></html>`,
77+
};
78+
}
79+
80+
const card = (style: string): string =>
81+
`<div id="card" style="position:absolute;left:200px;top:80px;width:240px;height:200px;background:#264653;${style}"><div id="m" class="m" style="left:-160px;top:60px"></div></div>`;
82+
83+
const SWEEP_FIXTURES = [
84+
// Control: a plain mover. Both tiers draw it the way the oracle does.
85+
sweepFixture({ name: "plain" }),
86+
// A: a static panel painted over the mover.
87+
sweepFixture({
88+
name: "behind-panel",
89+
css: ".m { z-index: 1 }",
90+
body: `${MOVER}<div id="panel" style="position:absolute;left:260px;top:100px;width:120px;height:160px;background:#ffd166;z-index:5;border:4px solid #000"></div>`,
91+
}),
92+
// B: the mover blends with what is under it.
93+
sweepFixture({
94+
name: "blend-difference",
95+
css: ".m { background: #fff; mix-blend-mode: difference }",
96+
body: STRIPES + MOVER,
97+
}),
98+
// C: an ancestor casts a drop shadow from the mover.
99+
sweepFixture({
100+
name: "ancestor-drop-shadow",
101+
body: `<div style="position:absolute;inset:0;filter:drop-shadow(14px 14px 3px #000)">${MOVER}</div>`,
102+
}),
103+
// D: generated content drawn outside the mover's box.
104+
sweepFixture({
105+
name: "pseudo-after",
106+
css: ".m::after { content: ''; position: absolute; left: 130px; top: 10px; width: 60px; height: 60px; background: #ffd166; border-radius: 50% }",
107+
}),
108+
// E: the mover's own clip-path.
109+
sweepFixture({
110+
name: "own-clip-polygon",
111+
css: ".m { clip-path: polygon(50% 0, 100% 100%, 0 100%) }",
112+
}),
113+
// F: a position:fixed child of a mover that moves through left.
114+
sweepFixture({
115+
name: "fixed-child-left",
116+
body: `<div id="m" class="m"><div id="badge" style="position:fixed;left:10px;top:10px;width:60px;height:30px;background:#ffd166"></div></div>`,
117+
script: `tl.fromTo("#m", { left: 40 }, { left: 520, duration: 0.5, ease: "none" }, 0.25);`,
118+
}),
119+
// H: an author selector that goes through the root's parent.
120+
sweepFixture({ name: "body-child-selector", css: "body > #root > .m { background: #06d6a0 }" }),
121+
// I: an author selector on the root's last child.
122+
sweepFixture({
123+
name: "last-child-selector",
124+
css: "#root > :last-child { outline: 6px solid #ffd166 }",
125+
body: `${MOVER}<div id="last" style="position:absolute;left:500px;top:20px;width:100px;height:50px;background:#000"></div>`,
126+
}),
127+
// J: an overflow:hidden card the mover slides into.
128+
sweepFixture({ name: "overflow-card", body: card("overflow:hidden;border-radius:24px") }),
129+
// K: two movers that cross.
130+
sweepFixture({
131+
name: "overlapping-movers",
132+
css: ".m2 { position: absolute; left: 480px; top: 150px; width: 120px; height: 80px; background: #2a9d8f; border: 4px solid #000 }",
133+
body: `${MOVER}<div id="m2" class="m2"></div>`,
134+
script: `${SLIDE} tl.fromTo("#m2", { x: 0 }, { x: -440, duration: 0.5, ease: "none" }, 0.25);`,
135+
}),
136+
// M: movers that rise in from below the frame edge.
137+
sweepFixture({
138+
name: "rise-from-below",
139+
css: ".r { position: absolute; top: 300px; width: 40px; height: 40px; background: #ffd166; border: 3px solid #000 }",
140+
body: Array.from(
141+
{ length: 9 },
142+
(_, i) => `<div class="r" style="left:${20 + i * 68}px"></div>`,
143+
).join(""),
144+
script: `tl.from(".r", { y: 120, duration: 0.3, ease: "none", stagger: 0.012 }, 0.2);`,
145+
}),
146+
// O: the mover is hidden half way through a frame's shutter.
147+
sweepFixture({
148+
name: "visibility-toggle",
149+
script: `${SLIDE} tl.set("#m", { visibility: "hidden" }, 0.5);`,
150+
}),
151+
] as const satisfies readonly SweepFixture[];
152+
153+
export type SweepFixtureName = (typeof SWEEP_FIXTURES)[number]["name"];
154+
155+
export function sweepFixtureNamed(name: SweepFixtureName): SweepFixture {
156+
const f = SWEEP_FIXTURES.find((x) => x.name === name);
157+
if (!f) throw new Error(`missing sweep fixture ${name}`);
158+
return f;
159+
}

‎packages/engine/src/services/__fixtures__/motionBlur/thresholds.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,30 @@ export const INVARIANTS = {
4242
minCheckedFraction: 0.5,
4343
shutterSamples: 8,
4444
};
45+
46+
// Oracle: the engine's 32-sample sub-frame blur. Noise: worst tile MAE on the sweep fixtures' clean frames.
47+
export const MEASURED_ORACLE_NOISE = 3.94;
48+
export const MEASURED_ORACLE_SMALLEST_SYMPTOM = 14.47;
49+
50+
export const ORACLE = {
51+
samples: 32,
52+
maxMae: geometricMean(MEASURED_ORACLE_NOISE, MEASURED_ORACLE_SMALLEST_SYMPTOM),
53+
};
54+
55+
export const SWEEP_SYMPTOMS = {
56+
A: 47.67,
57+
B: 148.63,
58+
C: 73.02,
59+
D_CAPTURE: 107.66,
60+
D_FILTER: 107.66,
61+
E: 27.6,
62+
F_CAPTURE: 40.62,
63+
F_FILTER: 126.54,
64+
H: 135.67,
65+
I: 53.63,
66+
J: 25.79,
67+
K: MEASURED_ORACLE_SMALLEST_SYMPTOM,
68+
M: 18.31,
69+
O_CAPTURE: 50.38,
70+
O_FILTER: 50.38,
71+
} as const;

0 commit comments

Comments
 (0)