Skip to content

Commit 45369c5

Browse files
committed
fix: require explicit recording benchmark invocation
1 parent 2fca0fe commit 45369c5

4 files changed

Lines changed: 385 additions & 38 deletions

File tree

apps/desktop/scripts/stop-editor-performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ From `apps/desktop-gpui`, build the drivers with `cargo build --example studio-f
522522

523523
`CAP_BENCH_FULL_AUDIO_ONLY=1` skips the range experiment. Without it, the driver exits unsuccessfully if decoded ranges differ from the full-track reference. `CAP_BENCH_STREAM_AUDIO=1` also checks every sequential chunk against that reference. Preserve failed range experiments as failures; the known two-hour timestamp-seeking mismatch must not be mistaken for passing progressive-window coverage. Progressive windows use sequential sample positions instead.
524524

525-
The debug Tauri driver is enabled by `CAP_STOP_EDITOR_BENCHMARK_OUTPUT`, with `CAP_STOP_BENCH_SECONDS`, optional `CAP_STOP_BENCH_MIC`, and optional `CAP_STOP_BENCH_SYSTEM_AUDIO`. Use an isolated app identifier and recordings directory. Its injected editor observer waits for a completed render in the existing frame statistics, a visible editor canvas, and two animation frames. A timeout is a failed benchmark, not a successful editor-open measurement. The initial observer only watched worker messages and missed Tauri's direct-canvas renderer; that incomplete run is excluded.
525+
The debug Tauri driver requires the explicit arguments `--stop-editor-benchmark --allow-real-recording`, both `CAP_STOP_EDITOR_BENCHMARK_OUTPUT` and `CAP_STOP_BENCH_LOG_DIR`, and a private app identifier beginning `so.cap.desktop.stop-editor-benchmark.` with a nonempty suffix. Output and log paths must be fresh private siblings under an existing canonical directory. `CAP_STOP_BENCH_SECONDS` selects 1–86,400 seconds (default 15); `CAP_STOP_BENCH_MIC` and `CAP_STOP_BENCH_SYSTEM_AUDIO` opt into audio. Environment variables alone cannot activate recording. Keep the private identifier and recordings directory isolated from the user library. Its injected editor observer waits for a completed render in the existing frame statistics, a visible editor canvas, and two animation frames. A timeout is a failed benchmark, not a successful editor-open measurement. The initial observer only watched worker messages and missed Tauri's direct-canvas renderer; that incomplete run is excluded.
526526

527527
Existing GPUI drivers include `CAP_GPUI_AUTO_RECORD=studio:60`, `CAP_GPUI_AUTO_NO_MIC=1`, `CAP_GPUI_AUTO_SYSTEM_AUDIO=1`, `CAP_GPUI_AUTO_EDITOR`, and `CAP_GPUI_AUTO_PLAYBACK`. `CAP_GPUI_AUTO_SEEK` targets a fraction of the visible timeline viewport. The new `CAP_GPUI_AUTO_SEEK_TIME=7194.5` targets seconds into the recording and logs the clamped time passed to the ordinary seek method. Use explicit time for long-recording tail checks. Keep app data and recordings isolated from the user's library.
528528

apps/desktop/src-tauri/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6525,6 +6525,13 @@ type FilteredRegistry = tracing_subscriber::layer::Layered<
65256525
pub type DynLoggingLayer = Box<dyn tracing_subscriber::Layer<FilteredRegistry> + Send + Sync>;
65266526
type LoggingHandle = tracing_subscriber::reload::Handle<Option<DynLoggingLayer>, FilteredRegistry>;
65276527

6528+
#[cfg(debug_assertions)]
6529+
pub fn initialize_stop_editor_benchmark(
6530+
create_log_directory: impl FnOnce(&std::path::Path, &std::path::Path) -> std::io::Result<PathBuf>,
6531+
) -> Result<Option<PathBuf>, String> {
6532+
stop_editor_benchmark::initialize(create_log_directory)
6533+
}
6534+
65286535
/// Software recovery exists to break GPU-driver crash loops: a process that died
65296536
/// while wgpu adapter/device initialisation was in flight. Any other unexpected
65306537
/// termination (force-quit, power loss, OS kill, a hung shutdown) says nothing
@@ -7075,6 +7082,8 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
70757082
})
70767083
.setup(move |app| {
70777084
let app = app.handle().clone();
7085+
#[cfg(debug_assertions)]
7086+
stop_editor_benchmark::validate_app_identifier(&app.config().identifier)?;
70787087
#[cfg(target_os = "macos")]
70797088
let _startup_open_guard = app
70807089
.try_state::<StartupOpenGate>()

apps/desktop/src-tauri/src/main.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,15 @@ fn main() {
101101
.join("logs");
102102

103103
#[cfg(debug_assertions)]
104-
let path = match (
105-
std::env::var_os("CAP_STOP_EDITOR_BENCHMARK_OUTPUT"),
106-
std::env::var_os("CAP_STOP_BENCH_LOG_DIR"),
107-
) {
108-
(Some(output), Some(directory)) => match create_benchmark_log_directory(
109-
std::path::Path::new(&output),
110-
std::path::Path::new(&directory),
111-
) {
112-
Ok(directory) => directory,
104+
let path =
105+
match cap_desktop_lib::initialize_stop_editor_benchmark(create_benchmark_log_directory)
106+
{
107+
Ok(directory) => directory.unwrap_or(path),
113108
Err(error) => {
114-
eprintln!("Invalid private benchmark log directory: {error}");
109+
eprintln!("Invalid Stop benchmark invocation: {error}");
115110
std::process::exit(2);
116111
}
117-
},
118-
_ => path,
119-
};
112+
};
120113

121114
path
122115
};

0 commit comments

Comments
 (0)