diff --git a/electron/main.ts b/electron/main.ts index c273daac..89d05051 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -17,6 +17,7 @@ import { import { RECORDINGS_DIR } from "./appPaths"; import { showCursor } from "./cursorHider"; import { + cleanupNativeVideoExportSessions, getSelectedSourceId, killWindowsCaptureProcess, registerIpcHandlers, @@ -46,11 +47,50 @@ import { } from "./windows"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const IS_SMOKE_EXPORT = process.env.RECORDLY_SMOKE_EXPORT === "1"; -if (process.platform === "darwin") { - app.commandLine.appendSwitch("disable-features", "MacCatapLoopbackAudioForScreenShare"); +function configureGpuAccelerationSwitches() { + app.commandLine.appendSwitch("ignore-gpu-blocklist"); + app.commandLine.appendSwitch("enable-gpu-rasterization"); + + if (process.platform === "darwin") { + app.commandLine.appendSwitch("use-angle", "metal"); + app.commandLine.appendSwitch("disable-features", "MacCatapLoopbackAudioForScreenShare"); + return; + } + + if (process.platform === "win32") { + app.commandLine.appendSwitch("use-angle", "d3d11"); + return; + } + + if (process.platform === "linux") { + app.commandLine.appendSwitch("use-angle", "vulkan"); + app.commandLine.appendSwitch("enable-features", "Vulkan"); + } } +async function logSmokeExportGpuDiagnostics() { + if (!IS_SMOKE_EXPORT) { + return; + } + + try { + console.log( + "[smoke-export] GPU feature status", + JSON.stringify(app.getGPUFeatureStatus()), + ); + console.log( + "[smoke-export] GPU info", + JSON.stringify(await app.getGPUInfo("basic")), + ); + } catch (error) { + console.warn("[smoke-export] Failed to read GPU diagnostics:", error); + } +} + +configureGpuAccelerationSwitches(); + async function ensureRecordingsDir() { try { await fs.mkdir(RECORDINGS_DIR, { recursive: true }); @@ -632,10 +672,11 @@ function createSourceSelectorWindowWrapper() { app.on("before-quit", () => { killWindowsCaptureProcess(); showCursor(); + cleanupNativeVideoExportSessions(); }); app.on("window-all-closed", () => { - if (process.platform !== "darwin") { + if (IS_SMOKE_EXPORT || process.platform !== "darwin") { app.quit(); } }); @@ -717,6 +758,15 @@ app.whenReady().then(async () => { }, ); + if (IS_SMOKE_EXPORT) { + await logSmokeExportGpuDiagnostics(); + console.log( + `[smoke-export] Starting editor smoke export for ${process.env.RECORDLY_SMOKE_EXPORT_INPUT ?? ""}`, + ); + createEditorWindowWrapper(); + return; + } + createWindow(); setupAutoUpdates(getUpdateDialogWindow, sendUpdateToastToWindows); diff --git a/electron/windows.ts b/electron/windows.ts index 1abb70e3..872689a5 100644 --- a/electron/windows.ts +++ b/electron/windows.ts @@ -41,6 +41,57 @@ let hudOverlayCompactWidth = HUD_MIN_WINDOW_WIDTH; let hudOverlayCompactHeight = HUD_COMPACT_HEIGHT; let hudOverlayExpandedHeight = HUD_MIN_EXPANDED_HEIGHT; +function getEditorWindowQuery(): Record { + const query: Record = { + windowType: "editor", + }; + + if (process.env.RECORDLY_SMOKE_EXPORT === "1") { + query.smokeExport = "1"; + if (process.env.RECORDLY_SMOKE_EXPORT_INPUT) { + query.smokeInput = process.env.RECORDLY_SMOKE_EXPORT_INPUT; + } + if (process.env.RECORDLY_SMOKE_EXPORT_OUTPUT) { + query.smokeOutput = process.env.RECORDLY_SMOKE_EXPORT_OUTPUT; + } + if (process.env.RECORDLY_SMOKE_EXPORT_USE_NATIVE === "1") { + query.smokeUseNativeExport = "1"; + } + if (process.env.RECORDLY_SMOKE_EXPORT_ENCODING_MODE) { + query.smokeEncodingMode = process.env.RECORDLY_SMOKE_EXPORT_ENCODING_MODE; + } + if (process.env.RECORDLY_SMOKE_EXPORT_SHADOW_INTENSITY) { + query.smokeShadowIntensity = process.env.RECORDLY_SMOKE_EXPORT_SHADOW_INTENSITY; + } + if (process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_INPUT) { + query.smokeWebcamInput = process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_INPUT; + } + if (process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_SHADOW) { + query.smokeWebcamShadow = process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_SHADOW; + } + if (process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_SIZE) { + query.smokeWebcamSize = process.env.RECORDLY_SMOKE_EXPORT_WEBCAM_SIZE; + } + if (process.env.RECORDLY_SMOKE_EXPORT_PIPELINE) { + query.smokePipelineModel = process.env.RECORDLY_SMOKE_EXPORT_PIPELINE; + } + if (process.env.RECORDLY_SMOKE_EXPORT_BACKEND) { + query.smokeBackendPreference = process.env.RECORDLY_SMOKE_EXPORT_BACKEND; + } + if (process.env.RECORDLY_SMOKE_EXPORT_MAX_ENCODE_QUEUE) { + query.smokeMaxEncodeQueue = process.env.RECORDLY_SMOKE_EXPORT_MAX_ENCODE_QUEUE; + } + if (process.env.RECORDLY_SMOKE_EXPORT_MAX_DECODE_QUEUE) { + query.smokeMaxDecodeQueue = process.env.RECORDLY_SMOKE_EXPORT_MAX_DECODE_QUEUE; + } + if (process.env.RECORDLY_SMOKE_EXPORT_MAX_PENDING_FRAMES) { + query.smokeMaxPendingFrames = process.env.RECORDLY_SMOKE_EXPORT_MAX_PENDING_FRAMES; + } + } + + return query; +} + function isHudOverlayCaptureProtectionSupported(): boolean { return process.platform !== "linux"; } @@ -547,11 +598,12 @@ export function createEditorWindow(): BrowserWindow { }); if (VITE_DEV_SERVER_URL) { - win.loadURL(VITE_DEV_SERVER_URL + "?windowType=editor"); + const query = new URLSearchParams(getEditorWindowQuery()); + win.loadURL(`${VITE_DEV_SERVER_URL}?${query.toString()}`); } else { console.log("[editor-window] load-file", path.join(RENDERER_DIST, "index.html")); win.loadFile(path.join(RENDERER_DIST, "index.html"), { - query: { windowType: "editor" }, + query: getEditorWindowQuery(), }); }