Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add system diagnostics collection and UI display

Richie McIlroy0d71888d96da
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index a9944f0f3..bb84c28cf 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -42,7 +42,8 @@
"Bash(cargo tree:*)",
"WebFetch(domain:github.com)",
"WebFetch(domain:docs.rs)",
- "WebFetch(domain:gix.github.io)"
+ "WebFetch(domain:gix.github.io)",
+ "Bash(cargo clean:*)"
],
"deny": [],
"ask": []
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index f5c19546d..2b1d08cff 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -420,6 +420,12 @@ async fn upload_logs(app_handle: AppHandle) -> Result<(), String> {
logging::upload_log_file(&app_handle).await
}
+#[tauri::command]
+#[specta::specta]
+fn get_system_diagnostics() -> cap_recording::diagnostics::SystemDiagnostics {
+ cap_recording::diagnostics::collect_diagnostics()
+}
+
#[tauri::command]
#[specta::specta]
#[instrument(skip(app_handle, state))]
@@ -2337,6 +2343,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
set_camera_input,
recording_settings::set_recording_mode,
upload_logs,
+ get_system_diagnostics,
recording::start_recording,
recording::stop_recording,
recording::pause_recording,
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx b/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx
index f81059faa..ae984036c 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx
@@ -2,10 +2,10 @@ import { Button } from "@cap/ui-solid";
import { action, useAction, useSubmission } from "@solidjs/router";
import { getVersion } from "@tauri-apps/api/app";
import { type as ostype } from "@tauri-apps/plugin-os";
-import { createSignal } from "solid-js";
+import { createResource, createSignal, For, Show } from "solid-js";
import toast from "solid-toast";
-import { commands } from "~/utils/tauri";
+import { commands, type SystemDiagnostics } from "~/utils/tauri";
import { apiClient, protectedHeaders } from "~/utils/web-api";
const sendFeedbackAction = action(async (feedback: string) => {
@@ -18,9 +18,19 @@ const sendFeedbackAction = action(async (feedback: string) => {
return response.body;
});
+async function fetchDiagnostics(): Promise<SystemDiagnostics | null> {
+ try {
+ return await commands.getSystemDiagnostics();
+ } catch (e) {
+ console.error("Failed to fetch diagnostics:", e);
+ return null;
+ }
+}
+
export default function FeedbackTab() {
const [feedback, setFeedback] = createSignal("");
const [uploadingLogs, setUploadingLogs] = createSignal(false);
+ const [diagnostics] = createResource(fetchDiagnostics);
const submission = useSubmission(sendFeedbackAction);
const sendFeedback = useAction(sendFeedbackAction);
@@ -107,6 +117,92 @@ export default function FeedbackTab() {
{uploadingLogs() ? "Uploading..." : "Upload Logs"}
</Button>
</div>
+
+ <div class="pt-6 border-t border-gray-2">
+ <h3 class="text-sm font-medium text-gray-12 mb-3">
+ System Information
+ </h3>
+ <Show
+ when={!diagnostics.loading && diagnostics()}
+ fallback={
+ <p class="text-sm text-gray-10">
+ Loading system information...
+ </p>
+ }
+ >
+ {(diag) => (
+ <div class="space-y-3 text-sm">
+ <Show when={diag().windowsVersion}>
+ {(ver) => (
+ <div class="space-y-1">
+ <p class="text-gray-11 font-medium">Operating System</p>
+ <p class="text-gray-10 bg-gray-2 px-2 py-1.5 rounded font-mono text-xs">
+ {ver().displayName}
+ </p>
+ </div>
+ )}
+ </Show>
+
+ <Show when={diag().gpuInfo}>
+ {(gpu) => (
+ <div class="space-y-1">
+ <p class="text-gray-11 font-medium">Graphics</p>
+ <p class="text-gray-10 bg-gray-2 px-2 py-1.5 rounded font-mono text-xs">
+ {gpu().description} ({gpu().vendor},{" "}
+ {gpu().dedicatedVideoMemoryMb} MB VRAM)
+ </p>
+ </div>
+ )}
+ </Show>
+
+ <div class="space-y-1">
+ <p class="text-gray-11 font-medium">Capture Support</p>
+ <div class="flex gap-2 flex-wrap">
+ <span
+ class={`px-2 py-1 rounded text-xs ${
+ diag().graphicsCaptureSupported
+ ? "bg-green-500/20 text-green-400"
+ : "bg-red-500/20 text-red-400"
+ }`}
+ >
+ Graphics Capture:{" "}
+ {diag().graphicsCaptureSupported
+ ? "Supported"
+ : "Not Supported"}
+ </span>
+ <span
+ class={`px-2 py-1 rounded text-xs ${
+ diag().d3D11VideoProcessorAvailable
+ ? "bg-green-500/20 text-green-400"
+ : "bg-yellow-500/20 text-yellow-400"
+ }`}
+ >
+ D3D11 Video:{" "}
+ {diag().d3D11VideoProcessorAvailable
+ ? "Available"
+ : "Unavailable"}
+ </span>
+ </div>
+ </div>
+
+ <Show when={diag().availableEncoders.length > 0}>
+ <div class="space-y-1">
+ <p class="text-gray-11 font-medium">Available Encoders</p>
+ <div class="flex gap-1.5 flex-wrap">
+ <For each={diag().availableEncoders}>
+ {(encoder) => (
+ <span class="px-2 py-1 bg-gray-2 rounded text-xs text-gray-10 font-mono">
+ {encoder}
+ </span>
+ )}
+ </For>
+ </div>
+ </div>
+ </Show>
+ </div>
+ )}
+ </Show>
+ </div>
</div>
</div>
</div>
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 88b4042ec..1afc1a010 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -17,6 +17,9 @@ async setRecordingMode(mode: RecordingMode) : Promise<null> {
async uploadLogs() : Promise<null> {
return await TAURI_INVOKE("upload_logs");
},
+async getSystemDiagnostics() : Promise<SystemDiagnostics> {
+ return await TAURI_INVOKE("get_system_diagnostics");
+},
async startRecording(inputs: StartRecordingInputs) : Promise<RecordingAction> {
return await TAURI_INVOKE("start_recording", { inputs });
},
@@ -420,6 +423,7 @@ quality: number | null;
* Whether to prioritize speed over quality (default: false)
*/
fast: boolean | null }
+export type GpuInfoDiag = { vendor: string; description: string; dedicatedVideoMemoryMb: number }
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 }
@@ -494,6 +498,7 @@ export type StartRecordingInputs = { capture_target: ScreenCaptureTarget; captur
export type StereoMode = "stereo" | "monoL" | "monoR"
export type StudioRecordingMeta = { segment: SingleSegment } | { inner: MultipleSegments }
export type StudioRecordingStatus = { status: "InProgress" } | { status: "NeedsRemux" } | { status: "Failed"; error: string } | { status: "Complete" }
+export type SystemDiagnostics = { windowsVersion: WindowsVersionInfo | null; gpuInfo: GpuInfoDiag | null; availableEncoders: string[]; graphicsCaptureSupported: boolean; d3D11VideoProcessorAvailable: boolean }
export type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }
export type TextSegment = { start: number; end: 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[] }
@@ -510,6 +515,7 @@ export type VideoUploadInfo = { id: string; link: string; config: S3UploadMeta }
export type WindowExclusion = { bundleIdentifier?: string | null; ownerName?: string | null; windowTitle?: string | null }
export type WindowId = string
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 }
diff --git a/crates/recording/src/diagnostics.rs b/crates/recording/src/diagnostics.rs
new file mode 100644
index 000000000..b304d95d7
--- /dev/null
+++ b/crates/recording/src/diagnostics.rs
@@ -0,0 +1,177 @@
+#[cfg(target_os = "windows")]
+mod windows_impl {
+ use serde::Serialize;
+ use specta::Type;
+
+ #[derive(Debug, Clone, Serialize, Type)]
+ #[serde(rename_all = "camelCase")]
+ pub struct WindowsVersionInfo {
+ pub major: u32,
+ pub minor: u32,
+ pub build: u32,
+ pub display_name: String,
+ pub meets_requirements: bool,
+ pub is_windows_11: bool,
+ }
+
+ #[derive(Debug, Clone, Serialize, Type)]
+ #[serde(rename_all = "camelCase")]
+ pub struct GpuInfoDiag {
+ pub vendor: String,
+ pub description: String,
+ pub dedicated_video_memory_mb: f64,
+ }
+
+ #[derive(Debug, Clone, Serialize, Type)]
+ #[serde(rename_all = "camelCase")]
+ pub struct SystemDiagnostics {
+ pub windows_version: Option<WindowsVersionInfo>,
+ pub gpu_info: Option<GpuInfoDiag>,
+ pub available_encoders: Vec<String>,
+ pub graphics_capture_supported: bool,
+ pub d3d11_video_processor_available: bool,
+ }
+
+ pub fn collect_diagnostics() -> SystemDiagnostics {
+ let windows_version = get_windows_version_info();
+ let gpu_info = get_gpu_info();
+ let available_encoders = get_available_encoders();
+ let graphics_capture_supported = check_graphics_capture_support();
+ let d3d11_video_processor_available = check_d3d11_video_processor();
+
+ tracing::info!("System Diagnostics:");
+ if let Some(ref ver) = windows_version {
+ tracing::info!(" Windows: {}", ver.display_name);
+ }
+ if let Some(ref gpu) = gpu_info {
+ tracing::info!(" GPU: {} ({})", gpu.description, gpu.vendor);
+ }
+ tracing::info!(" Encoders: {:?}", available_encoders);
+ tracing::info!(" Graphics Capture: {}", graphics_capture_supported);
+ tracing::info!(
+ " D3D11 Video Processor: {}",
+ d3d11_video_processor_available
+ );
+
+ SystemDiagnostics {
+ windows_version,
+ gpu_info,
+ available_encoders,
+ graphics_capture_supported,
+ d3d11_video_processor_available,
+ }
+ }
+
+ fn get_windows_version_info() -> Option<WindowsVersionInfo> {
+ scap_direct3d::WindowsVersion::detect().map(|v| WindowsVersionInfo {
+ major: v.major,
+ minor: v.minor,
+ build: v.build,
+ display_name: v.display_name(),
+ meets_requirements: v.meets_minimum_requirements(),
+ is_windows_11: v.is_windows_11(),
+ })
+ }
+
+ fn get_gpu_info() -> Option<GpuInfoDiag> {
+ cap_frame_converter::detect_primary_gpu().map(|info| GpuInfoDiag {
+ vendor: info.vendor_name().to_string(),
+ description: info.description.clone(),
+ dedicated_video_memory_mb: (info.dedicated_video_memory / (1024 * 1024)) as f64,
+ })
+ }
+
+ fn get_available_encoders() -> Vec<String> {
+ let candidates = [
+ "h264_nvenc",
+ "h264_qsv",
+ "h264_amf",
+ "h264_mf",
+ "libx264",
+ "hevc_nvenc",
+ "hevc_qsv",
+ "hevc_amf",
+ "hevc_mf",
+ "libx265",
+ ];
+
+ candidates
+ .iter()
+ .filter(|name| ffmpeg::encoder::find_by_name(name).is_some())
+ .map(|s| s.to_string())
+ .collect()
+ }
+
+ fn check_graphics_capture_support() -> bool {
+ scap_direct3d::is_supported().unwrap_or(false)
+ }
+
+ fn check_d3d11_video_processor() -> bool {
+ use cap_frame_converter::ConversionConfig;
+
+ let test_config = ConversionConfig::new(
+ ffmpeg::format::Pixel::BGRA,
+ 1920,
+ 1080,
+ ffmpeg::format::Pixel::NV12,
+ 1920,
+ 1080,
+ );
+
+ cap_frame_converter::D3D11Converter::new(test_config).is_ok()
+ }
+}
+
+#[cfg(target_os = "macos")]
+mod macos_impl {
+ use serde::Serialize;
+ use specta::Type;
+
+ #[derive(Debug, Clone, Serialize, Type)]
+ #[serde(rename_all = "camelCase")]
+ pub struct MacOSVersionInfo {
+ pub display_name: String,
+ }
+
+ #[derive(Debug, Clone, Serialize, Type)]
+ #[serde(rename_all = "camelCase")]
+ pub struct SystemDiagnostics {
+ pub macos_version: Option<MacOSVersionInfo>,
+ pub available_encoders: Vec<String>,
+ pub screen_capture_supported: bool,
+ }
+
+ pub fn collect_diagnostics() -> SystemDiagnostics {
+ let available_encoders = get_available_encoders();
+
+ tracing::info!("System Diagnostics:");
+ tracing::info!(" Encoders: {:?}", available_encoders);
+
+ SystemDiagnostics {
+ macos_version: None,
+ available_encoders,
+ screen_capture_supported: true,
+ }
+ }
+
+ fn get_available_encoders() -> Vec<String> {
+ let candidates = [
+ "h264_videotoolbox",
+ "libx264",
+ "hevc_videotoolbox",
+ "libx265",
+ ];
+
+ candidates
+ .iter()
+ .filter(|name| ffmpeg::encoder::find_by_name(name).is_some())
+ .map(|s| s.to_string())
+ .collect()
+ }
+}
+
+#[cfg(target_os = "windows")]
+pub use windows_impl::*;
+
+#[cfg(target_os = "macos")]
+pub use macos_impl::*;
diff --git a/crates/recording/src/lib.rs b/crates/recording/src/lib.rs
index e68b92d15..dc1670b27 100644
--- a/crates/recording/src/lib.rs
+++ b/crates/recording/src/lib.rs
@@ -1,6 +1,7 @@
pub mod benchmark;
mod capture_pipeline;
pub mod cursor;
+pub mod diagnostics;
pub mod feeds;
pub mod fragmentation;
pub mod instant_recording;