From b33ce5bf77018673f2bfcea3adce6436e289a199 Mon Sep 17 00:00:00 2001 From: lashman Date: Mon, 21 Sep 2026 06:22:44 +0300 Subject: [PATCH] fix the failures that were failing quietly --- src-tauri/build.rs | 13 +++++---- src-tauri/src/bootstrap.rs | 55 ++++++++++++++++++++++++++----------- src-tauri/src/capture.rs | 9 ++++++ src-tauri/src/lib.rs | 31 +++++++++++++++++---- src/lib/Main.svelte | 17 +++++++++--- src/lib/Picker.svelte | 1 + src/lib/Settings.svelte | 14 ++++++++-- src/lib/UpdateBanner.svelte | 5 +++- 8 files changed, 110 insertions(+), 35 deletions(-) diff --git a/src-tauri/build.rs b/src-tauri/build.rs index ffec4d4..dbb0e22 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -8,9 +8,9 @@ fn main() { /// Compile the HDR tonemap HLSL to bytecode at build time so we can embed it /// via `include_bytes`! and avoid a runtime dependency on `d3dcompiler_47.dll`. -/// Looks for fxc.exe in the installed Windows SDK. If fxc is unavailable the -/// .cso files are emitted empty and capture.rs falls back to runtime -/// `D3DCompile` (so a clean checkout without the SDK still builds). +/// Looks for fxc.exe in the installed Windows SDK. Without the SDK the .cso +/// files are emitted empty so the build still succeeds, and there is no runtime +/// compile path: capture.rs refuses to start on empty bytecode and says why. fn compile_shaders() { // Cargo always sets OUT_DIR for a build script; if it is missing the build // is broken in a way we cannot paper over, so say so plainly. @@ -56,15 +56,16 @@ fn compile_shaders() { } } None => { - // No SDK on the build machine - emit an empty .cso; capture.rs - // detects the zero size and compiles the HLSL at runtime. + // No SDK on the build machine - emit an empty .cso so the build + // still succeeds; capture.rs rejects it at startup and points at + // the SDK rather than failing opaquely on the first frame. drop(std::fs::write(&dst, [])); } } } if fxc.is_none() { - println!("cargo:warning=fxc.exe not found - shaders will be compiled at runtime"); + println!("cargo:warning=fxc.exe not found - shaders cannot be compiled, capture will refuse to start"); } println!("cargo:rerun-if-changed=shaders/tonemap.hlsl"); } diff --git a/src-tauri/src/bootstrap.rs b/src-tauri/src/bootstrap.rs index 7a408d4..d7a6f7a 100644 --- a/src-tauri/src/bootstrap.rs +++ b/src-tauri/src/bootstrap.rs @@ -41,20 +41,31 @@ struct Source { release_api_url: &'static str, asset_name_suffix: &'static str, kind: ArchiveKind, + /// Release download directory, used to fetch the sibling `.sha256`. None + /// when the project publishes no checksums at all. + download_base: Option<&'static str>, } +// `releases/latest` rather than `releases/tags/latest` for both: the latter +// only resolves for a repo that happens to have a tag literally named "latest", +// which GyanD does not - its tag is the version, so that URL 404s. +// +// BtbN is first because its zip is the path that actually installs today; the +// 7z branch below is the fallback. const SOURCES: &[Source] = &[ - Source { - name: "GyanD", - release_api_url: "https://api.github.com/repos/GyanD/codexffmpeg/releases/tags/latest", - asset_name_suffix: "full_build.7z", - kind: ArchiveKind::SevenZ, - }, Source { name: "BtbN", - release_api_url: "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/tags/latest", + release_api_url: "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest", asset_name_suffix: "win64-gpl.zip", kind: ArchiveKind::Zip, + download_base: None, + }, + Source { + name: "GyanD", + release_api_url: "https://api.github.com/repos/GyanD/codexffmpeg/releases/latest", + asset_name_suffix: "full_build.7z", + kind: ArchiveKind::SevenZ, + download_base: Some("https://github.com/GyanD/codexffmpeg/releases/download"), }, ]; @@ -104,17 +115,29 @@ where let (asset, version) = pick_asset(&client, source).await?; - // GyanD publishes a .sha256 file alongside each release. - // BtbN does not, so we skip verification for BtbN. - let expected = if source.name == "GyanD" { - let checksum_url = format!( - "https://github.com/GyanD/codexffmpeg/releases/download/{}/{}.sha256", - version, + // Verify against the published checksum when there is one. GyanD used to + // ship a .sha256 next to each asset and no longer does, so a missing + // checksum downgrades to a logged warning rather than failing the source - + // aborting on it would just push the user onto the unverified build anyway. + let expected = if let Some(base) = source.download_base { + let checksum_url = format!("{base}/{version}/{}.sha256", asset.name); + match fetch_sha256(&client, &checksum_url).await { + Ok(hash) => Some(hash), + Err(e) => { + tracing::warn!( + "{} publishes no usable checksum for {} ({e:#}), continuing unverified", + source.name, + asset.name + ); + None + } + } + } else { + tracing::warn!( + "{} publishes no checksums, downloading {} unverified", + source.name, asset.name ); - Some(fetch_sha256(&client, &checksum_url).await?) - } else { - tracing::warn!("BtbN build: skipping SHA-256 verification (no checksum file)"); None }; diff --git a/src-tauri/src/capture.rs b/src-tauri/src/capture.rs index 3c6d062..760b801 100644 --- a/src-tauri/src/capture.rs +++ b/src-tauri/src/capture.rs @@ -213,6 +213,15 @@ fn new_vertex_buffer() -> (D3D11_BUFFER_DESC, D3D11_SUBRESOURCE_DATA) { impl TonemapPipeline { fn new(device: &ID3D11Device, width: u32, height: u32) -> Result { + // build.rs emits empty .cso files when fxc was missing at build time. + // Without this the only symptom is an opaque CreateVertexShader failure + // on the first frame of every recording. + if FULLSCREEN_VS.is_empty() || TONEMAP_PS.is_empty() { + bail!( + "shader bytecode is empty - rebuild with the Windows SDK installed so build.rs can run fxc" + ); + } + // Vertex shader: fullscreen-triangle pass-through (no vertex buffer). let mut vs = None; unsafe { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7759642..4a50a7e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1045,11 +1045,29 @@ const GIF_ESTIMATE_GRID: &[u64] = &[ 104_857_600, 209_715_200, ]; +/// The size-table scan sweeps target sizes itself, so it needs only the inputs +/// that shape a GIF budget - not the single requested target that +/// `PreviewRequest` requires. +#[derive(Debug, Deserialize)] +pub struct GifTableRequest { + pub fps: u32, + #[serde(default)] + pub gif_budget_mode: GifBudgetMode, + #[serde(default)] + pub gif_colors: Option, + #[serde(default)] + pub clip_width: u32, + #[serde(default)] + pub clip_height: u32, + #[serde(default)] + pub duration_secs: Option, +} + /// Return estimates for a grid of `target_bytes` values so the frontend can /// interpolate on slider drag without an IPC per debounce tick. The grid is /// geometric from 100KB to 200MB. #[tauri::command] -fn estimate_gif_params_table(request: PreviewRequest) -> GifEstimateTable { +fn estimate_gif_params_table(request: GifTableRequest) -> GifEstimateTable { let colors = request.gif_colors.unwrap_or(256); let dur = request.duration_secs.unwrap_or(0.0).max(0.1); let fps = request.fps; @@ -2214,13 +2232,16 @@ pub fn run() { Ok(Some(info)) => { tracing::info!(version = info.version, "update available"); drop(handle.emit("update-available", &info)); + updates::stamp_check(&app_dir); } - Ok(None) => tracing::debug!("no update available"), + Ok(None) => { + tracing::debug!("no update available"); + updates::stamp_check(&app_dir); + } + // No stamp on failure, so a transient network error does + // not silence the check for the whole TTL. Err(e) => tracing::warn!("update check failed: {e:#}"), } - // Stamp success on Ok results so a future launch won't - // re-check until the TTL elapses. Errors don't stamp. - updates::stamp_check(&app_dir); }); } Ok(()) diff --git a/src/lib/Main.svelte b/src/lib/Main.svelte index 8db5c95..b5476f3 100644 --- a/src/lib/Main.svelte +++ b/src/lib/Main.svelte @@ -202,6 +202,12 @@ // ---- Actions ---- + // Several template handlers fire a command without awaiting it; an unhandled + // rejection there would disappear without a trace. + function toastOnFail(p: Promise) { + void p.catch((e) => { errMsg = String(e) }) + } + async function toggleFrame() { useFrame = !useFrame try { @@ -418,6 +424,7 @@ const f = format if (phase !== "editing" || pathOverridden || !f) return void api.defaultOutputPath(f).then(p => { if (!pathOverridden) outputPath = p }) + .catch(e => console.warn("could not resolve the default output path:", e)) }) // Auto-dismiss error toast @@ -528,15 +535,15 @@ {#each PRESETS as [w, h, label]} {/each} {#if aspectLock !== null} {/if} @@ -712,7 +719,9 @@

{exportResult.output_path}

-
diff --git a/src/lib/Picker.svelte b/src/lib/Picker.svelte index 9a4f837..eb93797 100644 --- a/src/lib/Picker.svelte +++ b/src/lib/Picker.svelte @@ -22,6 +22,7 @@ void (async () => { await refresh() win.onMoved(refresh).then(fn => { if (mounted) unlisten.push(fn) }) + .catch(e => console.warn("could not watch the picker window position:", e)) let hoverDebounce = 0 listen("picker-hover", (e) => { clearTimeout(hoverDebounce) diff --git a/src/lib/Settings.svelte b/src/lib/Settings.svelte index 8b08f5e..cb0e51c 100644 --- a/src/lib/Settings.svelte +++ b/src/lib/Settings.svelte @@ -62,6 +62,10 @@ try { diagnostics = await api.diagnosticsInfo() } catch { diagnostics = null } } + function openLogFolder() { + void api.openLogDir().catch(e => console.warn("could not open the log folder:", e)) + } + async function save() { if (!cfg) return @@ -94,8 +98,12 @@ async function pickOutputDir() { if (!cfg) return - const picked = await open({ directory: true, defaultPath: cfg.output_dir ?? undefined }) - if (typeof picked === "string") cfg.output_dir = picked + try { + const picked = await open({ directory: true, defaultPath: cfg.output_dir ?? undefined }) + if (typeof picked === "string") cfg.output_dir = picked + } catch (e) { + console.warn("directory picker failed:", e) + } } @@ -288,7 +296,7 @@
Log folder {diagnostics ? diagnostics.log_dir : "..."} - +
diff --git a/src/lib/UpdateBanner.svelte b/src/lib/UpdateBanner.svelte index 5b8ae78..a505cec 100644 --- a/src/lib/UpdateBanner.svelte +++ b/src/lib/UpdateBanner.svelte @@ -20,7 +20,10 @@ }) function dismiss() { info = null; errMsg = null; phase = "info" } - function viewRelease() { if (info) void api.openUrl(info.release_url) } + function viewRelease() { + if (!info) return + void api.openUrl(info.release_url).catch(e => { errMsg = String(e); phase = "error" }) + } async function download() { if (!info?.download_url) { errMsg = "no downloadable exe in this release"; phase = "error"; return }