Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Enable Windows release export workaround

Richie McIlroyaec751ed0641
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rs
index c8c7e460e..0e1adce97 100644
--- a/apps/desktop/src-tauri/src/export.rs
+++ b/apps/desktop/src-tauri/src/export.rs
@@ -425,7 +425,7 @@ async fn run_out_of_process_export(
force_ffmpeg: bool,
cancel_token: CancellationToken,
) -> Result<PathBuf, String> {
- let mode = ExportWorkerMode::HardwareOptimized;
+ let mode = initial_export_worker_mode();
match run_out_of_process_export_attempt(
project_path,
settings,
@@ -437,7 +437,7 @@ async fn run_out_of_process_export(
.await
{
Ok(path) => Ok(path),
- Err(e) if e != "Export cancelled" => {
+ Err(e) if e != "Export cancelled" && !mode.is_software_safe() => {
error!(
error = %e,
"Export worker failed, retrying with software rendering and encoding"
@@ -456,6 +456,14 @@ async fn run_out_of_process_export(
}
}
+fn initial_export_worker_mode() -> ExportWorkerMode {
+ if should_start_export_worker_in_software_safe_mode() {
+ ExportWorkerMode::SoftwareSafe
+ } else {
+ ExportWorkerMode::HardwareOptimized
+ }
+}
+
async fn run_out_of_process_export_attempt(
project_path: &Path,
settings: &ExportSettings,
@@ -900,7 +908,19 @@ fn is_frame_decode_error(error: &str) -> bool {
}
fn should_force_ffmpeg_export(_project_path: &Path, settings: &ExportSettings) -> bool {
- settings.force_ffmpeg_decoder()
+ settings.force_ffmpeg_decoder() || should_use_windows_release_export_workaround()
+}
+
+fn should_force_ffmpeg_preview() -> bool {
+ should_use_windows_release_export_workaround()
+}
+
+fn should_start_export_worker_in_software_safe_mode() -> bool {
+ should_use_windows_release_export_workaround()
+}
+
+fn should_use_windows_release_export_workaround() -> bool {
+ cfg!(all(target_os = "windows", not(debug_assertions)))
}
fn should_use_out_of_process_export() -> bool {
@@ -1398,7 +1418,7 @@ async fn generate_export_preview_inner(
.map_err(|e| format!("Failed to create render constants: {e}"))?,
);
- let force_ffmpeg = false;
+ let force_ffmpeg = should_force_ffmpeg_preview();
info!(
project_path = %project_path.display(),
force_ffmpeg,
@@ -1612,7 +1632,7 @@ mod tests {
#[cfg(target_os = "windows")]
#[test]
- fn windows_exports_do_not_force_ffmpeg_without_explicit_setting() {
+ fn windows_exports_force_ffmpeg_in_release_builds_without_explicit_setting() {
let dir = tempdir().unwrap();
let gif_settings = ExportSettings::Gif(cap_export::gif::GifExportSettings {
@@ -1621,7 +1641,18 @@ mod tests {
quality: None,
});
- assert!(!should_force_ffmpeg_export(dir.path(), &gif_settings));
+ assert_eq!(
+ should_force_ffmpeg_export(dir.path(), &gif_settings),
+ !cfg!(debug_assertions)
+ );
+ }
+
+ #[test]
+ fn windows_release_safe_mode_gate_matches_target() {
+ assert_eq!(
+ should_start_export_worker_in_software_safe_mode(),
+ cfg!(all(target_os = "windows", not(debug_assertions)))
+ );
}
}
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 4b00ad8ab..afee0929c 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -104,6 +104,9 @@ async endExportSession() : Promise<void> {
async cancelExport(exportId: string) : Promise<boolean> {
return await TAURI_INVOKE("cancel_export", { exportId });
},
+async cancelCurrentWindowExports() : Promise<void> {
+ await TAURI_INVOKE("cancel_current_window_exports");
+},
async exportVideo(projectPath: string, progress: TAURI_CHANNEL<FramesRendered>, settings: ExportSettings) : Promise<string> {
return await TAURI_INVOKE("export_video", { projectPath, progress, settings });
},
@@ -462,6 +465,7 @@ videoImportProgress: "video-import-progress"
/** user-defined types **/
+export type AllGpusInfo = { gpus: GpuInfoDiag[]; primaryGpuIndex: number | null; isMultiGpuSystem: boolean; hasDiscreteGpu: boolean }
export type Annotation = { id: string; type: AnnotationType; x: number; y: number; width: number; height: number; strokeColor: string; strokeWidth: number; fillColor: string; opacity: number; rotation: number; text: string | null; maskType?: MaskType | null; maskLevel?: number | null }
export type AnnotationType = "arrow" | "circle" | "rectangle" | "text" | "mask"
export type AppTheme = "system" | "light" | "dark"
@@ -539,6 +543,7 @@ quality: number | null;
*/
fast: boolean | null }
export type GlideDirection = "none" | "left" | "right" | "up" | "down"
+export type GpuInfoDiag = { vendor: string; description: string; dedicatedVideoMemoryMb: number; adapterIndex: number; isSoftwareAdapter: boolean; isBasicRenderDriver: boolean; supportsHardwareEncoding: boolean }
export type HapticPattern = "alignment" | "levelChange" | "generic"
export type HapticPerformanceTime = "default" | "now" | "drawCompleted"
export type Hotkey = { code: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }
@@ -556,7 +561,6 @@ export type KeyboardTrackSegment = { id: string; start: number; end: number; dis
export type LogicalBounds = { position: LogicalPosition; size: LogicalSize }
export type LogicalPosition = { x: number; y: number }
export type LogicalSize = { width: number; height: number }
-export type MacOSVersionInfo = { major: number; minor: number; patch: number; displayName: string; buildNumber: string; isAppleSilicon: boolean }
export type MainWindowRecordingStartBehaviour = "close" | "minimise"
export type MaskKeyframes = { position?: MaskVectorKeyframe[]; size?: MaskVectorKeyframe[]; intensity?: MaskScalarKeyframe[] }
export type MaskKind = "sensitive" | "highlight"
@@ -604,6 +608,7 @@ export type RecordingStatus = "pending" | "recording"
export type RecordingStopped = null
export type RecordingTargetMode = "display" | "window" | "area" | "camera"
export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }
+export type RenderingStatus = { isUsingSoftwareRendering: boolean; isUsingBasicRenderDriver: boolean; hardwareEncodingAvailable: boolean; warningMessage: string | null }
export type RequestOpenRecordingPicker = { target_mode: RecordingTargetMode | null }
export type RequestOpenSettings = { page: string }
export type RequestScreenCapturePrewarm = { force?: boolean }
@@ -631,7 +636,7 @@ export type StereoMode = "stereo" | "monoL" | "monoR"
export type StudioRecordingMeta = { segment: SingleSegment } | { inner: MultipleSegments }
export type StudioRecordingQuality = "compatibility" | "balanced" | "ultra"
export type StudioRecordingStatus = { status: "InProgress" } | { status: "NeedsRemux" } | { status: "Failed"; error: string } | { status: "Complete" }
-export type SystemDiagnostics = { macosVersion: MacOSVersionInfo | null; availableEncoders: string[]; screenCaptureSupported: boolean; metalSupported: boolean; gpuName: string | null }
+export type SystemDiagnostics = { windowsVersion: WindowsVersionInfo | null; gpuInfo: GpuInfoDiag | null; allGpus: AllGpusInfo | null; renderingStatus: RenderingStatus; availableEncoders: string[]; graphicsCaptureSupported: boolean; d3D11VideoProcessorAvailable: boolean }
export type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }
export type TextSegment = { start: number; end: number; track?: number; enabled?: boolean; content?: string; center?: XY<number>; size?: XY<number>; fontFamily?: string; fontSize?: number; fontWeight?: number; italic?: boolean; color?: string; fadeDuration?: number }
export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments: ZoomSegment[]; sceneSegments?: SceneSegment[]; maskSegments?: MaskSegment[]; textSegments?: TextSegment[]; captionSegments?: CaptionTrackSegment[]; keyboardSegments?: KeyboardTrackSegment[] }
@@ -651,6 +656,7 @@ export type WindowExclusion = { bundleIdentifier?: string | null; ownerName?: st
export type WindowId = string
export type WindowPosition = { x: number; y: number; displayId?: DisplayId | null }
export type WindowUnderCursor = { id: WindowId; app_name: string; bounds: LogicalBounds }
+export type WindowsVersionInfo = { major: number; minor: number; build: number; displayName: string; meetsRequirements: boolean; isWindows11: boolean }
export type XY<T> = { x: T; y: T }
export type ZoomMode = "auto" | { manual: { x: number; y: number } }
export type ZoomSegment = { start: number; end: number; amount: number; mode: ZoomMode; glideDirection?: GlideDirection; glideSpeed?: number; instantAnimation?: boolean; edgeSnapRatio?: number }