Skip to content

🎥 Make videos programmatically with React

Internal tests: Consolidate GSAP renderer parity workflows

JonnyBurgerd15cc5283f7f
diff --git a/packages/example/src/Gsap/ParityFixture.tsx b/packages/example/src/Gsap/ParityFixture.tsx
new file mode 100644
index 0000000000..05250df6ef
--- /dev/null
+++ b/packages/example/src/Gsap/ParityFixture.tsx
@@ -0,0 +1,50 @@
+import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import OverlapFixture from './Overlap';
+import SamePropertyOverlapFixture from './SamePropertyOverlap';
+import SurfaceFixture from './Surface';
+import SvgRootFixture from './SvgRoot';
+
+const FixtureCell: React.FC<{
+ children: React.ReactNode;
+ height: number;
+ left: number;
+ top: number;
+ width: number;
+}> = ({children, height, left, top, width}) => {
+ return (
+ <div
+ style={{
+ position: 'absolute',
+ left,
+ top,
+ width,
+ height,
+ overflow: 'hidden',
+ }}
+ >
+ {children}
+ </div>
+ );
+};
+
+const ParityFixture: React.FC = () => {
+ return (
+ <AbsoluteFill style={{background: '#000'}}>
+ <FixtureCell width={320} height={180} left={0} top={0}>
+ <SurfaceFixture />
+ </FixtureCell>
+ <FixtureCell width={320} height={180} left={320} top={0}>
+ <OverlapFixture />
+ </FixtureCell>
+ <FixtureCell width={320} height={120} left={0} top={180}>
+ <SamePropertyOverlapFixture />
+ </FixtureCell>
+ <FixtureCell width={100} height={100} left={320} top={180}>
+ <SvgRootFixture />
+ </FixtureCell>
+ </AbsoluteFill>
+ );
+};
+
+export default ParityFixture;
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 1b5004db46..dea4693f2e 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -2030,6 +2030,14 @@ export const Index: React.FC = () => {
width={100}
height={100}
/>
+ <Composition
+ id="gsap-parity"
+ lazyComponent={() => import('./Gsap/ParityFixture')}
+ durationInFrames={90}
+ fps={30}
+ width={640}
+ height={300}
+ />
</Folder>
<Folder name="lottie">
<Composition
diff --git a/packages/it-tests/src/rendering/gsap-render-parity.test.ts b/packages/it-tests/src/rendering/gsap-render-parity.test.ts
index 79e704d8df..f900537b6c 100644
--- a/packages/it-tests/src/rendering/gsap-render-parity.test.ts
+++ b/packages/it-tests/src/rendering/gsap-render-parity.test.ts
@@ -18,10 +18,7 @@ const FPS_30_FIXTURE_ID = 'gsap-fps-30';
const FPS_60_FIXTURE_ID = 'gsap-fps-60';
const SEQUENCE_FIXTURE_ID = 'gsap-sequence';
const NESTED_SEQUENCE_FIXTURE_ID = 'gsap-nested-sequence';
-const SURFACE_FIXTURE_ID = 'gsap-surface';
-const OVERLAP_FIXTURE_ID = 'gsap-overlap';
-const SAME_PROPERTY_OVERLAP_FIXTURE_ID = 'gsap-same-property-overlap';
-const SVG_ROOT_FIXTURE_ID = 'gsap-svg-root';
+const PARITY_FIXTURE_ID = 'gsap-parity';
const exampleDir = path.resolve(__dirname, '..', '..', '..', 'example');
const serveUrl = path.join(exampleDir, 'build');
@@ -67,8 +64,12 @@ describe('GSAP renderer parity', () => {
});
}
- composition = await selectComposition({serveUrl, id: SHOWCASE_ID});
browser = await openBrowser('chrome', {logLevel: 'warn'});
+ composition = await selectComposition({
+ serveUrl,
+ id: SHOWCASE_ID,
+ puppeteerInstance: browser,
+ });
});
afterAll(async () => {
@@ -103,7 +104,7 @@ describe('GSAP renderer parity', () => {
};
it(
- 'matches concurrent sequence rendering with shuffled direct-frame rendering',
+ 'keeps showcase frames identical across concurrent, shuffled, and repeated renders',
async () => {
const sequenceFrames = new Map<number, Buffer>();
@@ -125,7 +126,8 @@ describe('GSAP renderer parity', () => {
logLevel: 'warn',
});
- for (const frame of shuffledFrames) {
+ const directFrames = new Map<number, Buffer>();
+ for (const frame of [...shuffledFrames, 87]) {
const direct = await renderStill({
serveUrl,
composition,
@@ -136,35 +138,26 @@ describe('GSAP renderer parity', () => {
logLevel: 'warn',
});
- const fromSequence = sequenceFrames.get(frame);
- expect(
- fromSequence,
- `sequence buffer for frame ${frame}`,
- ).toBeDefined();
expect(
direct.buffer,
`direct buffer for frame ${frame}`,
).not.toBeNull();
- const difference = pixelDifference(fromSequence!, direct.buffer!);
- expect(difference, `showcase frame ${frame}`).toBe(0);
+ directFrames.set(frame, direct.buffer!);
+
+ if (shuffledFrames.includes(frame)) {
+ const fromSequence = sequenceFrames.get(frame);
+ expect(
+ fromSequence,
+ `sequence buffer for frame ${frame}`,
+ ).toBeDefined();
+ expect(
+ pixelDifference(fromSequence!, direct.buffer!),
+ `showcase frame ${frame}`,
+ ).toBe(0);
+ }
}
- },
- {timeout: 120000},
- );
- it(
- 'repeated direct renders of the same frame are pixel-identical',
- async () => {
- const first = await renderStill({
- serveUrl,
- composition,
- frame: 87,
- output: null,
- puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
- });
- const second = await renderStill({
+ const repeated = await renderStill({
serveUrl,
composition,
frame: 87,
@@ -174,72 +167,74 @@ describe('GSAP renderer parity', () => {
logLevel: 'warn',
});
- expect(pixelDifference(first.buffer!, second.buffer!)).toBe(0);
+ expect(pixelDifference(directFrames.get(87)!, repeated.buffer!)).toBe(0);
},
- {timeout: 60000},
+ {timeout: 120000},
);
it(
- 'maps equal local time to equal pixels at 30fps, 60fps, and inside a Sequence',
+ 'maps timeline time and boundary states consistently across frame rates and Sequences',
async () => {
- const fps24 = await selectComposition({serveUrl, id: FPS_24_FIXTURE_ID});
- const fps30 = await selectComposition({serveUrl, id: FPS_30_FIXTURE_ID});
- const fps60 = await selectComposition({serveUrl, id: FPS_60_FIXTURE_ID});
- const sequence = await selectComposition({
- serveUrl,
- id: SEQUENCE_FIXTURE_ID,
- });
- const nestedSequence = await selectComposition({
+ const fps24 = await selectComposition({
serveUrl,
- id: NESTED_SEQUENCE_FIXTURE_ID,
- });
-
- const halfSecond24 = await renderStill({
- serveUrl,
- composition: fps24,
- frame: 12,
- output: null,
+ id: FPS_24_FIXTURE_ID,
puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
});
- const halfSecond30 = await renderStill({
+ const fps30 = await selectComposition({
serveUrl,
- composition: fps30,
- frame: 15,
- output: null,
+ id: FPS_30_FIXTURE_ID,
puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
});
- const halfSecond60 = await renderStill({
+ const fps60 = await selectComposition({
serveUrl,
- composition: fps60,
- frame: 30,
- output: null,
+ id: FPS_60_FIXTURE_ID,
puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
});
- const halfSecondInSequence = await renderStill({
+ const sequence = await selectComposition({
serveUrl,
- composition: sequence,
- frame: 45,
- output: null,
+ id: SEQUENCE_FIXTURE_ID,
puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
});
- const halfSecondInNestedSequence = await renderStill({
+ const nestedSequence = await selectComposition({
serveUrl,
- composition: nestedSequence,
- frame: 45,
- output: null,
+ id: NESTED_SEQUENCE_FIXTURE_ID,
puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
});
+ const render = (
+ targetComposition: Awaited<ReturnType<typeof selectComposition>>,
+ frame: number,
+ ) =>
+ renderStill({
+ serveUrl,
+ composition: targetComposition,
+ frame,
+ output: null,
+ puppeteerInstance: browser,
+ imageFormat: 'png',
+ logLevel: 'warn',
+ });
+
+ const [
+ halfSecond24,
+ halfSecond30,
+ halfSecond60,
+ halfSecondInSequence,
+ halfSecondInNestedSequence,
+ start,
+ midpoint,
+ postDuration,
+ ] = await Promise.all([
+ render(fps24, 12),
+ render(fps30, 15),
+ render(fps60, 30),
+ render(sequence, 45),
+ render(nestedSequence, 45),
+ render(fps30, 0),
+ render(fps30, 12),
+ render(fps30, 59),
+ ]);
+
expect(pixelDifference(halfSecond24.buffer!, halfSecond30.buffer!)).toBe(
0,
);
@@ -255,71 +250,38 @@ describe('GSAP renderer parity', () => {
halfSecondInNestedSequence.buffer!,
),
).toBe(0);
+ expect(pixelAt(start.buffer!, 50, 50)).toEqual([0, 0, 0, 255]);
+ expect(pixelAt(midpoint.buffer!, 50, 50)).toEqual([102, 0, 0, 255]);
+ expect(pixelAt(postDuration.buffer!, 50, 50)).toEqual([255, 0, 0, 255]);
},
{timeout: 120000},
);
it(
- 'renders exact start, midpoint, and post-duration states',
- async () => {
- const fps30 = await selectComposition({serveUrl, id: FPS_30_FIXTURE_ID});
- const frames = await Promise.all(
- [0, 12, 59].map(async (frame) =>
- renderStill({
- serveUrl,
- composition: fps30,
- frame,
- output: null,
- puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
- }),
- ),
- );
-
- expect(pixelAt(frames[0]!.buffer!, 50, 50)).toEqual([0, 0, 0, 255]);
- expect(pixelAt(frames[1]!.buffer!, 50, 50)).toEqual([102, 0, 0, 255]);
- expect(pixelAt(frames[2]!.buffer!, 50, 50)).toEqual([255, 0, 0, 255]);
- },
- {timeout: 60000},
- );
-
- it(
- 'matches every complex-surface frame between serial and concurrent rendering',
+ 'keeps complex fixtures identical across serial, concurrent, and shuffled rendering',
async () => {
- const surface = await selectComposition({
+ const parity = await selectComposition({
serveUrl,
- id: SURFACE_FIXTURE_ID,
+ id: PARITY_FIXTURE_ID,
+ puppeteerInstance: browser,
});
- const serial = await renderFrameMap(surface, 1);
- const concurrent = await renderFrameMap(surface, rendererConcurrency);
+ const serial = await renderFrameMap(parity, 1);
+ const concurrent = await renderFrameMap(parity, rendererConcurrency);
- expect(serial.size).toBe(surface.durationInFrames);
- expect(concurrent.size).toBe(surface.durationInFrames);
+ expect(serial.size).toBe(parity.durationInFrames);
+ expect(concurrent.size).toBe(parity.durationInFrames);
- for (let frame = 0; frame < surface.durationInFrames; frame++) {
+ for (let frame = 0; frame < parity.durationInFrames; frame++) {
expect(
pixelDifference(serial.get(frame)!, concurrent.get(frame)!),
- `surface frame ${frame}`,
+ `parity frame ${frame} serial vs concurrent`,
).toBe(0);
}
- },
- {timeout: 240000},
- );
- it(
- 'keeps overlapping scoped Sequences deterministic under shuffled access',
- async () => {
- const overlap = await selectComposition({
- serveUrl,
- id: OVERLAP_FIXTURE_ID,
- });
- const rendered = await renderFrameMap(overlap, rendererConcurrency);
-
- for (const frame of [84, 30, 9, 64, 10, 45, 29]) {
+ for (const frame of [84, 30, 9, 64, 10, 45, 29, 23, 16, 44, 0, 59, 15]) {
const direct = await renderStill({
serveUrl,
- composition: overlap,
+ composition: parity,
frame,
output: null,
puppeteerInstance: browser,
@@ -327,71 +289,12 @@ describe('GSAP renderer parity', () => {
logLevel: 'warn',
});
- expect(pixelDifference(rendered.get(frame)!, direct.buffer!)).toBe(0);
- }
- },
- {timeout: 240000},
- );
-
- it(
- 'keeps overlapping same-property tweens identical across stills, serial and concurrent renders',
- async () => {
- const contested = await selectComposition({
- serveUrl,
- id: SAME_PROPERTY_OVERLAP_FIXTURE_ID,
- });
- const serial = await renderFrameMap(contested, 1);
- const concurrent = await renderFrameMap(contested, rendererConcurrency);
-
- for (const frame of [23, 16, 44, 0, 59]) {
- const direct = await renderStill({
- serveUrl,
- composition: contested,
- frame,
- output: null,
- puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
- });
-
- expect(
- pixelDifference(serial.get(frame)!, direct.buffer!),
- `contested frame ${frame} still vs serial`,
- ).toBe(0);
expect(
- pixelDifference(serial.get(frame)!, concurrent.get(frame)!),
- `contested frame ${frame} serial vs concurrent`,
+ pixelDifference(concurrent.get(frame)!, direct.buffer!),
+ `parity frame ${frame} concurrent vs direct`,
).toBe(0);
}
},
{timeout: 240000},
);
-
- it(
- 'supports an SVG element as the timeline scope root',
- async () => {
- const svg = await selectComposition({serveUrl, id: SVG_ROOT_FIXTURE_ID});
- const direct = await renderStill({
- serveUrl,
- composition: svg,
- frame: 15,
- output: null,
- puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
- });
- const repeated = await renderStill({
- serveUrl,
- composition: svg,
- frame: 15,
- output: null,
- puppeteerInstance: browser,
- imageFormat: 'png',
- logLevel: 'warn',
- });
-
- expect(pixelDifference(direct.buffer!, repeated.buffer!)).toBe(0);
- },
- {timeout: 60000},
- );
});