mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(core): a set that interrupts a tween holds in a real render at any worker count (#7318)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import gsap from "gsap";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { seekGsapTimeline } from "./gsap";
|
||||
import { rerenderGsapTimelineAt, seekGsapTimeline } from "./gsap";
|
||||
import { producerStandIn } from "./gsapStandIn.test-helpers";
|
||||
import type { RuntimeTimelineLike } from "../types";
|
||||
|
||||
@@ -136,9 +136,45 @@ function panelAt(frames: number[], fps?: number, standIn = false): Map<number, n
|
||||
return opacity;
|
||||
}
|
||||
|
||||
/** The panel at each frame through both steps of a real seek: the seek, then the runtime's re-render. */
|
||||
function panelThroughRuntimeSeek(frames: number[], standIn = false): Map<number, number> {
|
||||
const { panel, timeline } = fadeInterruptedBySet(standIn);
|
||||
const opacity = new Map<number, number>();
|
||||
for (const frame of frames) {
|
||||
const t = frame / SET_FPS;
|
||||
if (!seekGsapTimeline(timeline, t, false, undefined, SET_FPS)) {
|
||||
rerenderGsapTimelineAt(
|
||||
{
|
||||
totalTime: timeline.totalTime!.bind(timeline),
|
||||
totalDuration: timeline.totalDuration?.bind(timeline),
|
||||
getChildren: timeline.getChildren?.bind(timeline),
|
||||
},
|
||||
t,
|
||||
);
|
||||
}
|
||||
opacity.set(frame, panel.opacity);
|
||||
}
|
||||
return opacity;
|
||||
}
|
||||
|
||||
describe("a render where a set interrupts a running tween", () => {
|
||||
const preview = panelAt(range(0, 90));
|
||||
|
||||
it("keeps the set's value through the runtime's re-render, however frames are shared out", () => {
|
||||
for (const standIn of [false, true]) {
|
||||
for (const workers of [1, 2, 3, 4, 6]) {
|
||||
for (let worker = 0; worker < workers; worker++) {
|
||||
for (const [frame, opacity] of panelThroughRuntimeSeek(
|
||||
range(worker, 90, workers),
|
||||
standIn,
|
||||
)) {
|
||||
if (frame >= SET_FPS) expect([workers, frame, opacity]).toEqual([workers, frame, 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("lands every frame where preview does when one worker renders in order", () => {
|
||||
for (const [frame, opacity] of panelAt(range(0, 90), SET_FPS)) {
|
||||
expect([frame, opacity]).toEqual([frame, preview.get(frame)]);
|
||||
|
||||
@@ -57,7 +57,12 @@ function renderOntoInAuthoredOrder(
|
||||
timeline.totalTime(below ? t - REDRAW_STEP : t + REDRAW_STEP, true);
|
||||
primeTweensStartingAt(children, t, below ? REDRAW_STEP : 0);
|
||||
timeline.totalTime(t, true);
|
||||
if (!below) reapplyStepsInAuthoredOrder(timeline, structure ?? ownStructureOf(children), t);
|
||||
const own = structure ?? ownStructureOf(children);
|
||||
if (!below) {
|
||||
reapplyStepsInAuthoredOrder(timeline, own, t);
|
||||
} else if (own) {
|
||||
settleOverlapsEndedBetween(own.owner as RuntimeTimelineLike, t - REDRAW_STEP, t, own.version);
|
||||
}
|
||||
}
|
||||
|
||||
function ownStructureOf(children: unknown[]): GsapStructureKey | undefined {
|
||||
|
||||
Reference in New Issue
Block a user