Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(ui): open on a software adapter, and say why when the window cannot start

Jareer04695f8c440a
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 5121c2c6..e244e6bd 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -279,6 +279,7 @@
"Go to start": "Go to start",
"Golden Hour": "Golden Hour",
"Grain": "Grain",
+ "Graphics": "Graphics",
"Green": "Green",
"Green Screen": "Green Screen",
"Greens": "Greens",
diff --git a/src/crates/concat/src/gpu.rs b/src/crates/concat/src/gpu.rs
index 923f75b7..a468e792 100644
--- a/src/crates/concat/src/gpu.rs
+++ b/src/crates/concat/src/gpu.rs
@@ -14,6 +14,19 @@
//! is carried and never opened there; see platform.rs.
#![cfg_attr(target_os = "android", allow(dead_code))]
+use std::sync::OnceLock;
+
+/// The adapter this run opened, as one line for Settings > About: name,
+/// backend, and whether it is a software rasteriser. Written once by
+/// [`Gpu::acquire`], because the adapter itself is moved into the monitor
+/// before the About sheet is built.
+static ADAPTER: OnceLock<String> = OnceLock::new();
+
+/// What [`Gpu::acquire`] found, or `None` when it found nothing.
+pub fn adapter_description() -> Option<&'static str> {
+ ADAPTER.get().map(String::as_str)
+}
+
/// The shared device and what it was created from.
#[derive(Clone)]
pub struct Gpu {
@@ -51,6 +64,26 @@ impl Gpu {
..Default::default()
}))
.ok()?;
+ // This is not always a GPU. wgpu ranks a CPU adapter last but never
+ // leaves it out, so on a machine whose hardware it will not drive -
+ // its D3D12 backend wants resource binding tier 2, which Intel's
+ // Broadwell-era chips do not have - the adapter that comes back is
+ // WARP, Windows' software rasteriser. The window still opens on it;
+ // see `is_software` and platform.rs for what that changes.
+ // https://github.com/jub0t/Concat/issues/135
+ let info = adapter.get_info();
+ log::info!(
+ "GPU adapter: {} ({:?}, {:?}, driver {})",
+ info.name,
+ info.device_type,
+ info.backend,
+ info.driver_info
+ );
+ let _ = ADAPTER.set(if info.device_type == wgpu::DeviceType::Cpu {
+ format!("{} · {} · software rasteriser", info.name, info.backend)
+ } else {
+ format!("{} · {}", info.name, info.backend)
+ });
// The adapter's own limits, not `Limits::default()`: the defaults are
// the downlevel floor every GL-class device can meet, and their
// `max_texture_dimension_2d` is 8192 whatever the machine can do -
@@ -72,6 +105,13 @@ impl Gpu {
})
}
+ /// Whether the adapter is a software rasteriser - WARP on Windows,
+ /// llvmpipe on Linux - rather than a GPU. Everything still draws, only
+ /// slower, and the sysinfo sheet says so.
+ pub fn is_software(&self) -> bool {
+ self.adapter.get_info().device_type == wgpu::DeviceType::Cpu
+ }
+
/// The device as Slint takes it.
pub fn configuration(&self) -> slint::wgpu_29::WGPUConfiguration {
slint::wgpu_29::WGPUConfiguration::Manual {
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index d571c834..3de60ddb 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -84,6 +84,20 @@ pub fn open_logging(extra: Option<Box<dyn log::Log>>) {
}
}
+/// Says why the window could not start, somewhere the user will see it.
+///
+/// [`run`] returns its failure, and a desktop binary's `main` returns that
+/// to the runtime, which prints it on standard error and exits 1 - exactly
+/// what a packaged GUI build has no console for. Each entry point calls
+/// this on the error before letting it go, so the reason is in the log and
+/// in a dialog, not only in a console that was never there.
+/// https://github.com/jub0t/Concat/issues/135
+pub fn report_startup_failure(error: &slint::PlatformError) {
+ let error = error.to_string();
+ log::error!("could not start: {error}");
+ platform::report_startup_failure(&error);
+}
+
/// Builds the window, binds it to the engine, and runs it until it closes.
pub fn run() -> Result<(), slint::PlatformError> {
// The shell doesn't exist yet - it needs the window the backend is about
diff --git a/src/crates/concat/src/main.rs b/src/crates/concat/src/main.rs
index c3b56d3a..a178edca 100644
--- a/src/crates/concat/src/main.rs
+++ b/src/crates/concat/src/main.rs
@@ -11,5 +11,8 @@ fn main() -> Result<(), slint::PlatformError> {
// A desktop's console is its standard error, which a packaged build
// has wired to nowhere; hence the file underneath it.
concat::open_logging(None);
- concat::run()
+ // A failure here is the one this binary would otherwise swallow: with
+ // no console, the runtime's "Error: ..." on standard error is lost.
+ // https://github.com/jub0t/Concat/issues/135
+ concat::run().inspect_err(concat::report_startup_failure)
}
diff --git a/src/crates/concat/src/platform.rs b/src/crates/concat/src/platform.rs
index 84085aff..43ff9084 100644
--- a/src/crates/concat/src/platform.rs
+++ b/src/crates/concat/src/platform.rs
@@ -98,8 +98,25 @@ pub fn select_backend(
// The device the renderer and the monitor share. Taken first, because
// the backend is selected with it.
let gpu = Gpu::acquire();
- if gpu.is_none() {
- log::warn!("no GPU adapter; the monitor composites on the CPU");
+ match &gpu {
+ None => log::warn!("no GPU adapter; the monitor composites on the CPU"),
+ // A software adapter is refused by Slint's selector unless this
+ // variable says otherwise: it enumerates the adapters on the instance
+ // it was handed, finds none that is a GPU, and `select` fails with
+ // "no GPU-backed WGPU adapter is available". From a double-clicked
+ // GUI build that failure went to a console nobody could see, and the
+ // app just never appeared. Setting it here is what the reporter did
+ // by hand, and the window, the editing and the export all worked on
+ // WARP - so the app does it for them and says so in the log.
+ // https://github.com/jub0t/Concat/issues/135
+ Some(gpu) if gpu.is_software() => {
+ log::warn!("the GPU adapter is a software rasteriser; the window will render slowly");
+ // SAFETY: the process is single-threaded at this point - the
+ // backend, the engine's threads and the window all come after
+ // this function - so nothing reads the environment concurrently.
+ unsafe { std::env::set_var("SLINT_WGPU_CPU", "1") };
+ }
+ Some(_) => {}
}
let mut selector = slint::BackendSelector::new()
@@ -175,6 +192,30 @@ pub fn select_backend(
Ok(gpu)
}
+/// Tells the user the window could not start, in a dialog of the platform's
+/// own, because the console the error would otherwise go to is not one a
+/// double-clicked build has: on Windows a GUI subsystem binary has no
+/// standard error, and the app was exiting with the reason written to
+/// nowhere. The log file is named so the reader has something to attach.
+/// https://github.com/jub0t/Concat/issues/135
+pub fn report_startup_failure(error: &str) {
+ #[cfg(not(any(target_os = "android", target_os = "ios")))]
+ {
+ let mut description = format!("Concat could not start.\n\n{error}");
+ if let Some(path) = concat_host::logs::current() {
+ description.push_str(&format!("\n\nLog: {}", path.display()));
+ }
+ rfd::MessageDialog::new()
+ .set_level(rfd::MessageLevel::Error)
+ .set_title("Concat")
+ .set_description(description)
+ .set_buttons(rfd::MessageButtons::Ok)
+ .show();
+ }
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ let _ = error;
+}
+
/// Whether the strip should draw its own window buttons: everywhere the
/// platform's decorations were taken off, which is everywhere but macOS,
/// where the traffic lights stay the window's.
diff --git a/src/crates/concat/src/sysinfo.rs b/src/crates/concat/src/sysinfo.rs
index de9253ab..d9089693 100644
--- a/src/crates/concat/src/sysinfo.rs
+++ b/src/crates/concat/src/sysinfo.rs
@@ -92,6 +92,14 @@ pub fn system_facts() -> Vec<(String, String)> {
}
.into(),
),
+ // The adapter the window and the monitor draw on, and whether it is
+ // a GPU at all. A machine that fell back to WARP looks like any
+ // other in the window, and the difference was the whole story of
+ // https://github.com/jub0t/Concat/issues/135
+ (
+ t("Graphics"),
+ crate::gpu::adapter_description().unwrap_or("none").into(),
+ ),
(
t("Engine"),
format!("concat-engine · FFmpeg {}", concat_media::linked_version()),