20 fixes: mutex poisoning recovery, clickthrough shutdown, audio cleanup, config corruption, GIF aspect ratio, ffmpeg crash detection, cancel export, discard confirm, thumbnail cache, keyboard nav, right-click tracking, multi-monitor overlay, click injection fix, update script robustness, effect cleanup, concat guard, dead code removal

This commit is contained in:
2026-05-27 19:14:33 +03:00
parent f0775b8ff0
commit e4141f8be8
10 changed files with 310 additions and 140 deletions
+17 -2
View File
@@ -1,6 +1,8 @@
use std::io::Write;
use std::path::PathBuf;
use std::process::{Child, ChildStdin, Command, Stdio};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Instant;
use anyhow::{anyhow, bail, Context, Result};
@@ -27,6 +29,7 @@ pub struct CaptureSetup {
pub height: u32,
pub fps: u32,
pub crop: Option<CaptureRect>,
pub crashed: Arc<AtomicBool>,
}
pub struct CaptureHandler {
@@ -35,6 +38,7 @@ pub struct CaptureHandler {
width: u32,
height: u32,
scratch: Vec<u8>,
crashed: Arc<AtomicBool>,
}
impl GraphicsCaptureApiHandler for CaptureHandler {
@@ -96,6 +100,7 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
width: setup.width,
height: setup.height,
scratch: Vec::with_capacity(frame_size),
crashed: setup.crashed,
})
}
@@ -119,7 +124,8 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
return Ok(());
}
stdin.write_all(&bytes[..expected]).map_err(|e| {
tracing::error!("ffmpeg stdin write failed: {e} — encoder may have crashed");
tracing::error!("ffmpeg stdin write failed: {e} - encoder may have crashed");
self.crashed.store(true, Ordering::Release);
anyhow!("ffmpeg encoder stopped unexpectedly: {e}")
})?;
Ok(())
@@ -141,6 +147,7 @@ pub struct CaptureSession {
pub width: u32,
pub height: u32,
pub crop: Option<CaptureRect>,
pub crashed: Arc<AtomicBool>,
control: CaptureControl<CaptureHandler, anyhow::Error>,
}
@@ -203,6 +210,8 @@ pub fn start(
let (out_w, out_h) = compute_output_dims(width, height, crop);
let crashed = Arc::new(AtomicBool::new(false));
let setup = CaptureSetup {
output_path: output_path.clone(),
ffmpeg_path,
@@ -210,6 +219,7 @@ pub fn start(
height,
fps,
crop,
crashed: crashed.clone(),
};
let cursor_setting = if capture_cursor {
@@ -238,6 +248,7 @@ pub fn start(
width: out_w,
height: out_h,
crop,
crashed,
control,
})
}
@@ -264,6 +275,10 @@ fn compute_output_dims(monitor_w: u32, monitor_h: u32, crop: Option<CaptureRect>
}
impl CaptureSession {
pub fn has_crashed(&self) -> bool {
self.crashed.load(Ordering::Acquire)
}
pub fn stop(self) -> Result<PathBuf> {
self.control
.stop()
@@ -271,7 +286,7 @@ impl CaptureSession {
let meta = std::fs::metadata(&self.output_path)
.with_context(|| format!("checking output file {}", self.output_path.display()))?;
if meta.len() == 0 {
bail!("capture output file is empty — ffmpeg may have crashed during recording");
bail!("capture output file is empty - ffmpeg may have crashed during recording");
}
Ok(self.output_path)
}