Skip to content

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

fix(linux): an export from the window draws on a device of its own on Vulkan, so it no longer loses the GPU part way through (#324)

Jareer14b5998d793d
diff --git a/src/crates/concat-host/src/preview.rs b/src/crates/concat-host/src/preview.rs
index ab36f685..68fbec27 100644
--- a/src/crates/concat-host/src/preview.rs
+++ b/src/crates/concat-host/src/preview.rs
@@ -135,6 +135,23 @@ impl Monitor {
Some(gpu.sibling())
}
+ /// [`Monitor::sibling`] for work on a thread of its own - the export,
+ /// the effect cards - where the window's queue can take it, and None
+ /// on Vulkan, where the work then opens a device of its own. Skia
+ /// submits the window's frames to the raw Vulkan queue without wgpu's
+ /// lock, and a Vulkan queue must not be submitted to from two threads
+ /// at once: an export from the window on Linux lost the device part
+ /// way through, and the window's with it (#324). Direct3D 12 and Metal
+ /// queues take submissions from any thread, so there the work stays on
+ /// the window's device, which is what kept the export alive on Windows
+ /// laptops with NVIDIA chips (#202).
+ #[cfg(feature = "gpu")]
+ pub fn off_thread(&self) -> Option<concat_render::WgpuCompositor> {
+ let gpu = self.gpu.as_ref()?;
+ let gpu = gpu.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
+ (gpu.adapter_info().backend != wgpu::Backend::Vulkan).then(|| gpu.sibling())
+ }
+
/// Whether frames can be composited on the GPU.
pub fn has_gpu(&self) -> bool {
#[cfg(feature = "gpu")]
diff --git a/src/crates/concat/src/panes/export.rs b/src/crates/concat/src/panes/export.rs
index 33a5e9f9..dad0f497 100644
--- a/src/crates/concat/src/panes/export.rs
+++ b/src/crates/concat/src/panes/export.rs
@@ -511,9 +511,11 @@ impl ExportPane {
// monitor's compositor - not on a second device opened through the
// drivers for the export alone, which on Windows laptops with NVIDIA
// chips took the whole app down at the first frame with nothing in
- // the log (issue #202). None without a GPU here, and the render then
- // opens what it can.
- let compositor = studio.host.monitor.sibling();
+ // the log (issue #202). Not on Vulkan, whose queue the window
+ // submits to from its own thread (#324); see `Monitor::off_thread`.
+ // None there or without a GPU, and the render then opens what it
+ // can.
+ let compositor = studio.host.monitor.off_thread();
spawn(
move || {
let job = job;
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index aaf9be77..593d8478 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -7407,7 +7407,9 @@ impl Studio {
return;
}
self.cards_busy = true;
- let compositor = self.host.monitor.sibling();
+ // On a thread of its own, so not on the window's device on Vulkan
+ // (#324).
+ let compositor = self.host.monitor.off_thread();
let spawned = std::thread::Builder::new()
.name("concat cards".to_owned())
.spawn(move || {