Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Merge remote-tracking branch 'origin/main' into perf/native-chunked-export-fastpath

wiiiii123762a5ba895ba
diff --cc electron/ipc/register/recording.ts
index a019a341,40a8d2f6..8d395e78
--- a/electron/ipc/register/recording.ts
+++ b/electron/ipc/register/recording.ts
@@@ -18,10 -18,10 +18,10 @@@ import { startWindowBoundsCapture, stop
import { startInteractionCapture, stopInteractionCapture } from "../cursor/interaction";
import { startNativeCursorMonitor, stopNativeCursorMonitor } from "../cursor/monitor";
import {
- clamp,
+ normalizeCursorTelemetrySamples,
pauseCursorCapture,
- resumeCursorCapture,
resetCursorCaptureClock,
+ resumeCursorCapture,
sampleCursorPoint,
snapshotCursorTelemetryForPersistence,
startCursorSampling,
@@@ -1354,58 -1334,8 +1347,8 @@@ export function registerRecordingHandle
const telemetryPath = getTelemetryPathForVideo(targetVideoPath);
try {
const content = await fs.readFile(telemetryPath, "utf-8");
- const parsed = JSON.parse(content);
+ const parsed = parseJsonWithByteOrderMark<unknown>(content);
- const parsedObject =
- parsed && typeof parsed === "object" && !Array.isArray(parsed)
- ? (parsed as { samples?: unknown })
- : null;
- const rawSamples = Array.isArray(parsed)
- ? parsed
- : Array.isArray(parsedObject?.samples)
- ? parsedObject.samples
- : [];
-
- const samples: CursorTelemetryPoint[] = rawSamples
- .filter((sample: unknown) => Boolean(sample && typeof sample === "object"))
- .map((sample: unknown) => {
- const point = sample as Partial<CursorTelemetryPoint>;
- return {
- timeMs:
- typeof point.timeMs === "number" && Number.isFinite(point.timeMs)
- ? Math.max(0, point.timeMs)
- : 0,
- cx:
- typeof point.cx === "number" && Number.isFinite(point.cx)
- ? clamp(point.cx, 0, 1)
- : 0.5,
- cy:
- typeof point.cy === "number" && Number.isFinite(point.cy)
- ? clamp(point.cy, 0, 1)
- : 0.5,
- interactionType:
- point.interactionType === "click" ||
- point.interactionType === "double-click" ||
- point.interactionType === "right-click" ||
- point.interactionType === "middle-click" ||
- point.interactionType === "move" ||
- point.interactionType === "mouseup"
- ? point.interactionType
- : undefined,
- cursorType:
- point.cursorType === "arrow" ||
- point.cursorType === "text" ||
- point.cursorType === "pointer" ||
- point.cursorType === "crosshair" ||
- point.cursorType === "open-hand" ||
- point.cursorType === "closed-hand" ||
- point.cursorType === "resize-ew" ||
- point.cursorType === "resize-ns" ||
- point.cursorType === "not-allowed"
- ? point.cursorType
- : undefined,
- };
- })
- .sort((a: CursorTelemetryPoint, b: CursorTelemetryPoint) => a.timeMs - b.timeMs);
+ const samples = normalizeCursorTelemetrySamples(parsed);
return { success: true, samples };
} catch (error) {
diff --cc src/components/video-editor/VideoPlayback.tsx
index 3a618d18,11002c6a..f55cda90
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@@ -323,14 -265,8 +315,9 @@@ interface VideoPlaybackProps
cursorClickBounceDuration?: number;
cursorSway?: number;
volume?: number;
+ suspendRendering?: boolean;
}
- type CaptionEditSession = {
- target: CaptionEditTarget;
- draft: string;
- };
-
export interface VideoPlaybackRef {
video: HTMLVideoElement | null;
app: Application | null;
@@@ -1722,9 -1449,9 +1616,9 @@@ const VideoPlayback = forwardRef<VideoP
// Video container - holds the masked video sprite
const videoContainer = new Container();
videoContainerRef.current = videoContainer;
- cameraContainer.addChild(videoContainer);
+ videoEffectsContainer.addChild(videoContainer);
- // Device frame overlay container — sits above video but below cursor
+ // Device frame overlay container - sits above video but below cursor
const frameContainer = new Container();
frameContainerRef.current = frameContainer;
cameraContainer.addChild(frameContainer);
diff --cc src/lib/exporter/modernFrameRenderer.ts
index e7f160b7,161d26bc..3297b801
--- a/src/lib/exporter/modernFrameRenderer.ts
+++ b/src/lib/exporter/modernFrameRenderer.ts
@@@ -217,61 -231,14 +231,69 @@@ interface CaptionRenderState
centerY: number;
}
+type PixiRendererAttempt = {
+ backend: ExportRenderBackend;
+ message: string;
+};
+
+const CANVAS_RENDERER_NOT_IMPLEMENTED_HINT = "CanvasRenderer is not yet implemented";
+const NO_RENDERER_HINT = "no available renderer";
+const PIXI_RENDERER_INIT_TIMEOUT_MS = 8_000;
+
+function isCanvasRenderer(application: Application): boolean {
+ const rendererName = application?.renderer?.constructor?.name?.toLowerCase();
+ return Boolean(rendererName && (rendererName.includes("canvasrenderer") || rendererName.includes("canvas")));
+}
+
+function toErrorMessage(error: unknown): string {
+ return error instanceof Error ? error.message : String(error ?? "Unknown renderer init error");
+}
+
+function summarizeRendererAttempts(attempts: readonly PixiRendererAttempt[]): string {
+ const details = attempts.map((attempt) => `${attempt.backend}: ${attempt.message}`).join(" | ");
+ return `No supported Pixi modern renderer was available. Attempted: ${details}`;
+}
+
+function isKnownRendererUnavailableError(error: unknown): boolean {
+ const message = toErrorMessage(error).toLowerCase();
+ return (
+ message.includes(CANVAS_RENDERER_NOT_IMPLEMENTED_HINT.toLowerCase()) ||
+ message.includes(NO_RENDERER_HINT)
+ );
+}
+
+type PixiInitOptions = Parameters<Application["init"]>[0];
+
+async function initApplicationWithTimeout(
+ app: Application,
+ options: PixiInitOptions,
+ backend: ExportRenderBackend,
+): Promise<void> {
+ const timeoutErrorMessage = `Initialization timed out after ${PIXI_RENDERER_INIT_TIMEOUT_MS}ms for ${backend} renderer`;
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
+ const timeoutPromise = new Promise<never>((_, reject) => {
+ timeoutId = setTimeout(() => {
+ reject(new Error(timeoutErrorMessage));
+ }, PIXI_RENDERER_INIT_TIMEOUT_MS);
+ });
+
+ try {
+ await Promise.race([app.init(options), timeoutPromise]);
+ } finally {
+ if (timeoutId !== undefined) {
+ clearTimeout(timeoutId);
+ }
+ }
+}
+
+ interface RenderSnapshot {
+ timeMs: number;
+ cursorTimeMs: number;
+ backgroundTimelineTimeMs: number;
+ sceneTransform: { scale: number; x: number; y: number };
+ zoom: { scale: number; focusX: number; focusY: number; progress: number };
+ }
+
function createAnimationState(): AnimationState {
return {
scale: 1,
diff --cc src/lib/exporter/modernVideoExporter.ts
index ed3df285,aabbbea0..09824840
--- a/src/lib/exporter/modernVideoExporter.ts
+++ b/src/lib/exporter/modernVideoExporter.ts
@@@ -211,8 -152,7 +217,9 @@@ export class ModernVideoExporter
private encoderName: string | null = null;
private backpressureProfile: ExportBackpressureProfile | null = null;
private nativeExportSessionId: string | null = null;
+ private nativeStaticLayoutSessionId: string | null = null;
+ private nativeStaticLayoutAverageFps: number | null = null;
+ private nativePendingWrite: Promise<void> = Promise.resolve();
private nativeWritePromises = new Set<Promise<void>>();
private nativeWriteError: Error | null = null;
private maxNativeWriteInFlight = 1;
diff --cc src/lib/wallpapers.test.ts
index ce338fdc,8e2ebe6f..57100955
--- a/src/lib/wallpapers.test.ts
+++ b/src/lib/wallpapers.test.ts
@@@ -12,14 -11,11 +12,15 @@@ describe("wallpapers", () =>
vi.unstubAllGlobals();
});
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
it("keeps the curated wallpaper list and default path aligned", () => {
- expect(DEFAULT_WALLPAPER_PATH).toBe("/wallpapers/midnight-8.jpg");
- expect(DEFAULT_WALLPAPER_RELATIVE_PATH).toBe("wallpapers/midnight-8.jpg");
+ expect(DEFAULT_WALLPAPER_PATH).toBe("/wallpapers/tahoe-light.jpg");
+ expect(DEFAULT_WALLPAPER_RELATIVE_PATH).toBe("wallpapers/tahoe-light.jpg");
expect(BUILT_IN_WALLPAPERS.at(0)?.publicPath).toBe(DEFAULT_WALLPAPER_PATH);
+ expect(BUILT_IN_WALLPAPERS.at(1)?.publicPath).toBe("/wallpapers/tahoe-dark.jpg");
expect(BUILT_IN_WALLPAPERS).toHaveLength(25);
});
diff --cc src/lib/wallpapers.ts
index be2637c2,2132b8d3..2cdd8a79
--- a/src/lib/wallpapers.ts
+++ b/src/lib/wallpapers.ts
@@@ -40,49 -40,9 +40,49 @@@ export const WALLPAPER_PATHS = BUILT_IN
export const WALLPAPER_RELATIVE_PATHS = BUILT_IN_WALLPAPERS.map(
(wallpaper) => wallpaper.relativePath,
);
- export const DEFAULT_WALLPAPER_PATH = "/wallpapers/midnight-8.jpg";
- export const DEFAULT_WALLPAPER_RELATIVE_PATH = "wallpapers/midnight-8.jpg";
+ export const DEFAULT_WALLPAPER_PATH = "/wallpapers/tahoe-light.jpg";
+ export const DEFAULT_WALLPAPER_RELATIVE_PATH = "wallpapers/tahoe-light.jpg";
+function safeDecodeFileName(fileName: string) {
+ try {
+ return decodeURIComponent(fileName);
+ } catch {
+ return fileName;
+ }
+}
+
+function getBundledWallpaperFileName(value: string) {
+ if (!value.startsWith("/wallpapers/")) {
+ return null;
+ }
+
+ const normalizedValue = value.split("?")[0] ?? value;
+ const fileName = normalizedValue.split("/").filter(Boolean).pop();
+ return fileName ? safeDecodeFileName(fileName) : null;
+}
+
+export async function resolveAvailableWallpaperPath(wallpaper: string): Promise<string> {
+ const bundledFileName = getBundledWallpaperFileName(wallpaper);
+ if (
+ !bundledFileName ||
+ typeof window === "undefined" ||
+ !window.electronAPI?.listAssetDirectory
+ ) {
+ return wallpaper;
+ }
+
+ try {
+ const result = await window.electronAPI.listAssetDirectory("wallpapers");
+ if (!result.success || !result.files?.length) {
+ return wallpaper;
+ }
+
+ return result.files.includes(bundledFileName) ? wallpaper : DEFAULT_WALLPAPER_PATH;
+ } catch {
+ return wallpaper;
+ }
+}
+
export function isVideoWallpaperSource(value: string): boolean {
if (!value) {
return false;