Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/core/src/runtime/colorGrading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,45 @@ describe("createColorGradingRuntime", () => {
});
});

describe("createColorGradingRuntime after a context loss", () => {
it("grades a clip that came on screen while the context was lost once it is restored", () => {
let lost = false;
const gl = createMockWebGl();
gl.createTexture = vi.fn(() => (lost ? null : ({} as WebGLTexture)));
const spy = vi
.spyOn(HTMLCanvasElement.prototype, "getContext")
.mockImplementation(((type: string) =>
type === "webgl" ? gl : type === "2d" ? mock2d() : null) as never);
try {
document.body.innerHTML = "";
const first = makeDrawableVideo();
first.id = "first";
const second = makeDrawableVideo();
second.id = "second";
second.style.visibility = "hidden";
document.body.append(first, second);
const runtime = createColorGradingRuntime();
const shared = spy.mock.instances[0] as HTMLCanvasElement;

lost = true;
shared.dispatchEvent(new Event("webglcontextlost", { cancelable: true }));
second.style.visibility = "visible";
runtime.refresh();
expect(runtime.getStatus("#second").state).toBe("unavailable");

lost = false;
shared.dispatchEvent(new Event("webglcontextrestored"));

expect(runtime.getStatus("#first").state).toBe("active");
expect(runtime.getStatus("#second").state).toBe("active");
runtime.destroy();
} finally {
spy.mockRestore();
document.body.innerHTML = "";
}
});
});

describe("installAuthoredOpacityCapture", () => {
it("stamps graded elements at insertion and never overwrites the stamp", async () => {
installAuthoredOpacityCapture();
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/runtime/colorGrading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3867,6 +3867,7 @@ export function createColorGradingRuntime(pausedMediaLease?: {
if (entry.contextLost) restoreSourceElement(entry);
else drawEntry(entry);
}
refresh();
});
shared = { canvas, gl };
return shared;
Expand Down
Loading