Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
build(win): fail the pack on a stale compositor addon, and split poc-d3d into crates/
Etienne Lescot279c1e5ea2ac
diff --git a/AGENTS.md b/AGENTS.mdindex babd479cb..b4b873979 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -80,7 +80,7 @@ Unit/browser tests can't exercise real capture (native screen recording, a physi**Judging the rendered picture**- A preview screenshot is a **downscaled** view of the compositor's output (a 1920-wide render shown in a ~600px pane, then downscaled again by the screenshot). Fine detail — a corner radius, a 1° edge slope, a soft shadow — does not survive that, and squinting at it produces confident wrong conclusions. To decide anything about pixels, **export and measure**: `Export → MP4 1080p`, then `ffmpeg -ss <t> -i out.mp4 -frames:v 1 -c:v ppm frame.ppm` and walk the raw bytes (a P6 PPM is a 15-line parser) for the exact edges. That is what settled a "the tilt is truncated" report: measured right edge 1539 px against a computed corner at 1540 — no clipping at all, the real defect was elsewhere.-- ffmpeg lives at `poc-d3d/thirdparty/ffmpeg-*/bin/ffmpeg.exe` (also needed on `PATH` for the compositor addon to load).+- ffmpeg lives at `crates/thirdparty/ffmpeg-*/bin/ffmpeg.exe` (also needed on `PATH` for the compositor addon to load).## PR & commit conventionsdiff --git a/poc-d3d/.cargo/config.toml b/crates/.cargo/config.tomlsimilarity index 90%rename from poc-d3d/.cargo/config.tomlrename to crates/.cargo/config.tomlindex 79bdd9a87..35d539b18 100644--- a/poc-d3d/.cargo/config.toml+++ b/crates/.cargo/config.toml@@ -1,4 +1,4 @@-# FFMPEG_DIR relatif au dossier poc-d3d/ (portable dans le repo). Y déposer le build+# FFMPEG_DIR relatif au dossier crates/ (portable dans le repo). Y déposer le build# ffmpeg LGPL-shared (voir README). LIBCLANG_PATH = install LLVM locale (bindgen).# Ces valeurs cèdent à une vraie variable d'environnement (force=false par défaut).#diff --git a/poc-d3d/.gitignore b/crates/.gitignoresimilarity index 100%rename from poc-d3d/.gitignorerename to crates/.gitignorediff --git a/poc-d3d/Cargo.lock b/crates/Cargo.locksimilarity index 99%rename from poc-d3d/Cargo.lockrename to crates/Cargo.lockindex 575d7a385..52c11e5e3 100644--- a/poc-d3d/Cargo.lock+++ b/crates/Cargo.lock@@ -111,7 +111,7 @@ dependencies = ["napi","napi-build","napi-derive",- "poc-d3d",+ "openscreen-compositor","windows",]@@ -346,6 +346,19 @@ version = "1.21.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"+[[package]]+name = "openscreen-compositor"+version = "0.0.0"+dependencies = [+ "anyhow",+ "bindgen",+ "cc",+ "image",+ "serde",+ "serde_json",+ "windows",+]+[[package]]name = "png"version = "0.18.1"@@ -364,11 +377,7 @@ name = "poc-d3d"version = "0.0.0"dependencies = ["anyhow",- "bindgen",- "cc",- "image",- "serde",- "serde_json",+ "openscreen-compositor","windows",]diff --git a/crates/Cargo.toml b/crates/Cargo.tomlnew file mode 100644index 000000000..ecb97d3c9--- /dev/null+++ b/crates/Cargo.toml@@ -0,0 +1,59 @@+# Workspace Rust d'OpenScreen.+#+# compositor/ la bibliothèque : D3D11, pipeline, effets HLSL, scène, curseur, audio,+# vue live. C'est du code de PRODUCTION — l'addon Electron s'y lie.+# compositor-view-napi/ l'addon napi-rs empaqueté dans l'app (compositor_view.node).+# poc-d3d/ le POC d'origine (GUI Win32 de preview/export + bench fps). Rien ici+# n'est packagé ; il est conservé comme banc de mesure et pièce d'époque.+#+# Le tout vivait sous `poc-d3d/`, ce qui laissait croire que la bibliothèque était jetable alors+# que l'app en dépend : un `.node` périmé s'est ainsi retrouvé packagé sans que personne tique.+# Les dépendances communes sont déclarées ici une seule fois plutôt que recopiées par crate.++[workspace]+resolver = "2"+members = ["compositor", "compositor-view-napi", "poc-d3d"]+# `cargo build` (x.bat) ne construit que le POC ; l'addon se build explicitement+# (`cargo build -p compositor-view-napi`), comme avant le découpage.+default-members = ["poc-d3d"]++[workspace.package]+version = "0.0.0"+edition = "2021"++[workspace.dependencies]+openscreen-compositor = { path = "compositor" }+anyhow = "1"+serde = { version = "1", features = ["derive"] }+serde_json = "1"+# Décodage des wallpapers image (jpg/png) pour le fond natif. default-features off →+# on ne tire que les décodeurs nécessaires (build plus léger).+image = { version = "0.25", default-features = false, features = ["jpeg", "png"] }++[workspace.dependencies.windows]+version = "0.58"+features = [+ "Win32_Foundation",+ "Win32_Graphics_Direct3D",+ "Win32_Graphics_Direct3D_Fxc", # D3DCompile (HLSL runtime)+ "Win32_Graphics_Direct3D11",+ "Win32_Graphics_Dxgi",+ "Win32_Graphics_Dxgi_Common",+ "Foundation_Numerics", # requis par les méthodes D2D à brosse (CreateSolidColorBrush)+ "Win32_Graphics_Direct2D", # cible de rendu D2D sur surface DXGI (texte, text.rs)+ "Win32_Graphics_Direct2D_Common", # D2D1_COLOR_F / PIXEL_FORMAT+ "Win32_Graphics_DirectWrite", # mise en page + rastérisation du texte+ "Win32_Graphics_Gdi", # brosses/police GUI de la preview (poc-d3d/src/app.rs)+ "Win32_System_Performance", # QueryPerformanceCounter / Frequency (§10)+ "Win32_System_LibraryLoader", # GetModuleHandleW (hInstance)+ "Win32_UI_WindowsAndMessaging", # fenêtres (harnais live + GUI du POC)+ "Win32_UI_Controls", # barre de progression (poc-d3d/src/app.rs)+ "Win32_UI_Input_KeyboardAndMouse", # EnableWindow (poc-d3d/src/app.rs)+]++[profile.release]+opt-level = 3+lto = true+debug = false+# §10 : debug_assertions OFF dans tout run mesuré+overflow-checks = falsediff --git a/poc-d3d/README.md b/crates/README.mdsimilarity index 80%rename from poc-d3d/README.mdrename to crates/README.mdindex cc69c8a2c..605c5a366 100644--- a/poc-d3d/README.md+++ b/crates/README.md@@ -1,4 +1,18 @@-# poc-d3d — POC compositeur natif D3D11 (le fast-path natif retenu)+# crates/ — le compositeur natif D3D11 (le fast-path natif retenu)++| Crate | Rôle |+|---|---|+| [`compositor/`](compositor) | La bibliothèque : D3D11, décodage, pipeline, effets HLSL, scène, curseur, audio, vue live. **Code de production** — la preview et l'export de l'app passent par là. |+| [`compositor-view-napi/`](compositor-view-napi) | L'addon napi-rs. C'est lui qui produit `compositor_view.node`, **le binaire packagé dans l'app**. |+| [`poc-d3d/`](poc-d3d) | Le POC d'origine : GUI Win32 de preview/export + harnais de bench fps. **Rien ici n'est packagé** ; conservé comme banc de mesure et pièce d'époque. |++Tout vivait auparavant sous `poc-d3d/`, ce qui laissait croire que la bibliothèque était+jetable alors que l'app en dépend — un `.node` périmé s'est ainsi retrouvé packagé sans que+personne tique. Le garde-fou est décrit dans+[`build-and-packaging.md`](../technical-documentation/engineering/build-and-packaging.md#stale-native-artifacts) ;+en un mot : sur Windows, packager avec `npm run build:win`, jamais `npm run build`.++Le reste de ce document est l'historique du POC qui a produit ce compositeur.Troisième POC de rendu d'OpenScreen, à côté de [`poc/`](../poc) (web, WebCodecs + WebGPU)et [`poc-native/`](../poc-native) (Rust + wgpu/Vulkan). Voir la spec :diff --git a/poc-d3d/compositor-view-napi/Cargo.toml b/crates/compositor-view-napi/Cargo.tomlsimilarity index 50%rename from poc-d3d/compositor-view-napi/Cargo.tomlrename to crates/compositor-view-napi/Cargo.tomlindex 1d385a8cd..166dc920b 100644--- a/poc-d3d/compositor-view-napi/Cargo.toml+++ b/crates/compositor-view-napi/Cargo.toml@@ -1,8 +1,8 @@[package]name = "compositor-view-napi"-version = "0.0.0"-edition = "2021"-description = "Addon napi-rs : expose poc_d3d::live::LiveView (fenêtre D3D enfant) à Electron."+version.workspace = true+edition.workspace = true+description = "Addon napi-rs : expose openscreen_compositor::live::LiveView (fenêtre D3D enfant) à Electron. C'est CE crate qui produit compositor_view.node, le binaire packagé dans l'app."[lib]crate-type = ["cdylib"]@@ -11,8 +11,8 @@ name = "compositor_view"[dependencies]napi = { version = "2", default-features = false, features = ["napi6"] }napi-derive = "2"-poc-d3d = { path = ".." }-anyhow = "1"+openscreen-compositor.workspace = true+anyhow.workspace = true[dependencies.windows]version = "0.58"diff --git a/poc-d3d/compositor-view-napi/build.rs b/crates/compositor-view-napi/build.rssimilarity index 100%rename from poc-d3d/compositor-view-napi/build.rsrename to crates/compositor-view-napi/build.rsdiff --git a/poc-d3d/compositor-view-napi/src/lib.rs b/crates/compositor-view-napi/src/lib.rssimilarity index 98%rename from poc-d3d/compositor-view-napi/src/lib.rsrename to crates/compositor-view-napi/src/lib.rsindex 41e0978a3..db91121ce 100644--- a/poc-d3d/compositor-view-napi/src/lib.rs+++ b/crates/compositor-view-napi/src/lib.rs@@ -1,4 +1,4 @@-//! Addon napi-rs : pont Electron ↔ `poc_d3d::live::LiveView`. Expose la vue+//! Addon napi-rs : pont Electron ↔ `openscreen_compositor::live::LiveView`. Expose la vue//! offscreen (Option B, post-readback `Vec<u8>` RGBA8 → `<canvas>` HTML) à la//! glue TS (native-bridge domaine "compositor"). Les `#[napi]` sont appelés//! depuis le thread principal Node (là où vit la `BrowserWindow`) ; le rendu et@@ -9,11 +9,11 @@ use napi::bindgen_prelude::*;use napi::threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode};use napi::{Env, JsFunction, Task};use napi_derive::napi;-use poc_d3d::compositor::{live_params_from_scene, Compositor};-use poc_d3d::d3d::Gpu;-use poc_d3d::live::{LiveView, PausedPreviews};-use poc_d3d::scene::Scene;-use poc_d3d::{config, pipeline};+use openscreen_compositor::compositor::{live_params_from_scene, Compositor};+use openscreen_compositor::d3d::Gpu;+use openscreen_compositor::live::{LiveView, PausedPreviews};+use openscreen_compositor::scene::Scene;+use openscreen_compositor::{config, pipeline};use std::collections::HashMap;use std::sync::{Mutex, OnceLock};diff --git a/crates/compositor/Cargo.toml b/crates/compositor/Cargo.tomlnew file mode 100644index 000000000..969f26be8--- /dev/null+++ b/crates/compositor/Cargo.toml@@ -0,0 +1,20 @@+[package]+name = "openscreen-compositor"+version.workspace = true+edition.workspace = true+description = "Compositeur natif D3D11 d'OpenScreen : décodage, pipeline, effets HLSL, scène, curseur, audio et vue live. Code de production — l'addon Electron (compositor-view-napi) s'y lie, le POC (poc-d3d) le consomme aussi."++[lib]+name = "openscreen_compositor"+path = "src/lib.rs"++[build-dependencies]+bindgen = "0.70"+cc = "1"++[dependencies]+anyhow.workspace = true+serde.workspace = true+serde_json.workspace = true+image.workspace = true+windows.workspace = truediff --git a/poc-d3d/build.rs b/crates/compositor/build.rssimilarity index 100%rename from poc-d3d/build.rsrename to crates/compositor/build.rsdiff --git a/poc-d3d/shim.c b/crates/compositor/shim.csimilarity index 100%rename from poc-d3d/shim.crename to crates/compositor/shim.cdiff --git a/poc-d3d/src/audio.rs b/crates/compositor/src/audio.rssimilarity index 100%rename from poc-d3d/src/audio.rsrename to crates/compositor/src/audio.rsdiff --git a/poc-d3d/src/compositor.rs b/crates/compositor/src/compositor.rssimilarity index 100%rename from poc-d3d/src/compositor.rsrename to crates/compositor/src/compositor.rsdiff --git a/poc-d3d/src/config.rs b/crates/compositor/src/config.rssimilarity index 100%rename from poc-d3d/src/config.rsrename to crates/compositor/src/config.rsdiff --git a/poc-d3d/src/cursor.rs b/crates/compositor/src/cursor.rssimilarity index 100%rename from poc-d3d/src/cursor.rsrename to crates/compositor/src/cursor.rsdiff --git a/poc-d3d/src/d3d.rs b/crates/compositor/src/d3d.rssimilarity index 100%rename from poc-d3d/src/d3d.rsrename to crates/compositor/src/d3d.rsdiff --git a/poc-d3d/src/ffi.rs b/crates/compositor/src/ffi.rssimilarity index 100%rename from poc-d3d/src/ffi.rsrename to crates/compositor/src/ffi.rsdiff --git a/crates/compositor/src/lib.rs b/crates/compositor/src/lib.rsnew file mode 100644index 000000000..380ab9933--- /dev/null+++ b/crates/compositor/src/lib.rs@@ -0,0 +1,20 @@+//! Le compositeur natif D3D11 d'OpenScreen : décodage, pipeline, effets HLSL, scène, curseur,+//! audio, et la vue live embarquable (`live`).+//!+//! C'est du code de PRODUCTION. `compositor-view-napi` s'y lie pour produire+//! `compositor_view.node`, le binaire que l'app Electron charge — la preview comme l'export+//! passent par ici. Le POC de mesure (`poc-d3d`) n'est qu'un autre consommateur de cette+//! bibliothèque, pas l'inverse : la GUI Win32 et le harnais de bench vivent chez lui.++pub mod audio;+pub mod compositor;+pub mod config;+pub mod cursor;+pub mod d3d;+pub mod ffi;+pub mod live;+pub mod pipeline;+pub mod regions;+pub mod scene;+pub mod text;+pub mod text_anim;diff --git a/poc-d3d/src/live.rs b/crates/compositor/src/live.rssimilarity index 100%rename from poc-d3d/src/live.rsrename to crates/compositor/src/live.rsdiff --git a/poc-d3d/src/pipeline.rs b/crates/compositor/src/pipeline.rssimilarity index 100%rename from poc-d3d/src/pipeline.rsrename to crates/compositor/src/pipeline.rsdiff --git a/poc-d3d/src/regions.rs b/crates/compositor/src/regions.rssimilarity index 100%rename from poc-d3d/src/regions.rsrename to crates/compositor/src/regions.rsdiff --git a/poc-d3d/src/scene.rs b/crates/compositor/src/scene.rssimilarity index 100%rename from poc-d3d/src/scene.rsrename to crates/compositor/src/scene.rsdiff --git a/poc-d3d/src/shaders.hlsl b/crates/compositor/src/shaders.hlslsimilarity index 100%rename from poc-d3d/src/shaders.hlslrename to crates/compositor/src/shaders.hlsldiff --git a/poc-d3d/src/text.rs b/crates/compositor/src/text.rssimilarity index 100%rename from poc-d3d/src/text.rsrename to crates/compositor/src/text.rsdiff --git a/poc-d3d/src/text_anim.rs b/crates/compositor/src/text_anim.rssimilarity index 100%rename from poc-d3d/src/text_anim.rsrename to crates/compositor/src/text_anim.rsdiff --git a/poc-d3d/tests/output_geometry_golden.rs b/crates/compositor/tests/output_geometry_golden.rssimilarity index 98%rename from poc-d3d/tests/output_geometry_golden.rsrename to crates/compositor/tests/output_geometry_golden.rsindex d4dcca2d5..fca407d0d 100644--- a/poc-d3d/tests/output_geometry_golden.rs+++ b/crates/compositor/tests/output_geometry_golden.rs@@ -24,11 +24,11 @@//! portrait : c'est la mesure du détail regagné, aujourd'hui perdu parce//! que le canvas plafonne à 1080 lignes et que `blit_resized` agrandit.-use poc_d3d::compositor::Compositor;-use poc_d3d::d3d::Gpu;-use poc_d3d::live::Player;-use poc_d3d::scene::Scene;-use poc_d3d::config;+use openscreen_compositor::compositor::Compositor;+use openscreen_compositor::d3d::Gpu;+use openscreen_compositor::live::Player;+use openscreen_compositor::scene::Scene;+use openscreen_compositor::config;/// Instant fixe dans la source. Un seek explicite (`present_frame`) plutôt que/// la lecture libre : le golden doit être reproductible à l'octet près.diff --git a/poc-d3d/wrapper.h b/crates/compositor/wrapper.hsimilarity index 100%rename from poc-d3d/wrapper.hrename to crates/compositor/wrapper.hdiff --git a/poc-d3d/fixture/fixture.json b/crates/fixture/fixture.jsonsimilarity index 100%rename from poc-d3d/fixture/fixture.jsonrename to crates/fixture/fixture.jsondiff --git a/crates/poc-d3d/Cargo.toml b/crates/poc-d3d/Cargo.tomlnew file mode 100644index 000000000..34ba4e7ce--- /dev/null+++ b/crates/poc-d3d/Cargo.toml@@ -0,0 +1,18 @@+# Le POC d'origine, conservé tel quel comme banc de mesure et pièce d'époque.+# Rien ici n'est packagé dans l'app : la GUI Win32 de preview/export (`app.rs`) et le+# harnais de bench fps (`bench.rs`) ne servent qu'à mesurer et à regarder. Tout ce qui+# est réellement expédié vit dans `openscreen-compositor` et `compositor-view-napi`.+[package]+name = "poc-d3d"+version.workspace = true+edition.workspace = true+description = "POC de mesure OpenScreen : GUI Win32 de preview/export + harnais de bench fps (§9/§10) au-dessus d'openscreen-compositor."++[[bin]]+name = "poc-d3d"+path = "src/main.rs"++[dependencies]+openscreen-compositor.workspace = true+anyhow.workspace = true+windows.workspace = truediff --git a/poc-d3d/src/app.rs b/crates/poc-d3d/src/app.rssimilarity index 98%rename from poc-d3d/src/app.rsrename to crates/poc-d3d/src/app.rsindex b10f0952f..6c49b7d2b 100644--- a/poc-d3d/src/app.rs+++ b/crates/poc-d3d/src/app.rs@@ -10,12 +10,12 @@//! - un modèle mono-thread coopératif : WM_TIMER cadence la playback à 60 fps ;//! l'export tourne sur le thread UI et rafraîchit la barre entre frames.-use crate::compositor::{Compositor, FIXTURE_FRAMES, OUT_H, OUT_W};-use crate::config::{self, Cfg};-use crate::cursor::CursorTrack;-use crate::d3d::Gpu;-use crate::live::Player;-use crate::pipeline;+use openscreen_compositor::compositor::{Compositor, FIXTURE_FRAMES, OUT_H, OUT_W};+use openscreen_compositor::config::{self, Cfg};+use openscreen_compositor::cursor::CursorTrack;+use openscreen_compositor::d3d::Gpu;+use openscreen_compositor::live::Player;+use openscreen_compositor::pipeline;use anyhow::Result;use std::ffi::c_void;use std::time::Instant;diff --git a/poc-d3d/src/lib.rs b/crates/poc-d3d/src/bench.rssimilarity index 91%rename from poc-d3d/src/lib.rsrename to crates/poc-d3d/src/bench.rsindex 7946eb0ad..23769136a 100644--- a/poc-d3d/src/lib.rs+++ b/crates/poc-d3d/src/bench.rs@@ -1,23 +1,11 @@-//! `poc-d3d` en bibliothèque : le compositeur/pipeline/d3d mesurés (S2→S6) + la vue-//! live embarquable (`live`) sont réutilisables par l'addon napi-rs de l'intégration-//! Electron. Le binaire (`main.rs`) n'est qu'un mince consommateur (`run()`).--pub mod app;-pub mod audio;-pub mod compositor;-pub mod config;-pub mod cursor;-pub mod d3d;-pub mod ffi;-pub mod live;-pub mod pipeline;-pub mod regions;-pub mod scene;-pub mod text;-pub mod text_anim;+//! Harnais de mesure du POC (§9/§10) et aiguillage des modes.+//!+//! Vivait dans `lib.rs` de l'ancienne crate `poc-d3d`, quand bibliothèque et POC étaient le même+//! paquet. Rien ici n'est packagé : c'est du banc de mesure au-dessus d'`openscreen-compositor`.use anyhow::{Context as _, Result};-use compositor::Compositor;+use openscreen_compositor::compositor::Compositor;+use openscreen_compositor::{config, cursor, d3d, live, pipeline, scene};use std::fmt::Write as _;fn arg(args: &[String], k: &str, d: &str) -> String {@@ -44,7 +32,7 @@ pub fn run() -> Result<()> {} else {let fixture = arg(&args, "--fixture", "fixture");let out = arg(&args, "--out", "out");- app::run_gui(+ crate::app::run_gui(&format!("{fixture}/screen.mp4"),&format!("{fixture}/webcam.mp4"),&format!("{fixture}/screen.cursor.json"),diff --git a/crates/poc-d3d/src/main.rs b/crates/poc-d3d/src/main.rsnew file mode 100644index 000000000..6a8a43f16--- /dev/null+++ b/crates/poc-d3d/src/main.rs@@ -0,0 +1,9 @@+//! Binaire du POC de mesure : GUI Win32 de preview/export, harnais de bench fps, mode live.+//! Tout le rendu vient d'`openscreen-compositor` — ce crate ne fait que le piloter et le mesurer.++mod app;+mod bench;++fn main() -> anyhow::Result<()> {+ bench::run()+}diff --git a/poc-d3d/x.bat b/crates/x.batsimilarity index 100%rename from poc-d3d/x.batrename to crates/x.batdiff --git a/electron-builder.json5 b/electron-builder.json5index 1a2f8d9d4..f571e1ab5 100644--- a/electron-builder.json5+++ b/electron-builder.json5@@ -10,6 +10,11 @@"**/*.node"],"productName": "Openscreen",+ // Fails the build when compositor_view.node is older than the crates/ Rust sources. Plain+ // `npm run build` does not rebuild the addon, and a stale one fails SILENTLY at runtime+ // (unknown scene fields are #[serde(default)]) rather than erroring. See the script header+ // and technical-documentation/engineering/build-and-packaging.md.+ "beforePack": "scripts/before-pack.cjs","npmRebuild": true,// sharp ships ABI-stable (napi) prebuilt binaries with bundled libvips. Building it from source// needs a system libvips we don't provide and breaks on CI/local ("vips-cpp.42 not found"), so wediff --git a/electron/native-bridge/services/compositorViewService.test.ts b/electron/native-bridge/services/compositorViewService.test.tsindex 84c731d81..297d3f5ef 100644--- a/electron/native-bridge/services/compositorViewService.test.ts+++ b/electron/native-bridge/services/compositorViewService.test.ts@@ -9,9 +9,9 @@ import {resolveSceneAssetPaths,} from "./compositorViewService";-/** A source checkout's `poc-d3d/.cargo/config.toml`, with `FFMPEG_DIR` written as `body`. */+/** A source checkout's `crates/.cargo/config.toml`, with `FFMPEG_DIR` written as `body`. */function writeCargoConfig(root: string, body: string): void {- const cargoDir = path.join(root, "poc-d3d", ".cargo");+ const cargoDir = path.join(root, "crates", ".cargo");fs.mkdirSync(cargoDir, { recursive: true });fs.writeFileSync(path.join(cargoDir, "config.toml"),@@ -42,7 +42,7 @@ describe("ffmpegSharedBinCandidates", () => {const candidates = ffmpegSharedBinCandidates(tmpRoot).map((p) => p.replace(/\\/g, "/"));expect(candidates[0]).toBe(- `${tmpRoot.replace(/\\/g, "/")}/poc-d3d/thirdparty/ffmpeg-n9.9.9-win64-lgpl-shared/bin`,+ `${tmpRoot.replace(/\\/g, "/")}/crates/thirdparty/ffmpeg-n9.9.9-win64-lgpl-shared/bin`,);expect(candidates[1]).toMatch(/electron\/native\/bin\/(win32|darwin|linux)-(x64|arm64)$/);});@@ -51,9 +51,7 @@ describe("ffmpegSharedBinCandidates", () => {writeCargoConfig(tmpRoot, `FFMPEG_DIR = "thirdparty/ffmpeg-plain"`);const candidates = ffmpegSharedBinCandidates(tmpRoot).map((p) => p.replace(/\\/g, "/"));- expect(candidates[0]).toBe(- `${tmpRoot.replace(/\\/g, "/")}/poc-d3d/thirdparty/ffmpeg-plain/bin`,- );+ expect(candidates[0]).toBe(`${tmpRoot.replace(/\\/g, "/")}/crates/thirdparty/ffmpeg-plain/bin`);});it("keeps an absolute pin absolute rather than nesting it under the crate dir", () => {@@ -65,23 +63,23 @@ describe("ffmpegSharedBinCandidates", () => {const candidates = ffmpegSharedBinCandidates(tmpRoot).map((p) => p.replace(/\\/g, "/"));expect(candidates[0]).toBe(`${absolutePin}/bin`);- expect(candidates[0]).not.toContain("poc-d3d");+ expect(candidates[0]).not.toContain("crates");});it("starts at the arch-tagged native bin dir when there is no cargo pin to read", () => {- // Packaged builds ship no `poc-d3d/` at all — the dev candidate must drop+ // Packaged builds ship no `crates/` at all — the dev candidate must drop// out silently rather than contribute a path that can never exist.const candidates = ffmpegSharedBinCandidates(tmpRoot).map((p) => p.replace(/\\/g, "/"));expect(candidates[0]).toMatch(/electron\/native\/bin\/(win32|darwin|linux)-(x64|arm64)$/);- expect(candidates.some((c) => c.includes("poc-d3d"))).toBe(false);+ expect(candidates.some((c) => c.includes("crates"))).toBe(false);});it("ignores a cargo config that pins no FFMPEG_DIR", () => {writeCargoConfig(tmpRoot, `SOME_OTHER_VAR = "thirdparty/nope"`);const candidates = ffmpegSharedBinCandidates(tmpRoot).map((p) => p.replace(/\\/g, "/"));- expect(candidates.some((c) => c.includes("poc-d3d"))).toBe(false);+ expect(candidates.some((c) => c.includes("crates"))).toBe(false);});it("also probes process.resourcesPath, since electron/native/bin ships only via extraResources in packaged builds", () => {@@ -128,7 +126,7 @@ describe("CompositorViewService ffmpeg PATH prepend", () => {root,`FFMPEG_DIR = { value = "thirdparty/ffmpeg-n8.1.2-win64-lgpl-shared", relative = true }`,);- const dir = path.join(root, "poc-d3d", "thirdparty", "ffmpeg-n8.1.2-win64-lgpl-shared", "bin");+ const dir = path.join(root, "crates", "thirdparty", "ffmpeg-n8.1.2-win64-lgpl-shared", "bin");fs.mkdirSync(dir, { recursive: true });return dir;}diff --git a/electron/native-bridge/services/compositorViewService.ts b/electron/native-bridge/services/compositorViewService.tsindex de2edff11..17d9b4cfa 100644--- a/electron/native-bridge/services/compositorViewService.ts+++ b/electron/native-bridge/services/compositorViewService.ts@@ -217,7 +217,7 @@ function buildCandidatePaths(/*** The dev-vendored ffmpeg tree, read from the pin that already exists rather- * than named a second time here: `poc-d3d/.cargo/config.toml`'s `FFMPEG_DIR`.+ * than named a second time here: `crates/.cargo/config.toml`'s `FFMPEG_DIR`.** That pin is the one thing the addon is actually built against (see the* config's own comment), so the DLL basenames it imports — `avcodec-62.dll` and@@ -229,10 +229,10 @@ function buildCandidatePaths(* what makes the rot worth removing rather than tolerating.** Returns null when there is no config to read: packaged builds ship no- * `poc-d3d/` at all, and the candidate list simply starts one entry later.+ * `crates/` at all, and the candidate list simply starts one entry later.*/function pinnedFfmpegDir(appRoot: string): string | null {- const crateDir = path.join(appRoot, "poc-d3d");+ const crateDir = path.join(appRoot, "crates");let toml: string;try {toml = fs.readFileSync(path.join(crateDir, ".cargo", "config.toml"), "utf8");diff --git a/poc-d3d/Cargo.toml b/poc-d3d/Cargo.tomldeleted file mode 100644index a1d97d83a..000000000--- a/poc-d3d/Cargo.toml+++ /dev/null@@ -1,60 +0,0 @@-[package]-name = "poc-d3d"-version = "0.0.0"-edition = "2021"-description = "POC OpenScreen : compositeur natif D3D11 zéro-copie, effets HLSL, mesuré en fps (fast-path natif)."--# Workspace : l'addon napi-rs (compositor-view-napi) partage le build env (FFMPEG_DIR,-# LIBCLANG_PATH via .cargo/config.toml). `default-members = ["."]` → `cargo build` (x.bat)-# ne construit que le POC ; l'addon se build explicitement (`cargo build -p compositor-view-napi`).-[workspace]-members = ["compositor-view-napi"]-default-members = ["."]--[lib]-name = "poc_d3d"-path = "src/lib.rs"--[[bin]]-name = "poc-d3d"-path = "src/main.rs"--[profile.release]-opt-level = 3-lto = true-debug = false-# §10 : debug_assertions OFF dans tout run mesuré-overflow-checks = false--[build-dependencies]-bindgen = "0.70"-cc = "1"--[dependencies]-anyhow = "1"-serde = { version = "1", features = ["derive"] }-serde_json = "1"-# Décodage des wallpapers image (jpg/png) pour le fond natif. default-features off →-# on ne tire que les décodeurs nécessaires (build plus léger).-image = { version = "0.25", default-features = false, features = ["jpeg", "png"] }--[dependencies.windows]-version = "0.58"-features = [- "Win32_Foundation",- "Win32_Graphics_Direct3D",- "Win32_Graphics_Direct3D_Fxc", # D3DCompile (HLSL runtime)- "Win32_Graphics_Direct3D11",- "Win32_Graphics_Dxgi",- "Win32_Graphics_Dxgi_Common",- "Foundation_Numerics", # requis par les méthodes D2D à brosse (CreateSolidColorBrush)- "Win32_Graphics_Direct2D", # cible de rendu D2D sur surface DXGI (texte, text.rs)- "Win32_Graphics_Direct2D_Common", # D2D1_COLOR_F / PIXEL_FORMAT- "Win32_Graphics_DirectWrite", # mise en page + rastérisation du texte- "Win32_Graphics_Gdi", # brosses/police GUI de la preview (app.rs)- "Win32_System_Performance", # QueryPerformanceCounter / Frequency (§10)- "Win32_System_LibraryLoader", # GetModuleHandleW (hInstance, app.rs)- "Win32_UI_WindowsAndMessaging", # fenêtre + contrôles natifs (app.rs)- "Win32_UI_Controls", # barre de progression (app.rs)- "Win32_UI_Input_KeyboardAndMouse", # EnableWindow (app.rs)-]diff --git a/poc-d3d/src/main.rs b/poc-d3d/src/main.rsdeleted file mode 100644index e397eaf46..000000000--- a/poc-d3d/src/main.rs+++ /dev/null@@ -1,6 +0,0 @@-//! Binaire mince : toute la logique vit dans la bibliothèque `poc_d3d`-//! (réutilisable par l'addon napi-rs de l'intégration Electron).--fn main() -> anyhow::Result<()> {- poc_d3d::run()-}diff --git a/scripts/before-pack.cjs b/scripts/before-pack.cjsnew file mode 100644index 000000000..e64ba780e--- /dev/null+++ b/scripts/before-pack.cjs@@ -0,0 +1,103 @@+// electron-builder beforePack hook: refuse to package a compositor addon that is older than its+// Rust sources.+//+// `compositor_view.node` is an untracked build artifact, and plain `npm run build` does NOT rebuild+// it (only `build:win` runs `build:native:compositor`). So a bare `npm run build` — or a fresh+// worktree that inherited a copy from the main checkout — happily ships a `.node` built from+// whatever the sources looked like days ago.+//+// That failure is silent, which is what makes it worth a hard error. Scene fields the app sends are+// `#[serde(default)]` on the Rust side, so an addon predating a contract change does not reject the+// payload: it ignores the unknown key, takes the default, and falls back to older art. The feature+// simply does nothing, with no error in any log — it reads exactly like a bug in the TypeScript, and+// it has already cost one full false-trail investigation (custom cursor themes, 2026-07-27, where+// the shipped addon was 3 days older than the commit adding `cursorSprites`).+//+// ponytail: mtime comparison, not content hashing. A `git checkout` restamps source mtimes, so this+// can fire when the addon is actually fine. That trade is deliberate — the false positive costs one+// rebuild, the false negative ships a broken installer. Switch to hashing the sources into a stamp+// file next to the `.node` if branch-switching makes the noise annoying.++const fs = require("node:fs");+const path = require("node:path");++const ROOT = path.join(__dirname, "..");+const ADDON = path.join(ROOT, "electron/native/compositor-view/build/compositor_view.node");++// Everything the addon is compiled from. shaders.hlsl lives under src/, so it is covered.+// crates/poc-d3d/ is deliberately absent: nothing links it, so editing the POC cannot+// invalidate the shipped addon.+const SOURCE_PATHS = [+ "crates/compositor/src",+ "crates/compositor-view-napi/src",+ "crates/Cargo.toml",+ "crates/compositor/Cargo.toml",+ "crates/compositor-view-napi/Cargo.toml",+].map((p) => path.join(ROOT, p));++const FIX =+ "Rebuild it with:\n\n npm run build:native:compositor\n\nor use `npm run build:win`, which does that for you.";++/** Newest mtime under `target` (file or directory), or 0 if it does not exist. */+function newestMtimeMs(target) {+ let stat;+ try {+ stat = fs.statSync(target);+ } catch {+ return 0;+ }+ if (!stat.isDirectory()) {+ return stat.mtimeMs;+ }+ let newest = 0;+ for (const entry of fs.readdirSync(target, { withFileTypes: true })) {+ newest = Math.max(newest, newestMtimeMs(path.join(target, entry.name)));+ }+ return newest;+}++function checkCompositorAddonFreshness() {+ if (!fs.existsSync(ADDON)) {+ throw new Error(+ `Refusing to package: the D3D11 compositor addon is missing.\n\n expected: ${ADDON}\n\n${FIX}`,+ );+ }++ const addonMs = fs.statSync(ADDON).mtimeMs;+ const stale = SOURCE_PATHS.map((source) => ({ source, ms: newestMtimeMs(source) })).filter(+ (entry) => entry.ms > addonMs,+ );+ if (stale.length === 0) {+ return;+ }++ const newest = stale.reduce((a, b) => (a.ms > b.ms ? a : b));+ throw new Error(+ "Refusing to package a stale D3D11 compositor addon.\n\n" ++ ` addon built: ${new Date(addonMs).toISOString()}\n` ++ ` newer source: ${path.relative(ROOT, newest.source)} (${new Date(newest.ms).toISOString()})\n\n` ++ "Packaging this would silently ship an addon that ignores newer scene fields\n" ++ "(they are #[serde(default)], so it falls back instead of erroring).\n\n" ++ FIX,+ );+}++exports.default = async function beforePack(context) {+ // The compositor addon is Windows-only; skip when packing any other target.+ const platform = context?.electronPlatformName ?? process.platform;+ if (platform !== "win32") {+ return;+ }+ checkCompositorAddonFreshness();+};++// Runnable on its own for debugging: `node scripts/before-pack.cjs`+if (require.main === module) {+ try {+ checkCompositorAddonFreshness();+ console.log("compositor addon is up to date with its Rust sources.");+ } catch (err) {+ console.error(err.message);+ process.exit(1);+ }+}diff --git a/scripts/build-windows-compositor-addon.mjs b/scripts/build-windows-compositor-addon.mjsindex df2aee283..14f953d69 100644--- a/scripts/build-windows-compositor-addon.mjs+++ b/scripts/build-windows-compositor-addon.mjs@@ -1,19 +1,19 @@-// Builds the native D3D11 compositor addon (poc-d3d/compositor-view-napi) and+// Builds the native D3D11 compositor addon (crates/compositor-view-napi) and// vendors it to electron/native/compositor-view/build/compositor_view.node,// the path compositorViewService.ts's candidate list resolves at runtime.//// Mirrors build-windows-wgc-helper.mjs's MSVC-environment discovery (vcvarsall-// sweep), but drives `cargo build` instead of CMake/Ninja — poc-d3d is a Rust-// workspace. FFMPEG_DIR and LIBCLANG_PATH come from poc-d3d/.cargo/config.toml-// (portable, relative to poc-d3d/), not from this script: cargo picks those up-// automatically because the build runs with cwd = poc-d3d/.+// sweep), but drives `cargo build` instead of CMake/Ninja — crates/ is a Rust+// workspace. FFMPEG_DIR and LIBCLANG_PATH come from crates/.cargo/config.toml+// (portable, relative to crates/), not from this script: cargo picks those up+// automatically because the build runs with cwd = crates/.//// The addon links against ffmpeg's shared DLLs (avcodec/avformat/avutil/…),// so it MUST be built against the same pinned ffmpeg release that// fetch-ffmpeg.mjs vendors into electron/native/bin/<tag>/ — otherwise the// DLL filenames the addon imports (avcodec-NN.dll etc.) won't match what's// shipped, and require() fails at runtime even with the right dir on PATH.-// See poc-d3d/.cargo/config.toml for the pin.+// See crates/.cargo/config.toml for the pin.import fs from "node:fs";import path from "node:path";@@ -22,13 +22,13 @@ import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";const __dirname = path.dirname(fileURLToPath(import.meta.url));const ROOT = path.join(__dirname, "..");-const POC_D3D_DIR = path.join(ROOT, "poc-d3d");+const CRATES_DIR = path.join(ROOT, "crates");const BUILD_OUT_DIR = path.join(ROOT, "electron", "native", "compositor-view", "build");-// cwd defaults to poc-d3d/, not ROOT: cargo reads FFMPEG_DIR and LIBCLANG_PATH-// from poc-d3d/.cargo/config.toml, which only applies when it runs from there.+// cwd defaults to crates/, not ROOT: cargo reads FFMPEG_DIR and LIBCLANG_PATH+// from crates/.cargo/config.toml, which only applies when it runs from there.const run = (command, args, options = {}) =>- spawnStep(command, args, { cwd: POC_D3D_DIR, ...options });+ spawnStep(command, args, { cwd: CRATES_DIR, ...options });async function runInVsEnv(command) {const vcvarsAll = findVcVarsAll();@@ -59,7 +59,7 @@ async function runInVsEnv(command) {].join("\r\n"),);try {- await run("cmd.exe", ["/d", "/c", cmdPath], { cwd: POC_D3D_DIR });+ await run("cmd.exe", ["/d", "/c", cmdPath], { cwd: CRATES_DIR });} finally {fs.rmSync(path.dirname(cmdPath), { recursive: true, force: true });}@@ -70,15 +70,15 @@ if (process.platform !== "win32") {process.exit(0);}-const ffmpegDir = fs.readFileSync(path.join(POC_D3D_DIR, ".cargo", "config.toml"), "utf8");+const ffmpegDir = fs.readFileSync(path.join(CRATES_DIR, ".cargo", "config.toml"), "utf8");const pinMatch = ffmpegDir.match(/value = "([^"]+)"/);if (pinMatch) {- const pinnedDir = path.join(POC_D3D_DIR, pinMatch[1]);+ const pinnedDir = path.join(CRATES_DIR, pinMatch[1]);if (!fs.existsSync(pinnedDir)) {throw new Error(- `FFMPEG_DIR pin (poc-d3d/.cargo/config.toml) points at ${pinnedDir}, which doesn't exist.\n` ++ `FFMPEG_DIR pin (crates/.cargo/config.toml) points at ${pinnedDir}, which doesn't exist.\n` +"Vendor the pinned ffmpeg shared SDK there before building the compositor addon " +- "(see poc-d3d/.cargo/config.toml for the pinned release).",+ "(see crates/.cargo/config.toml for the pinned release).",);}}@@ -86,7 +86,7 @@ if (pinMatch) {const cargoExeQuoted = `"%USERPROFILE%\\.cargo\\bin\\cargo.exe"`;await runInVsEnv(`${cargoExeQuoted} build -p compositor-view-napi --release`);-const builtDll = path.join(POC_D3D_DIR, "target", "release", "compositor_view.dll");+const builtDll = path.join(CRATES_DIR, "target", "release", "compositor_view.dll");if (!fs.existsSync(builtDll)) {throw new Error(`Compositor addon build completed but ${builtDll} was not found.`);}diff --git a/scripts/fetch-ffmpeg.mjs b/scripts/fetch-ffmpeg.mjsindex 1f438242d..be75a858d 100644--- a/scripts/fetch-ffmpeg.mjs+++ b/scripts/fetch-ffmpeg.mjs@@ -8,7 +8,7 @@// gap is Chromium's per-frame overhead, not the silicon.//// SECOND PURPOSE (Windows only): the native D3D11 compositor addon-// (poc-d3d/compositor-view-napi) *dynamically links* against ffmpeg's shared+// (crates/compositor-view-napi) *dynamically links* against ffmpeg's shared// libraries (avcodec/avformat/avutil/…) at `require()` time — a completely// different artifact from the static `ffmpeg.exe` above (BtbN's "-shared"// build variant vs. its default static one). Without those DLLs reachable ondiff --git a/technical-documentation/architecture/cursor.md b/technical-documentation/architecture/cursor.mdindex 55c5e577e..831215841 100644--- a/technical-documentation/architecture/cursor.md+++ b/technical-documentation/architecture/cursor.md@@ -8,11 +8,11 @@ Native capture keeps cursor data separate from the video frame. On Windows, the## Telemetry-Position telemetry is represented by `CursorTelemetryPoint` in `src/lib/cursorTelemetryBuffer.ts`. Each point contains `timeMs`, the offset from recording start, and `cx`/`cy`, clamped ratios of the captured surface (`cursorTelemetryBuffer.ts:1-10`). The main-process `CursorTelemetryBuffer` starts a session with a recording id, appends samples, and finalizes them into FIFO batches keyed by that id (`cursorTelemetryBuffer.ts:25-34`). This key keeps asynchronous persistence and discard operations associated with the correct recording. Native cursor samples use the same recording-time convention, and `poc-d3d/src/cursor.rs:100-123` loads a selected window by subtracting its offset so the first sample is at time zero.+Position telemetry is represented by `CursorTelemetryPoint` in `src/lib/cursorTelemetryBuffer.ts`. Each point contains `timeMs`, the offset from recording start, and `cx`/`cy`, clamped ratios of the captured surface (`cursorTelemetryBuffer.ts:1-10`). The main-process `CursorTelemetryBuffer` starts a session with a recording id, appends samples, and finalizes them into FIFO batches keyed by that id (`cursorTelemetryBuffer.ts:25-34`). This key keeps asynchronous persistence and discard operations associated with the correct recording. Native cursor samples use the same recording-time convention, and `crates/compositor/src/cursor.rs:100-123` loads a selected window by subtracting its offset so the first sample is at time zero.## Rendering-`CursorPreviewLayer` is mounted above the video and loads both native recording data and telemetry through `useCursorRecordingData` and `useCursorTelemetry` (`src/components/ai-edition/CursorPreviewLayer.tsx:42-50`). Its animation loop updates the Pixi telemetry overlay and the native-cursor DOM image from the current playback time (`CursorPreviewLayer.tsx:187-255`). The shared cursor library supplies path smoothing, native asset selection, click bounce, and directional motion blur. The native compositor in `poc-d3d/src/cursor.rs` interpolates raw samples, applies the same 240 Hz spring-style smoothing, and computes click-bounce timing (`cursor.rs:126-196`). Preview and export therefore consume the same telemetry and cursor rules rather than maintaining independent cursor tracks.+`CursorPreviewLayer` is mounted above the video and loads both native recording data and telemetry through `useCursorRecordingData` and `useCursorTelemetry` (`src/components/ai-edition/CursorPreviewLayer.tsx:42-50`). Its animation loop updates the Pixi telemetry overlay and the native-cursor DOM image from the current playback time (`CursorPreviewLayer.tsx:187-255`). The shared cursor library supplies path smoothing, native asset selection, click bounce, and directional motion blur. The native compositor in `crates/compositor/src/cursor.rs` interpolates raw samples, applies the same 240 Hz spring-style smoothing, and computes click-bounce timing (`cursor.rs:126-196`). Preview and export therefore consume the same telemetry and cursor rules rather than maintaining independent cursor tracks.```mermaidflowchart LR@@ -27,7 +27,7 @@ The cursor settings pane is `CursorPane` in `src/components/ai-edition/RightPane## Auto-follow-Cursor telemetry also drives camera focus for auto-follow zooms. `src/components/video-editor/videoPlayback/cursorFollowUtils.ts` interpolates the cursor at content time and applies distance-adaptive, frame-rate-independent smoothing. The zoom-region utilities use that focus for preview, while the export frame renderer uses the corresponding focus during export. The native compositor keeps a raw track for cursor placement and derives a separately smoothed follow track (`poc-d3d/src/cursor.rs:16-24,126-136`), preventing camera motion from changing the cursor's actual recorded position.+Cursor telemetry also drives camera focus for auto-follow zooms. `src/components/video-editor/videoPlayback/cursorFollowUtils.ts` interpolates the cursor at content time and applies distance-adaptive, frame-rate-independent smoothing. The zoom-region utilities use that focus for preview, while the export frame renderer uses the corresponding focus during export. The native compositor keeps a raw track for cursor placement and derives a separately smoothed follow track (`crates/compositor/src/cursor.rs:16-24,126-136`), preventing camera motion from changing the cursor's actual recorded position.## Bundled assetsdiff --git a/technical-documentation/architecture/export-pipeline.md b/technical-documentation/architecture/export-pipeline.mdindex c2606ccf8..e8e0b2067 100644--- a/technical-documentation/architecture/export-pipeline.md+++ b/technical-documentation/architecture/export-pipeline.md@@ -5,7 +5,7 @@ live preview ([preview.md](preview.md) /[native-compositor.md](native-compositor.md)), one segment at a time. TheElectron renderer turns the project document into the same `SceneDescription`the live preview uses plus an ordered clip list, hands both to the napi addon-through the `compositor` IPC domain, and the addon drives `poc-d3d`'s+through the `compositor` IPC domain, and the addon drives `openscreen-compositor`'s`Player` + `Compositor::compose_frame` + AMF encoder + muxer to write one`.mp4`. The renderer only watches progress; the actual rendering does notleave the native process. Performance numbers, the bench, and the rejected@@ -22,7 +22,7 @@ flowchart LRTSD["src/native/sceneDescription.ts<br/>resolveVisibleClips / buildSceneDescription"]RP["clips + SceneDescription JSON<br/>layout + effects + background + zoom + cursor + webcam"]ADDON["compositor_view.node addon<br/>exportMulti (Electron IPC)"]- NATIVE["poc-d3d::live::Player<br/>Compositor::compose_frame<br/>h264_amf encoder + mux"]+ NATIVE["openscreen_compositor::live::Player<br/>Compositor::compose_frame<br/>h264_amf encoder + mux"]FILE["output.mp4"]DOC --> TSD --> RP --> ADDON --> NATIVE --> FILE```@@ -35,12 +35,12 @@ through `compositorViewService.exportMulti`The service resolves the same asset paths the renderer used (wallpaperimages, cursor theme sprite) and forwards the call to the addon([`compositorViewService.ts:437`](../../electron/native-bridge/services/compositorViewService.ts)).-The addon loads `poc-d3d`'s `Player` with the clip list and the shared+The addon loads `openscreen-compositor`'s `Player` with the clip list and the shared`SceneDescription` JSON, then walks the segments with **one** compositorand **one** encoder + muxer pair:- Per segment: load metadata, hand the asset to the `Player` (so screen- and webcam decode land on `poc-d3d`'s shared `ID3D11Device`), drive+ and webcam decode land on `openscreen-compositor`'s shared `ID3D11Device`), drive`compose_frame` at the segment's source time, and let the AMF encoderconsume the rendered RT. The compositor is paused on the live previewfor the duration of the export (`set_playing(false)` on every activediff --git a/technical-documentation/architecture/native-compositor.md b/technical-documentation/architecture/native-compositor.mdindex f2fd00e62..83802f37d 100644--- a/technical-documentation/architecture/native-compositor.md+++ b/technical-documentation/architecture/native-compositor.md@@ -1,6 +1,6 @@# Native compositor-`poc-d3d/` is the Rust + Direct3D 11 crate behind both the live preview and the MP4+`crates/compositor/` is the Rust + Direct3D 11 crate behind both the live preview and the MP4export. It exposes its compositor and pipeline to Electron through a smallnapi-rs addon (`compositor-view-napi/`) loaded by[`compositorViewService`](../../electron/native-bridge/services/compositorViewService.ts).@@ -11,7 +11,7 @@ zero CPU readback between stages — and is shared, with the same scene contractnumbers and the rejected alternatives that drove the design live in[engineering/rendering-performance.md](../engineering/rendering-performance.md).-A single `ID3D11Device` ([`poc-d3d/src/d3d.rs`](../../poc-d3d/src/d3d.rs))+A single `ID3D11Device` ([`crates/compositor/src/d3d.rs`](../../crates/compositor/src/d3d.rs))is shared by every consumer on the path: the ffmpeg `D3D11VA` decoder, the HLSLcompositor, the `h264_amf` encoder, and the live swapchain. It is created withfeature level **11_1**, the flags `VIDEO_SUPPORT | BGRA_SUPPORT` (`VIDEO_SUPPORT`@@ -24,54 +24,61 @@ and without that flag the runtime corruption is silent.| source | responsibility ||---|---|-| [`poc-d3d/src/lib.rs`](../../poc-d3d/src/lib.rs) | crate root: exposes `run()` (CLI / bench / GUI dispatcher), re-exports every module |-| [`poc-d3d/src/d3d.rs`](../../poc-d3d/src/d3d.rs) | the single `ID3D11Device` (feature level 11_1, `VIDEO_SUPPORT`, multithread-protected) |-| [`poc-d3d/src/ffi.rs`](../../poc-d3d/src/ffi.rs) | bindgen-generated `libav*` bindings (ffmpeg 8.x headers) |-| [`poc-d3d/src/compositor.rs`](../../poc-d3d/src/compositor.rs) | HLSL compositor — every per-frame pass (`compose_frame`, background, screen, webcam, cursor, annotations, shadows, blur) |-| [`poc-d3d/src/scene.rs`](../../poc-d3d/src/scene.rs) | the `Scene` struct parsed from the app's `SceneDescription` JSON |-| [`poc-d3d/src/regions.rs`](../../poc-d3d/src/regions.rs) | zoom / speed / Full Camera regions — envelope shapes and per-frame state sampling |-| [`poc-d3d/src/pipeline.rs`](../../poc-d3d/src/pipeline.rs) | demux + `D3D11VA` decode + composite + AMF encode + mux (`run_c0` for decode/encode only, `run_composited` for the full path) |-| [`poc-d3d/src/audio.rs`](../../poc-d3d/src/audio.rs) | per-clip audio decode, swresample → f32 planar 48 kHz stereo, WSOLA speed stretch, multi-track mix, AAC encoder |-| [`poc-d3d/src/cursor.rs`](../../poc-d3d/src/cursor.rs) | `.cursor.json` parser + interpolated cursor track (position, click bounces, adaptive follow samples) |-| [`poc-d3d/src/text.rs`](../../poc-d3d/src/text.rs) | DirectWrite + Direct2D text rasterisation for annotation labels, cached per (content, style, box) |-| [`poc-d3d/src/text_anim.rs`](../../poc-d3d/src/text_anim.rs) | text-annotation appearance animations (port of the TS animation curves, in fractions of the output short side) |-| [`poc-d3d/src/config.rs`](../../poc-d3d/src/config.rs) | cumulative bench configs C0..C8 (each adds one layer: composite, rounded corners, shadow, background blur, zoom, layout animation, cursor, motion blur) |-| [`poc-d3d/src/live.rs`](../../poc-d3d/src/live.rs) | off-screen view: `Player` + `Compositor::compose_frame` → RGBA8 staging texture, pulled by the napi addon |-| [`poc-d3d/src/app.rs`](../../poc-d3d/src/app.rs) | standalone Win32 GUI (combo preset, Play/Pause, Export, progress bar) — wraps the measured pipeline for interactive demo |-| [`poc-d3d/src/main.rs`](../../poc-d3d/src/main.rs) | thin `main` that calls `lib::run()` |-| [`poc-d3d/src/shaders.hlsl`](../../poc-d3d/src/shaders.hlsl) | all GPU effects (modes 0/1/5/8/9/10/12 — see pipeline below), compiled at runtime via Fxc |+| [`crates/compositor/src/lib.rs`](../../crates/compositor/src/lib.rs) | crate root: declares every module below. Nothing else — the CLI/bench/GUI dispatcher it used to hold lives in the POC crate now |+| [`crates/compositor/src/d3d.rs`](../../crates/compositor/src/d3d.rs) | the single `ID3D11Device` (feature level 11_1, `VIDEO_SUPPORT`, multithread-protected) |+| [`crates/compositor/src/ffi.rs`](../../crates/compositor/src/ffi.rs) | bindgen-generated `libav*` bindings (ffmpeg 8.x headers) |+| [`crates/compositor/src/compositor.rs`](../../crates/compositor/src/compositor.rs) | HLSL compositor — every per-frame pass (`compose_frame`, background, screen, webcam, cursor, annotations, shadows, blur) |+| [`crates/compositor/src/scene.rs`](../../crates/compositor/src/scene.rs) | the `Scene` struct parsed from the app's `SceneDescription` JSON |+| [`crates/compositor/src/regions.rs`](../../crates/compositor/src/regions.rs) | zoom / speed / Full Camera regions — envelope shapes and per-frame state sampling |+| [`crates/compositor/src/pipeline.rs`](../../crates/compositor/src/pipeline.rs) | demux + `D3D11VA` decode + composite + AMF encode + mux (`run_c0` for decode/encode only, `run_composited` for the full path) |+| [`crates/compositor/src/audio.rs`](../../crates/compositor/src/audio.rs) | per-clip audio decode, swresample → f32 planar 48 kHz stereo, WSOLA speed stretch, multi-track mix, AAC encoder |+| [`crates/compositor/src/cursor.rs`](../../crates/compositor/src/cursor.rs) | `.cursor.json` parser + interpolated cursor track (position, click bounces, adaptive follow samples) |+| [`crates/compositor/src/text.rs`](../../crates/compositor/src/text.rs) | DirectWrite + Direct2D text rasterisation for annotation labels, cached per (content, style, box) |+| [`crates/compositor/src/text_anim.rs`](../../crates/compositor/src/text_anim.rs) | text-annotation appearance animations (port of the TS animation curves, in fractions of the output short side) |+| [`crates/compositor/src/config.rs`](../../crates/compositor/src/config.rs) | cumulative bench configs C0..C8 (each adds one layer: composite, rounded corners, shadow, background blur, zoom, layout animation, cursor, motion blur) |+| [`crates/compositor/src/live.rs`](../../crates/compositor/src/live.rs) | off-screen view: `Player` + `Compositor::compose_frame` → RGBA8 staging texture, pulled by the napi addon |+| [`crates/compositor/src/shaders.hlsl`](../../crates/compositor/src/shaders.hlsl) | all GPU effects (modes 0/1/5/8/9/10/12 — see pipeline below), compiled at runtime via Fxc |++Two more modules sit in the POC crate ([`crates/poc-d3d/`](../../crates/poc-d3d)) rather than the+library. Nothing packages them — they drive the library for measurement and eyeballing:++| source | responsibility |+|---|---|+| [`crates/poc-d3d/src/app.rs`](../../crates/poc-d3d/src/app.rs) | standalone Win32 GUI (combo preset, Play/Pause, Export, progress bar) — wraps the measured pipeline for interactive demo |+| [`crates/poc-d3d/src/bench.rs`](../../crates/poc-d3d/src/bench.rs) | mode dispatcher (`--live` / `--cfg` bench / GUI) and the C0..C8 fps harness |+| [`crates/poc-d3d/src/main.rs`](../../crates/poc-d3d/src/main.rs) | thin `main` that calls `bench::run()` |## The compositing pipelineEvery visible frame is rasterised into one RGBA render target(`OUT_W × OUT_H = 1920×1080`, then optionally bilinearly resized to the realoutput aspect). `Compositor::compose_frame`-([`poc-d3d/src/compositor.rs:1421`](../../poc-d3d/src/compositor.rs))+([`crates/compositor/src/compositor.rs:1421`](../../crates/compositor/src/compositor.rs))runs one fixed draw order — derived from the per-frame math it performs, notfrom any list the caller can reorder — and `shaders.hlsl` keys each effect offthe `mode` field of the same `LayerCB` struct, so the modes below are exactlywhat `shaders.hlsl` actually implements:1. **Background** (the wallpaper). `mode = 1` for a solid colour- ([`compositor.rs:1761`](../../poc-d3d/src/compositor.rs)),+ ([`compositor.rs:1761`](../../crates/compositor/src/compositor.rs)),`mode = 5` for a CSS gradient- ([`compositor.rs:1765`](../../poc-d3d/src/compositor.rs)), or a cover-fitted+ ([`compositor.rs:1765`](../../crates/compositor/src/compositor.rs)), or a cover-fittedimage loaded through `draw_image_bg`- ([`compositor.rs:1156`](../../poc-d3d/src/compositor.rs)). When the+ ([`compositor.rs:1156`](../../crates/compositor/src/compositor.rs)). When thescene's `effects.blur` is on, `blur_bg` (dual-Kawase, ~18 px) blurs whateverwas just drawn — that is what "Blur BG" does, mirroring the web`frameRenderer.blurredBackgroundLayer`- ([`compositor.rs:1807`](../../poc-d3d/src/compositor.rs)).+ ([`compositor.rs:1807`](../../crates/compositor/src/compositor.rs)).2. **Screen shadow.** Drop-shadow SDF; opacity scales with the `shadow`slider. The shadow tracks the rendered silhouette — a tilted plane gets atilted shadow, not a rect shadow- ([`compositor.rs:1885`](../../poc-d3d/src/compositor.rs) /- [`compositor.rs:1882`](../../poc-d3d/src/compositor.rs), `mode = 12`).+ ([`compositor.rs:1885`](../../crates/compositor/src/compositor.rs) /+ [`compositor.rs:1882`](../../crates/compositor/src/compositor.rs), `mode = 12`).3. **Screen video.** Cropped from the active clip's source, with the zoom regionapplied to its UVs and rounded corners via SDF. `mode = 0` for the standard- quad ([`compositor.rs:1898`](../../poc-d3d/src/compositor.rs));+ quad ([`compositor.rs:1898`](../../crates/compositor/src/compositor.rs));`mode = 8` for the 3D tilt path (zoom `rotation: iso | left | right`,- [`compositor.rs:1950`](../../poc-d3d/src/compositor.rs)). Motion blur+ [`compositor.rs:1950`](../../crates/compositor/src/compositor.rs)). Motion bluruses the previous frame's UV delta as a per-pixel velocity vector and samplesalong it (the "blur by velocity" optimisation — early-outs on still frames).4. **Cursor.** A sprite picked from `cursor.cursorSprites` by the OS cursor state@@ -87,26 +94,26 @@ what `shaders.hlsl` actually implements:Motion blur is its own accumulation buffer (additive blend into anisolated RT, then "over"-composited onto the scene), independent of thescene's `effects.motionBlur`- ([`compositor.rs:2038`](../../poc-d3d/src/compositor.rs) /- [`compositor.rs:2060`](../../poc-d3d/src/compositor.rs)). Click+ ([`compositor.rs:2038`](../../crates/compositor/src/compositor.rs) /+ [`compositor.rs:2060`](../../crates/compositor/src/compositor.rs)). Clickbounce amplitude comes from the `.cursor.json` track- ([`poc-d3d/src/cursor.rs`](../../poc-d3d/src/cursor.rs)).+ ([`crates/compositor/src/cursor.rs`](../../crates/compositor/src/cursor.rs)).5. **Webcam shadow.** Drawn only when `cfg.shadow` is on AND the layout is PiP(not the block layouts, which weld the camera flush to the screen — nofloating bubble, no shadow). The strength fades to zero as the cameraenters Full Camera mode- ([`compositor.rs:2118`](../../poc-d3d/src/compositor.rs), `mode = 12`).+ ([`compositor.rs:2118`](../../crates/compositor/src/compositor.rs), `mode = 12`).6. **Webcam video.** UV rectangle derived from the destination aspect, withmirror, mask shape (rectangle / circle / square / rounded), and reactivescale applied- ([`compositor.rs:2127`](../../poc-d3d/src/compositor.rs), `mode = 0`).+ ([`compositor.rs:2127`](../../crates/compositor/src/compositor.rs), `mode = 0`).Full Camera lerps the destination to `[0, 0, 1, 1]` and dissolves the maskshape — same rule as `computeCameraFullscreenRect` on the TS side.7. **Annotations.** Highest layer. One full-frame `CopySubresourceRegion` ofthe composed scene is taken at the top of `draw_annotations` so thatmultiple blur annotations on the same frame read from a consistent snapshotof the underlying pixels- ([`compositor.rs:2162`](../../poc-d3d/src/compositor.rs)).+ ([`compositor.rs:2162`](../../crates/compositor/src/compositor.rs)).Per-annotation: figure (arrow, `mode = 9`), blur/mosaic (`mode = 10`),text (DirectWrite → D3D11 SRV, then `mode = 0`), image (cached perannotation id).@@ -131,7 +138,7 @@ The app hands the native compositor a flat JSON description once per documentor settings change. The TypeScript producer is[`buildSceneDescription`](../../src/native/sceneDescription.ts); the Rustmirror is the `Scene` struct in-[`poc-d3d/src/scene.rs`](../../poc-d3d/src/scene.rs). Field renames are+[`crates/compositor/src/scene.rs`](../../crates/compositor/src/scene.rs). Field renames arecamelCase on both sides (`#[serde(rename_all = "camelCase")]`), so the wireformat is the same names a TS caller already writes. Three fields thecontract insists on carrying as **fractions** of their reference box, not@@ -142,16 +149,16 @@ contain-fitted frame and the export at full output size:- `layout.screenRadiusFrac`, `layout.webcamRadiusFrac` — of their own box'sshort side (the only way two halves of a block layout can agree on aradius; see `compositor.rs` §1's comment on- [`compositor.rs:1702`](../../poc-d3d/src/compositor.rs)).+ [`compositor.rs:1702`](../../crates/compositor/src/compositor.rs)).- `annotation.x|y|w|h` and `annotation.text.fontSizeRel` — of the screenrect (annotations anchor to the screen box, not the output frame, andintentionally bypass the zoom transform).The consumer is `Compositor::compose_frame`-([`compositor.rs:1421`](../../poc-d3d/src/compositor.rs)). It reads+([`compositor.rs:1421`](../../crates/compositor/src/compositor.rs)). It readsthe scene per frame, derives per-clip and per-frame values through`Scene::for_clip_window`-([`scene.rs:436`](../../poc-d3d/src/scene.rs)) — which retains only the+([`scene.rs:436`](../../crates/compositor/src/scene.rs)) — which retains only theregions whose `clipIndex` matches the clip being composed and which overlapits source window — and only then issues GPU draws. Region visibility isexpressed as `[startSec, endSec)` intervals matched against `t = source_time`,@@ -164,7 +171,7 @@ mid-load.## Audio-`audio.rs` ([`poc-d3d/src/audio.rs`](../../poc-d3d/src/audio.rs)) is the+`audio.rs` ([`crates/compositor/src/audio.rs`](../../crates/compositor/src/audio.rs)) is thesingle audio path for the export. Per clip, it opens the source container,enumerates **every** audio stream (not just the first `av_find_best_stream`returns), opens a `SwrContext` to convert each one to **planar f32, 48 kHz,@@ -191,16 +198,16 @@ the click where two recordings meet butt-joined — without shifting timing,so A/V stays locked to the independently retimed video.The live preview does not use this path. `live.rs`-([`poc-d3d/src/live.rs`](../../poc-d3d/src/live.rs)) only handles video;+([`crates/compositor/src/live.rs`](../../crates/compositor/src/live.rs)) only handles video;audio is decoded and mixed by `audio.rs` for the export run and not for theon-screen view, so editing playback is silent against the exported file.## BuildThe crate links `libav*` (ffmpeg) via bindgen-([`build.rs`](../../poc-d3d/build.rs) /-[`wrapper.h`](../../poc-d3d/wrapper.h)). ffmpeg is not vendored — the-path is pinned in `poc-d3d/.cargo/config.toml`:+([`build.rs`](../../crates/compositor/build.rs) /+[`wrapper.h`](../../crates/compositor/wrapper.h)). ffmpeg is not vendored — the+path is pinned in `crates/.cargo/config.toml`:```[env]@@ -208,7 +215,7 @@ FFMPEG_DIR = { value = "thirdparty/ffmpeg-n8.1.2-win64-lgpl-shared", relative =LIBCLANG_PATH = "C:\\Program Files\\LLVM\\bin"```-So the thirdparty ffmpeg is **`poc-d3d/thirdparty/ffmpeg-n8.1.2-win64-lgpl-shared`**+So the thirdparty ffmpeg is **`crates/thirdparty/ffmpeg-n8.1.2-win64-lgpl-shared`**(the BtbN LGPL-shared build of ffmpeg-n8.1.2-22-g94138f6973, tag`autobuild-2026-07-15-14-01`). It must be the **same build** that`scripts/fetch-ffmpeg.mjs` vendorises into@@ -224,7 +231,7 @@ in `avcodec-NN.dll` is a build-id, not a soname, and changes betweenautobuilds. A floated snapshot would compile fine and crash at runtime onthe first `require()`.-`x.bat` ([`poc-d3d/x.bat`](../../poc-d3d/x.bat)) sets up the toolchain+`x.bat` ([`crates/x.bat`](../../crates/x.bat)) sets up the toolchainend-to-end: vcvars64 (MSVC + Windows SDK headers/libs for both the linkerand libclang), the ffmpeg `bin` directory on `PATH` (so the linker canfind `avcodec-NN.dll`'s import lib AND any DLL the crate emits resolves its@@ -244,7 +251,7 @@ licence. D3D11VA + AMF survive the LGPL-shared build (verified:## Known gaps- **No software/CPU fallback.** `d3d::Gpu::create`- ([`poc-d3d/src/d3d.rs`](../../poc-d3d/src/d3d.rs)) requests+ ([`crates/compositor/src/d3d.rs`](../../crates/compositor/src/d3d.rs)) requests`D3D_DRIVER_TYPE_HARDWARE` (no `WARP` / no `REFERENCE`) and pins`D3D_FEATURE_LEVEL_11_1` — any other feature level fails with `bail!`,and `VIDEO_SUPPORT` is mandatory for `D3D11VA`. A machine without adiff --git a/technical-documentation/architecture/preview.md b/technical-documentation/architecture/preview.mdindex 574858302..9b25d80dd 100644--- a/technical-documentation/architecture/preview.md+++ b/technical-documentation/architecture/preview.md@@ -1,7 +1,7 @@# PreviewThe preview is the editor's frame-at-the-playhead surface. It is composited by the same-Rust + Direct3D 11 native crate that drives MP4 export — `poc-d3d/` reached via the+Rust + Direct3D 11 native crate that drives MP4 export — `crates/compositor/` reached via the`compositor_view.node` napi-rs addon — and pulled into the renderer as an RGBA8bitmap that paints onto an HTML `<canvas>`. The DOM around the canvas hosts theinteractive-only layers (zoom gimbal, annotation selection, PiP webcam drag) that@@ -117,9 +117,9 @@ current editor settings to a `SceneDescription` JSON string. It resolves:itself stays in pixels for the user — the division happens once, here.The descriptor mirrors the Rust struct in-[`poc-d3d/src/scene.rs`](../../poc-d3d/src/scene.rs); field rename is `camelCase`+[`crates/compositor/src/scene.rs`](../../crates/compositor/src/scene.rs); field rename is `camelCase`on both sides. The Rust consumer (`compositor.rs::compose_frame`,-[`poc-d3d/src/compositor.rs:1421`](../../poc-d3d/src/compositor.rs:1421)) reads+[`crates/compositor/src/compositor.rs:1421`](../../crates/compositor/src/compositor.rs:1421)) readsthe JSON per frame, derives the per-clip and per-frame values it needs (zoomstate from `regions.rs::zoom_state_at`, camera-fullscreen progress from`regions.rs::camera_fullscreen_progress_at`, screen crop from@@ -239,9 +239,9 @@ in the middle of a clip transition is honoured, not silently undone.## Known gaps-- **Live preview is video-only.** `poc-d3d/src/live.rs` (1628 lines) handles only+- **Live preview is video-only.** `crates/compositor/src/live.rs` (1628 lines) handles onlythe video packet stream; audio is decoded and mixed in- [`audio.rs::decode_clip_audio`](../../poc-d3d/src/audio.rs) for the export+ [`audio.rs::decode_clip_audio`](../../crates/compositor/src/audio.rs) for the exportpath and not for the live view. Editing playback is therefore silent againstthe exported file; users hear audio only when the export runs. There is noflag in this branch that re-routes live audio.diff --git a/technical-documentation/engineering/build-and-packaging.md b/technical-documentation/engineering/build-and-packaging.mdindex 56d8a958f..fb45dc8be 100644--- a/technical-documentation/engineering/build-and-packaging.md+++ b/technical-documentation/engineering/build-and-packaging.md@@ -8,7 +8,7 @@ OpenScreen builds its renderer, Electron main process, preload bridge, native he|---|---|| `npm run dev` | Starts Vite with the Electron plugin; builds and launches main/preload unless `NO_ELECTRON` is set. || `npm run build-vite` | Runs TypeScript checking and Vite only. It produces `dist/` and `dist-electron/` but no installer. |-| `npm run build` | Runs TypeScript checking, Vite, then unrestricted `electron-builder`. This is the full generic packaging command, but it does not proactively build platform helpers. |+| `npm run build` | Runs TypeScript checking, Vite, then unrestricted `electron-builder`. This is the full generic packaging command, but it does not proactively build platform helpers. **On Windows, prefer `build:win`** — see [Stale native artifacts](#stale-native-artifacts). || `npm run build:mac` | Builds the ScreenCaptureKit and cursor helpers, checks TypeScript, runs Vite, and packages the macOS target. || `npm run build:win` | Builds WGC/cursor helpers and the D3D11 compositor addon, fetches FFmpeg, checks TypeScript, runs Vite, and packages the Windows NSIS target without npm rebuild. || `npm run build:win:store` | Performs the Windows native and renderer build, then asks electron-builder for the configured AppX Store package. |@@ -37,7 +37,30 @@ A usable full package depends on generated artifacts that are not committed:Electron-builder copies only the matching `electron/native/bin/<platform>-<arch>/` directory into each package. The compositor `.node` file is included by the Windows `files` rule and unpacked from ASAR because native addons cannot be loaded from inside the archive.-`electron/native/bin/`, local native build directories, the compositor build output, models, and caches are gitignored. Rebuilding from a source checkout therefore requires the complete platform toolchain and third-party SDKs; running the generic `npm run build` alone does not manufacture missing native artifacts. The Windows compositor's D3D11/FFmpeg prerequisites are described by the source POC in `poc-d3d/README.md`, while capture helper lookup and output conventions are documented in `electron/native/README.md`.+`electron/native/bin/`, local native build directories, the compositor build output, models, and caches are gitignored. Rebuilding from a source checkout therefore requires the complete platform toolchain and third-party SDKs; running the generic `npm run build` alone does not manufacture missing native artifacts. The Windows compositor's D3D11/FFmpeg prerequisites are described by the source POC in `crates/README.md`, while capture helper lookup and output conventions are documented in `electron/native/README.md`.++### Stale native artifacts++**On Windows, always package with `npm run build:win`, not `npm run build`.**++`compositor_view.node` is gitignored, so it is whatever your last local Rust build produced. `npm run build` is `tsc && vite build && electron-builder` — it never invokes `build:native:compositor`. Only `build:win` does. Two ways this bites:++- You edit `crates/compositor/`, then package with `npm run build`. The installer gets the addon from before your edit.+- You create a worktree. Git does not copy gitignored files, so the worktree has no addon until one is built or copied in — usually an old one from the main checkout.++A stale addon **fails silently rather than erroring**. Scene fields are `#[serde(default)]` on the Rust side, so an addon that predates a contract change does not reject the payload: it ignores the unknown key, takes the default, and falls back to older behaviour. Nothing appears in any log, and the symptom ("the feature does nothing") is indistinguishable from a TypeScript bug. This is not hypothetical — on 2026-07-27 a build shipped an addon three days older than the commit adding `cursorSprites`, custom cursor themes silently rendered as the built-in art, and the resulting investigation blamed the wrong layer entirely.++`scripts/before-pack.cjs` runs as electron-builder's `beforePack` hook and fails the build when the addon is older than `crates/compositor/src/`, `crates/compositor-view-napi/src/`, or either `Cargo.toml`. It only checks when packaging for Windows. The fix it prints is:++```bash+npm run build:native:compositor+```++CI is unaffected: `.github/workflows/build.yml` already uses `build:win`, which rebuilds before packaging.++The check compares modification times, so `git checkout` (which restamps source files) can occasionally flag an addon that is genuinely fine. That trade is deliberate — a false alarm costs one rebuild, whereas a missed stale addon ships a broken installer. Run `node scripts/before-pack.cjs` on its own to see the verdict without packaging.++Diagnosing a suspected stale addon: serde embeds its field-name literals in the compiled binary, so `grep -c <newCamelCaseField> compositor_view.node` returning 0 means the binary predates that contract.## Platform packagingdiff --git a/technical-documentation/engineering/rendering-performance.md b/technical-documentation/engineering/rendering-performance.mdindex 06f0dad0e..34a169422 100644--- a/technical-documentation/engineering/rendering-performance.md+++ b/technical-documentation/engineering/rendering-performance.md@@ -153,7 +153,7 @@ The three changes that produced the 84 %:- **The shadow ran everywhere.** 12 taps on every pixel, including under the opaque video and far outside the rect where the answer is zero. Every tap lands within `spread` of the pixel, so the box grown by spread bounds where any tap can hit, and the box shrunk by spread bounds where all of them do — Minkowski sums with the tap disc, the same number by arithmetic rather than by twelve samples.- **The frame was drawn as one fullscreen triangle with `if`s.** It paid for every pixel of every effect and threw most of it away. Now each element is a quad sized to its own rect: the rasterizer runs the fragment shader only where the element is and clips what leaves the stage, in fixed function, with no branch. A zoomed recording is 2.7× the stage — two thirds of it is off-screen and now costs nothing. Plus CPU culling from the rects the pure-function `evaluate` already produced: when the recording covers the stage (every zoom), the background and its shadow are not drawn at all; an off-stage webcam is not drawn at all.-### The D3D11 native fast path (`poc-d3d/`) — 2026-07-18+### The D3D11 native fast path (`crates/compositor/`) — 2026-07-18One `ID3D11Device`, no CPU readback between any stage — D3D11VA hardware decode (×2, NV12 GPU textures) → HLSL compositor (the same effect set: layout, zoom, shadows, masks, background blur, motion blur, cursor; NV12→RGB, dual-Kawase blur, SDF corners+shadows, per-velocity blur) → RGB→NV12 (two RTV passes) → `h264_amf` encode (GPU→GPU) → MP4 mux. Stack: Rust + `windows-rs`, ffmpeg `libav*` (LGPL) as demux/decode/encode/mux plumbing, HLSL compiled at runtime. The measured window is one `Instant::now()` before and one after the WHOLE run — decode, encode and mux included — so nothing inside can falsify the clock.@@ -321,7 +321,7 @@ Unit tests never look at a pixel. The `native*` arms write real files: export th### Rust + wgpu native POC (`poc-native/`)-**What it was.** `poc-native/` — Rust, wgpu (Vulkan on the reference AMD iGPU), the AMD hardware encoder via ffmpeg `h264_amf`. No browser, no WebCodecs. **What the measurement said.** The compositor is portable, proven: wgpu runs `composite.wgsl` **unchanged** — the only edits are the two the web platform forces and native lacks (`texture_external` → `texture_2d`, `textureSampleBaseClampToEdge` → `textureSampleLevel`); the native frame at t=0.5 s is pixel-identical to the web POC. Encoder ceilings measured (ffmpeg, `-benchmark`): `h264_amf` with CPU-decoded frames ~180 fps; `d3d11va` decode → `h264_amf`, frames stay on GPU **256 fps** — the hardware encoder is not the wall. The naive Vulkan pipeline measured 31 fps end-to-end (decoded via wgpu, composite in WGSL, encode `h264_amf`), but the cause was measured before it was concluded: with encode pipe 31.2 fps vs without 31.7 fps, the encoder isn't the wall; the decode pipe alone (ffmpeg → /dev/null, 180 frames) is **30 fps**, 3.9 s of system time — 8 MB/frame × 180 = 1.4 GB of *uncompressed* pixels shoved between subprocesses. The wall is the subprocess raw-RGBA pipes, an artifact of reaching ffmpeg as a child process, not the descent, not the compositor (1.9 ms), not the encoder (256 fps). The CPU path was pushed to its ceiling and loses by construction: subprocess pipes 31 fps, in-process CPU decode synchronous 25 fps, in-process CPU decode threaded (overlapped) no encode 61 fps, threaded decode + composite + `h264_amf` ~48 fps, threaded no-readback no encode 68 fps — against WebCodecs 79 fps and `d3d11va` → `h264_amf` all on GPU 256 fps. Threading the decode was the real lever (25 → 61): the subprocess version's advantage was never "pipes", it was parallel decode. The CPU path plateaus UNDER the browser, and the reason is pinned by the no-readback probe: the descent (GPU→CPU) is only ~10 % (61 → 68); the wall is **CPU↔GPU transport** — 9 MB uploaded per frame on input, 8 MB read back on output, plus CPU swscale at both ends (YUV→RGBA decode, RGBA→NV12 encode). The browser pays none of this: WebCodecs decodes into GPU-backed `VideoFrame`s that `importExternalTexture` wraps with no CPU copy. **The Vulkan route is blocked on the driver:** `VK_KHR_video_maintenance1` is required and the AMD iGPU's driver (24.10.38) predates it. `poc-d3d/` delivers the same GPU-resident principle on the shipped driver and is the retained native fast path (see [D3D11](#the-d3d11-native-fast-path-poc-d3d--2026-07-18) above). **One-line reason not to re-propose:** portability is proven but the GPU-resident native ceiling requires a path the AMD driver doesn't expose; the same goal is reached on D3D11.+**What it was.** `poc-native/` — Rust, wgpu (Vulkan on the reference AMD iGPU), the AMD hardware encoder via ffmpeg `h264_amf`. No browser, no WebCodecs. **What the measurement said.** The compositor is portable, proven: wgpu runs `composite.wgsl` **unchanged** — the only edits are the two the web platform forces and native lacks (`texture_external` → `texture_2d`, `textureSampleBaseClampToEdge` → `textureSampleLevel`); the native frame at t=0.5 s is pixel-identical to the web POC. Encoder ceilings measured (ffmpeg, `-benchmark`): `h264_amf` with CPU-decoded frames ~180 fps; `d3d11va` decode → `h264_amf`, frames stay on GPU **256 fps** — the hardware encoder is not the wall. The naive Vulkan pipeline measured 31 fps end-to-end (decoded via wgpu, composite in WGSL, encode `h264_amf`), but the cause was measured before it was concluded: with encode pipe 31.2 fps vs without 31.7 fps, the encoder isn't the wall; the decode pipe alone (ffmpeg → /dev/null, 180 frames) is **30 fps**, 3.9 s of system time — 8 MB/frame × 180 = 1.4 GB of *uncompressed* pixels shoved between subprocesses. The wall is the subprocess raw-RGBA pipes, an artifact of reaching ffmpeg as a child process, not the descent, not the compositor (1.9 ms), not the encoder (256 fps). The CPU path was pushed to its ceiling and loses by construction: subprocess pipes 31 fps, in-process CPU decode synchronous 25 fps, in-process CPU decode threaded (overlapped) no encode 61 fps, threaded decode + composite + `h264_amf` ~48 fps, threaded no-readback no encode 68 fps — against WebCodecs 79 fps and `d3d11va` → `h264_amf` all on GPU 256 fps. Threading the decode was the real lever (25 → 61): the subprocess version's advantage was never "pipes", it was parallel decode. The CPU path plateaus UNDER the browser, and the reason is pinned by the no-readback probe: the descent (GPU→CPU) is only ~10 % (61 → 68); the wall is **CPU↔GPU transport** — 9 MB uploaded per frame on input, 8 MB read back on output, plus CPU swscale at both ends (YUV→RGBA decode, RGBA→NV12 encode). The browser pays none of this: WebCodecs decodes into GPU-backed `VideoFrame`s that `importExternalTexture` wraps with no CPU copy. **The Vulkan route is blocked on the driver:** `VK_KHR_video_maintenance1` is required and the AMD iGPU's driver (24.10.38) predates it. `crates/compositor/` delivers the same GPU-resident principle on the shipped driver and is the retained native fast path (see [D3D11](#the-d3d11-native-fast-path-cratescompositor--2026-07-18) above). **One-line reason not to re-propose:** portability is proven but the GPU-resident native ceiling requires a path the AMD driver doesn't expose; the same goal is reached on D3D11.### Tauri / a separate native core