fix: pass platform from video/gifExporter to FrameRenderer, skip readback also for canvas composition for non-linux

This commit is contained in:
Theodor Peifer
2026-04-15 11:22:56 +02:00
parent d12f3980f9
commit 934f05cc80
3 changed files with 15 additions and 6 deletions
+8 -4
View File
@@ -78,6 +78,7 @@ interface FrameRenderConfig {
previewWidth?: number;
previewHeight?: number;
cursorTelemetry?: import("@/components/video-editor/types").CursorTelemetryPoint[];
platform: string;
}
interface AnimationState {
@@ -124,9 +125,11 @@ export class FrameRenderer {
private smoothedAutoFocus: { cx: number; cy: number } | null = null;
private prevAnimationTimeMs: number | null = null;
private prevTargetProgress = 0;
private isLinux = false;
constructor(config: FrameRenderConfig) {
this.config = config;
this.isLinux = config.platform === "linux";
this.animationState = {
scale: 1,
focusX: DEFAULT_FOCUS.cx,
@@ -189,10 +192,8 @@ export class FrameRenderer {
this.compositeCanvas.height = this.config.height;
// On Linux, getImageData() is called frequently causing frequent CPU readback
const isLinux = (await window.electronAPI.getPlatform()) === "linux";
this.compositeCtx = this.compositeCanvas.getContext("2d", {
willReadFrequently: isLinux,
willReadFrequently: this.isLinux,
});
if (!this.compositeCtx) {
@@ -730,7 +731,10 @@ export class FrameRenderer {
private compositeWithShadows(webcamFrame?: VideoFrame | null): void {
if (!this.compositeCanvas || !this.compositeCtx || !this.app) return;
const videoCanvas = this.readbackVideoCanvas();
const videoCanvas = this.isLinux
? this.readbackVideoCanvas()
: (this.app.canvas as HTMLCanvasElement);
const ctx = this.compositeCtx;
const w = this.compositeCanvas.width;
const h = this.compositeCanvas.height;
+4
View File
@@ -115,7 +115,10 @@ export class GifExporter {
async export(): Promise<ExportResult> {
let webcamFrameQueue: AsyncVideoFrameQueue | null = null;
try {
const platform = await window.electronAPI.getPlatform();
this.cleanup();
this.cancelled = false;
@@ -153,6 +156,7 @@ export class GifExporter {
previewWidth: this.config.previewWidth,
previewHeight: this.config.previewHeight,
cursorTelemetry: this.config.cursorTelemetry,
platform,
});
await this.renderer.initialize();
+3 -2
View File
@@ -111,9 +111,9 @@ export class VideoExporter {
this.cancelled = false;
this.fatalEncoderError = null;
const platform = await window.electronAPI.getPlatform();
try {
const platform = await window.electronAPI.getPlatform();
const streamingDecoder = new StreamingVideoDecoder();
this.streamingDecoder = streamingDecoder;
const videoInfo = await streamingDecoder.loadMetadata(this.config.videoUrl);
@@ -148,6 +148,7 @@ export class VideoExporter {
previewWidth: this.config.previewWidth,
previewHeight: this.config.previewHeight,
cursorTelemetry: this.config.cursorTelemetry,
platform,
});
this.renderer = renderer;
await renderer.initialize();