remove crash detection - was false-positive crashing every recording

This commit is contained in:
2026-05-28 01:08:46 +03:00
parent 4b6ca60b2e
commit 1a89a31ff5
2 changed files with 6 additions and 32 deletions
+2 -16
View File
@@ -1,8 +1,7 @@
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};
@@ -29,7 +28,6 @@ pub struct CaptureSetup {
pub height: u32,
pub fps: u32,
pub crop: Option<CaptureRect>,
pub crashed: Arc<AtomicBool>,
}
pub struct CaptureHandler {
@@ -38,7 +36,6 @@ pub struct CaptureHandler {
width: u32,
height: u32,
scratch: Vec<u8>,
crashed: Arc<AtomicBool>,
}
impl GraphicsCaptureApiHandler for CaptureHandler {
@@ -100,7 +97,6 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
width: setup.width,
height: setup.height,
scratch: Vec::with_capacity(frame_size),
crashed: setup.crashed,
})
}
@@ -124,8 +120,7 @@ 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");
self.crashed.store(true, Ordering::Release);
tracing::error!("ffmpeg stdin write failed: {e}");
anyhow!("ffmpeg encoder stopped unexpectedly: {e}")
})?;
Ok(())
@@ -147,7 +142,6 @@ pub struct CaptureSession {
pub width: u32,
pub height: u32,
pub crop: Option<CaptureRect>,
pub crashed: Arc<AtomicBool>,
control: CaptureControl<CaptureHandler, anyhow::Error>,
}
@@ -210,8 +204,6 @@ 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,
@@ -219,7 +211,6 @@ pub fn start(
height,
fps,
crop,
crashed: crashed.clone(),
};
let cursor_setting = if capture_cursor {
@@ -248,7 +239,6 @@ pub fn start(
width: out_w,
height: out_h,
crop,
crashed,
control,
})
}
@@ -275,10 +265,6 @@ 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()
-12
View File
@@ -420,13 +420,6 @@ fn pause_capture(state: State<'_, AppState>) -> Result<(), String> {
let session = lock(&state.capture)
.take()
.ok_or_else(|| "no capture in progress".to_string())?;
if session.has_crashed() {
tracing::warn!("ffmpeg crashed during recording, discarding incomplete capture");
// Drop the session (cleanup), clear related state
lock(&state.audio).take();
lock(&state.click_recorder).take();
return Err("recording failed - ffmpeg encoder crashed".to_string());
}
let elapsed = session.started_at.elapsed().as_secs_f64();
let path = session.stop().map_err(|e| format!("{e:#}"))?;
@@ -525,16 +518,11 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
let live = lock(&state.capture).take();
if let Some(session) = live {
if session.has_crashed() {
// ffmpeg crashed - don't try to stop/flush, just clean up
tracing::warn!("ffmpeg crashed during recording, discarding incomplete capture");
} else {
let elapsed = session.started_at.elapsed().as_secs_f64();
let path = session.stop().map_err(|e| format!("{e:#}"))?;
ss.segments.push(path);
ss.total_recorded_secs += elapsed;
}
}
let live_audio = lock(&state.audio).take();
if let Some(a) = live_audio {