The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(start): a launch that died starting puts Concat in software for that build only, not for good (#476)
Jareerf26ebf64faa4
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.jsonindex 4a4afc00..f7bd5120 100644--- a/src/crates/concat/locales/en.json+++ b/src/crates/concat/locales/en.json@@ -445,7 +445,7 @@"settings.fromStore": "Updates come through the store.","settings.general": "General","settings.gpu": "Draw on the GPU",- "settings.gpuHint": "Off, the window and the preview draw in software: slower, but out of the way of a graphics driver that closes Concat. It turns off by itself if Concat closes while starting. Takes effect the next time Concat starts.",+ "settings.gpuHint": "Off, the window and the preview draw in software: slower, but out of the way of a graphics driver that closes Concat. It turns off by itself if Concat closes while starting, until Concat's next update. Takes effect the next time Concat starts.","settings.gpuNextStart": "Concat will draw this way from the next time it starts.","settings.hideTheToken": "Hide the token","settings.inUse": "In use",@@ -656,7 +656,7 @@"start.removeFromList": "Remove from list","start.reportProblem": "Report a problem","start.reportProblemNote": "What to send so it can be fixed",- "start.safeMode": "Concat closed while starting last time, so it is drawing in software now: slower, but it opens. To try the graphics card again, turn on Draw on the GPU in Settings > General.",+ "start.safeMode": "Concat closed while starting once, so it draws in software until its next update: slower, but it opens. To try the graphics card now, turn on Draw on the GPU in Settings > General.","start.searchProjects": "Search projects","start.settingsApplyWholeEdit": "These settings apply to the whole edit and cannot be changed later.","start.shape": "Shape",diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex ee56c910..58d63317 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -211,7 +211,9 @@ fn start(project: Option<std::path::PathBuf>, smoke: bool) -> Result<(), slint::platform::set_ui_scale(percent);}- let (startup_mark, safe) = safe_start();+ // Not for a smoke run: it exits through `leave`, past the mark's drop,+ // and the mark it left put the next real launch in software for nothing.+ let (startup_mark, safe) = if smoke { (None, false) } else { safe_start() };// The shell doesn't exist yet - it needs the window the backend is about// to help create - but `Shell::with` is a no-op until `Shell::install`@@ -2539,12 +2541,15 @@ const SAFE_AFTER: std::time::Duration = std::time::Duration::from_secs(15);/// first seconds - a new one each time (#339, #378, #389, #242) - and a/// launch check on a CI machine meets none of them. A launch that dies/// before [`SAFE_AFTER`] leaves its mark; the next one finds it, draws on-/// WARP or lavapipe instead of the GPU, and keeps doing so - a driver that-/// killed one launch kills the next, and starting on the GPU every other-/// time would crash every other time. Slower, and it opens. Settings >-/// General's GPU switch goes back. Only on Windows and Linux, which have a-/// software rasteriser to draw on; a Mac has none, and a phone's backend-/// picks its own way to draw.+/// WARP or lavapipe instead of the GPU, and keeps doing so for that build -+/// a driver that killed one launch kills the next, and starting on the GPU+/// every other time would crash every other time. Slower, and it opens.+/// The next build tries the GPU again: 0.2.8 kept the CPU for good, and a+/// Task Manager kill or a crash an update fixed left fast machines drawing+/// every hover on it (#476). Settings > General's GPU switch goes back+/// sooner. Only on Windows and Linux, which have a software rasteriser to+/// draw on; a Mac has none, and a phone's backend picks its own way to+/// draw.fn safe_start() -> (Option<concat_host::jobs::Tripwire>, bool) {if !cfg!(any(windows, target_os = "linux")) {return (None, false);@@ -2554,17 +2559,18 @@ fn safe_start() -> (Option<concat_host::jobs::Tripwire>, bool) {};let mark = dirs.data.join("startup");let mut preferences = prefs::Preferences::load(&dirs);- let safe = concat_host::jobs::Tripwire::tripped(&mark) && !preferences.software_gpu;- if safe {- log::warn!("start: the last launch closed while starting; drawing in software from now on");- preferences.software_gpu = true;+ let died = concat_host::jobs::Tripwire::tripped(&mark);+ if preferences.settle_start(died, &concat_host::machine::build()) {preferences.save(&dirs);}- if preferences.software_gpu && std::env::var_os("CONCAT_GPU").is_none() {+ if preferences.draws_in_software() && std::env::var_os("CONCAT_GPU").is_none() {// SAFETY: the process is single-threaded here, as for the scale// above: nothing reads the environment concurrently.unsafe { std::env::set_var("CONCAT_GPU", "software") };}+ // Said on every launch it holds, not only the first: the person on+ // the CPU is the one who wants to know why the window is slow.+ let safe = preferences.software_after_crash.is_some() && !preferences.software_gpu;(Some(concat_host::jobs::Tripwire::arm(&mark)), safe)}diff --git a/src/crates/concat/src/panes/settings.rs b/src/crates/concat/src/panes/settings.rsindex c4e2a613..ab271be2 100644--- a/src/crates/concat/src/panes/settings.rs+++ b/src/crates/concat/src/panes/settings.rs@@ -327,6 +327,7 @@ impl SettingsPane {}SettingsMsg::GpuChanged(on) => {studio.prefs.software_gpu = !on;+ studio.prefs.software_after_crash = None;studio.prefs.save(&studio.host.dirs);studio.notify(&t("settings.gpuNextStart"), false);}@@ -853,7 +854,7 @@ impl SettingsPane {.unwrap_or(2) as i32,playhead_stops: self.playhead_stops,proxies: studio.prefs.proxies,- gpu: !studio.prefs.software_gpu,+ gpu: !studio.prefs.draws_in_software(),gpu_switchable: cfg!(any(windows, target_os = "linux")),magnetic: studio.prefs.magnetic,download_source: self.download_source as i32,diff --git a/src/crates/concat/src/prefs.rs b/src/crates/concat/src/prefs.rsindex 2043790a..05aeab70 100644--- a/src/crates/concat/src/prefs.rs+++ b/src/crates/concat/src/prefs.rs@@ -69,10 +69,23 @@ pub struct Preferences {/// wants one for smoother playback turns it on in Settings.pub proxies: bool,/// Drawing in software: the window and the compositor on the- /// platform's software rasteriser (WARP, lavapipe) instead of the GPU.- /// Set by itself when a launch died while starting (see `safe_start`),- /// and turned off again in Settings > General. Read at launch.+ /// platform's software rasteriser (WARP, lavapipe) instead of the GPU,+ /// as the person chose in Settings > General or with `concat+ /// --software`. Kept until they turn it back. Read at launch.+ ///+ /// Not the `softwareGpu` key 0.2.8 wrote: that one a safe start also+ /// set, for good, and nothing can tell the two apart. Left behind, it+ /// gives every machine a safe start trapped on the CPU one more go on+ /// its GPU - a hover drew a 14700K at "Very High" power (#476) - and+ /// a GPU that still dies starting puts it back in software by itself.+ #[serde(rename = "drawInSoftware")]pub software_gpu: bool,+ /// The build whose launch died while starting, which put the window in+ /// software by itself (see `safe_start`): until another build starts,+ /// or the person turns the GPU back on. A crash that an update fixed -+ /// the stray dxcompiler.dll of #418 - or a driver that a later one did+ /// would otherwise leave Concat on the CPU for good.+ pub software_after_crash: Option<String>,/// The magnetic timeline: a delete and a trim close the gap they would/// leave, on the lane they happen on. Off by default, because a gap is/// sometimes the point; ⇧⌫ ripples either way.@@ -254,6 +267,37 @@ impl Preferences {.filter(|location| std::path::Path::new(location).is_dir())}+ /// Whether this launch draws in software, by choice or after a crash.+ pub fn draws_in_software(&self) -> bool {+ self.software_gpu || self.software_after_crash.is_some()+ }++ /// Settles how this launch draws, from whether the last one died while+ /// starting and which build this is; whether anything changed and+ /// wants saving. A death puts the window in software for this build. A+ /// different build tries the GPU again, and a death on it puts the+ /// window back.+ pub fn settle_start(&mut self, died_starting: bool, build: &str) -> bool {+ if self.software_gpu {+ return false;+ }+ match &self.software_after_crash {+ Some(crashed) if crashed != build => {+ log::info!("start: {crashed} closed while starting; {build} tries the GPU again");+ self.software_after_crash = None;+ true+ }+ None if died_starting => {+ log::warn!(+ "start: the last launch closed while starting; drawing in software until another build"+ );+ self.software_after_crash = Some(build.to_owned());+ true+ }+ _ => false,+ }+ }+/// Reads the file, or the defaults when there is none.pub fn load(dirs: &AppDirs) -> Self {std::fs::read(dirs.config.join(FILE))@@ -516,4 +560,56 @@ mod tests {let older: Preferences = serde_json::from_str(r#"{"dark": false}"#).unwrap();assert!(older.keybinds.is_empty());}++ /// A launch that died while starting puts the window in software for+ /// its build only: the next build tries the GPU again, and a death on+ /// that one puts it back. The person's own choice is never touched.+ #[test]+ fn a_crash_draws_in_software_until_another_build() {+ let mut prefs = Preferences::default();+ assert!(!prefs.settle_start(false, "a"));+ assert!(!prefs.draws_in_software());++ assert!(prefs.settle_start(true, "a"));+ assert!(prefs.draws_in_software());+ assert!(+ !prefs.settle_start(false, "a"),+ "same build stays in software"+ );+ assert!(+ !prefs.settle_start(true, "a"),+ "a death in software changes nothing"+ );+ assert!(prefs.draws_in_software());++ assert!(prefs.settle_start(false, "b"));+ assert!(!prefs.draws_in_software(), "a new build tries the GPU");+ assert!(prefs.settle_start(true, "b"));+ assert_eq!(prefs.software_after_crash.as_deref(), Some("b"));++ let mut chosen = Preferences {+ software_gpu: true,+ ..Preferences::default()+ };+ assert!(!chosen.settle_start(true, "a"));+ assert!(!chosen.settle_start(false, "b"));+ assert!(chosen.draws_in_software());+ assert_eq!(chosen.software_after_crash, None);+ }++ /// The `softwareGpu` key 0.2.8 wrote is let go, safe start's and the+ /// person's alike, so the GPU gets one more go; the new key round-trips.+ #[test]+ fn the_old_software_key_is_let_go() {+ let older: Preferences = serde_json::from_str(r#"{"softwareGpu": true}"#).unwrap();+ assert!(!older.draws_in_software());+ let prefs = Preferences {+ software_gpu: true,+ ..Preferences::default()+ };+ let text = serde_json::to_string(&prefs).unwrap();+ assert!(text.contains("\"drawInSoftware\":true"), "{text}");+ let back: Preferences = serde_json::from_str(&text).unwrap();+ assert!(back.software_gpu);+ }}