Fix an issue where animations on the phone preview stopped prematurely

This commit is contained in:
James Babcock committed 2026-10-03 15:54:57 -07:00
1 parent eb7f385644
commit 4234d3e9e9
14 files changed
+160 -6

No files matched your search

+9 -1
View File
@@ -45,14 +45,20 @@ export class PreviewDisplayTarget implements DisplayTarget {
private onFrameComposited: (() => void) | null = null;
private released = false;
/** Receive a callback per applied frame, the stand-in for the connected path's frame-finished callback. */
/**
* Receive a callback per applied frame, the stand-in for the connected
* path's frame-finished callback, and per step of an animation the
* preview is replaying.
*/
activate(onFrameComposited: () => void): void {
this.onFrameComposited = onFrameComposited;
this.compositor.setPreviewAnimationListener(() => this.composited());
}
release(): void {
this.released = true;
this.onFrameComposited = null;
this.compositor.setPreviewAnimationListener(null);
}
private composited(): void {
@@ -61,7 +67,9 @@ export class PreviewDisplayTarget implements DisplayTarget {
async configureCompositorScreen(width: number, height: number): Promise<void> {
if (Math.round(width) !== this.compositor.width || Math.round(height) !== this.compositor.height) {
this.compositor.setPreviewAnimationListener(null);
this.compositor = new SurfaceCompositor(Math.round(width), Math.round(height));
if (this.onFrameComposited) this.compositor.setPreviewAnimationListener(() => this.composited());
}
}