Skip to content

Commit 887a734

Browse files
committed
fix(ai-edition): fall back to VirtualPreview for the screen stage
The refactor that swapped the screen preview from the legacy CSS+<video> approach (VirtualPreview) to a Pixi v8 WebGL compositor (preview-compositor/PreviewCompositor) regressed the editor preview. The Pixi path needs the <video> to stay as a hidden decode source for a VideoSource; combined with setPixiReady firing while canvasSize is still {0,0} on first mount, the canvas init'd at 1x1, the resize effect bailed, and the user got an empty stage (wallpaper showing through) or a black rectangle where the screen should be. Restore the VirtualPreview path until the Pixi port has tests and its own QA. The Pixi files stay in the codebase under preview-compositor/ for the next attempt. Inline comment in PreviewCanvas.tsx records the failure write-up.
1 parent d2042c6 commit 887a734

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

‎src/components/ai-edition/PreviewCanvas.tsx‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ import { getCssClipPath } from "@/lib/webcamMaskShapes";
4949
import { getAspectRatioValue } from "@/utils/aspectRatioUtils";
5050
import { AnnotationLayer } from "./AnnotationLayer";
5151
import styles from "./NewEditorShell.module.css";
52-
import {
53-
PreviewCompositor,
54-
type VideoSourceDescriptor,
55-
} from "./preview-compositor/PreviewCompositor";
52+
import { type VideoSource, VirtualPreview } from "./VirtualPreview";
5653
import { WebcamOverlay } from "./WebcamOverlay";
5754
import { ZoomFocusOverlay } from "./ZoomFocusOverlay";
5855

5956
type BlurData = NonNullable<AxcutAnnotationRegion["blurData"]>;
6057

6158
interface PreviewCanvasProps {
62-
videoSources: VideoSourceDescriptor[];
59+
videoSources: VideoSource[];
6360
clips: AxcutClip[];
6461
zoomRegions?: AxcutZoomRegion[];
6562
speedRegions?: SpeedRegion[];
@@ -271,7 +268,23 @@ export function PreviewCanvas(props: PreviewCanvasProps) {
271268
<div className={styles.bgBlur} style={blurStyle} aria-hidden />
272269
{layout?.screenRect ? (
273270
<div className={styles.screenStage} style={screenStyle}>
274-
<PreviewCompositor {...relayProps} />
271+
{(() => {
272+
// ponytail: PreviewCompositor (Pixi v8) regressed the screen
273+
// preview — the `<video>` is `visibility: hidden` while it's
274+
// the decode source for a Pixi VideoSource, and the
275+
// combination of `setPixiReady` + `canvasSize === {0,0}` on
276+
// mount produces a 1x1 canvas that the resize effect never
277+
// widens (the user reports either an empty stage showing
278+
// the wallpaper through, or a black rectangle where the
279+
// screen recording should be). Falling back to the legacy
280+
// VirtualPreview path — CSS-transformed <video> + measure
281+
// on ResizeObserver — until the Pixi path is hardened
282+
// behind a flag with its own tests.
283+
// See docs/engineering/ai-edition-preview-pixi-rollback.md
284+
// (todo) for the failure write-up.
285+
void relayProps.clockRef;
286+
return <VirtualPreview {...relayProps} videoStyle={videoBorderRadiusStyle(settings)} />;
287+
})()}
275288
{selectedZoomRegion && props.onZoomFocusChange ? (
276289
<ZoomFocusOverlay
277290
region={selectedZoomRegion}
@@ -387,6 +400,12 @@ function buildScreenStyle(
387400
};
388401
}
389402

403+
function videoBorderRadiusStyle(
404+
settings: ReturnType<typeof useEditorSettings>["settings"],
405+
): React.CSSProperties {
406+
return { borderRadius: `${settings.borderRadius}px` };
407+
}
408+
390409
// Webcam slot: full composite-layout rect with mask shape + shadow. NO
391410
// borderRadius here — the rounded corners live on the <video> inside so they
392411
// actually clip the camera content rather than drawing a frame around it.

0 commit comments

Comments
 (0)