Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf(desktop): raise native camera preview thread priority

Richie McIlroyec8fba6e8b44
diff --git a/apps/desktop/src-tauri/src/camera.rs b/apps/desktop/src-tauri/src/camera.rs
index 7fedbc921..4d5789a3d 100644
--- a/apps/desktop/src-tauri/src/camera.rs
+++ b/apps/desktop/src-tauri/src/camera.rs
@@ -32,6 +32,14 @@ static TOOLBAR_HEIGHT: f32 = 56.0;
static GPU_SURFACE_SCALE: u32 = 2;
+#[cfg(target_os = "macos")]
+const QOS_CLASS_USER_INTERACTIVE: u32 = 0x21;
+
+#[cfg(target_os = "macos")]
+unsafe extern "C" {
+ fn pthread_set_qos_class_self_np(qos_class: u32, relative_priority: i32) -> i32;
+}
+
pub const MIN_CAMERA_SIZE: f32 = 150.0;
pub const MAX_CAMERA_SIZE: f32 = 600.0;
pub const DEFAULT_CAMERA_SIZE: f32 = 230.0;
@@ -260,6 +268,10 @@ impl CameraPreviewManager {
});
thread::spawn(move || {
+ #[cfg(target_os = "macos")]
+ unsafe {
+ pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
+ }
LocalSet::new().block_on(
&rt,
renderer.run(window.clone(), default_state, reconfigure_rx, camera_rx),