Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
perf(editor): NV12 output and non-blocking render
Richie McIlroy79a76ffc75da
diff --git a/apps/desktop/src-tauri/src/editor_window.rs b/apps/desktop/src-tauri/src/editor_window.rsindex 33a2d56f8..f47d3f43a 100644--- a/apps/desktop/src-tauri/src/editor_window.rs+++ b/apps/desktop/src-tauri/src/editor_window.rs@@ -3,6 +3,8 @@ use tauri::{AppHandle, Manager, Runtime, Window, ipc::CommandArg};use tokio::sync::{RwLock, watch};use tokio_util::sync::CancellationToken;+use cap_rendering::GpuOutputFormat;+use crate::{create_editor_instance_impl,frame_ws::{WSFrame, WSFrameFormat, create_watch_frame_ws},@@ -29,16 +31,22 @@ async fn do_prewarm(app: AppHandle, path: PathBuf) -> PendingResult {path,Box::new(move |output| {let ws_frame = match output {- cap_editor::EditorFrameOutput::Nv12(frame) => WSFrame {- data: frame.data,- width: frame.width,- height: frame.height,- stride: frame.y_stride,- frame_number: frame.frame_number,- target_time_ns: frame.target_time_ns,- format: WSFrameFormat::Nv12,- created_at: Instant::now(),- },+ cap_editor::EditorFrameOutput::Nv12(frame) => {+ let ws_format = match frame.format {+ GpuOutputFormat::Nv12 => WSFrameFormat::Nv12,+ GpuOutputFormat::Rgba => WSFrameFormat::Rgba,+ };+ WSFrame {+ data: frame.data,+ width: frame.width,+ height: frame.height,+ stride: frame.y_stride,+ frame_number: frame.frame_number,+ target_time_ns: frame.target_time_ns,+ format: ws_format,+ created_at: Instant::now(),+ }+ }cap_editor::EditorFrameOutput::Rgba(frame) => WSFrame {data: frame.data,width: frame.width,@@ -234,16 +242,22 @@ impl EditorInstances {path,Box::new(move |output| {let ws_frame = match output {- cap_editor::EditorFrameOutput::Nv12(frame) => WSFrame {- data: frame.data,- width: frame.width,- height: frame.height,- stride: frame.y_stride,- frame_number: frame.frame_number,- target_time_ns: frame.target_time_ns,- format: WSFrameFormat::Nv12,- created_at: Instant::now(),- },+ cap_editor::EditorFrameOutput::Nv12(frame) => {+ let ws_format = match frame.format {+ GpuOutputFormat::Nv12 => WSFrameFormat::Nv12,+ GpuOutputFormat::Rgba => WSFrameFormat::Rgba,+ };+ WSFrame {+ data: frame.data,+ width: frame.width,+ height: frame.height,+ stride: frame.y_stride,+ frame_number: frame.frame_number,+ target_time_ns: frame.target_time_ns,+ format: ws_format,+ created_at: Instant::now(),+ }+ }cap_editor::EditorFrameOutput::Rgba(frame) => WSFrame {data: frame.data,width: frame.width,diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex f378538a0..716b7c0ef 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -148,7 +148,7 @@ impl Renderer {}}match frame_renderer- .render_immediate(+ .render_immediate_nv12(current.segment_frames,current.uniforms,¤t.cursor,@@ -157,7 +157,7 @@ impl Renderer {.await{Ok(frame) => {- (self.frame_cb)(EditorFrameOutput::Rgba(frame));+ (self.frame_cb)(EditorFrameOutput::Nv12(frame));}Err(e) => {tracing::error!(error = %e, "Failed to render frame in editor");@@ -170,11 +170,7 @@ impl Renderer {}impl RendererHandle {- async fn send(&self, msg: RendererMessage) {- let _ = self.tx.send(msg).await;- }-- pub async fn render_frame(+ pub fn render_frame(&self,segment_frames: DecodedSegmentFrames,uniforms: ProjectUniforms,@@ -182,13 +178,12 @@ impl RendererHandle {) {let (finished_tx, _finished_rx) = oneshot::channel();- self.send(RendererMessage::RenderFrame {+ let _ = self.tx.try_send(RendererMessage::RenderFrame {segment_frames,uniforms,finished: finished_tx,cursor,- })- .await;+ });}pub async fn stop(&self) {diff --git a/crates/editor/src/editor_instance.rs b/crates/editor/src/editor_instance.rsindex 4879fadc2..df50aac1b 100644--- a/crates/editor/src/editor_instance.rs+++ b/crates/editor/src/editor_instance.rs@@ -532,8 +532,7 @@ impl EditorInstance {&zoom_focus_interpolator,);self.renderer- .render_frame(segment_frames, uniforms, segment_medias.cursor.clone())- .await;+ .render_frame(segment_frames, uniforms, segment_medias.cursor.clone());} else {warn!("Preview renderer: no frames returned for frame {}", frame_number);}