Skip to content

Commit 52d596b

Browse files
test(compositor): fix flaky runtime format change test on GPU runner
The test consistently got only 1 output frame instead of ≥ 2 on the self-hosted GPU runner. Root cause: when compiled with --features gpu and gpu_mode Auto (the default), the compositor OS thread blocks on GpuContext::try_init() before processing any compositing work. On the GPU runner with many tests competing for the device, init can exceed the total sleep budget (800ms). By the time it finishes, both input frames have been drained to just the latest (Dynamic mode behaviour), producing a single output. Fix: set gpu_mode: "cpu" explicitly. This test validates runtime output_format switching via UpdateParams, not GPU compositing — GPU init is unnecessary overhead that creates the race. Also reduces sleep durations to 200/100/200ms (from 300/200/300ms) since without GPU init the compositor thread starts processing immediately. Signed-off-by: Devin AI <devin@streamkit.dev> Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
1 parent ea101aa commit 52d596b

File tree

1 file changed

+13
-8
lines changed
  • crates/nodes/src/video/compositor

1 file changed

+13
-8
lines changed

crates/nodes/src/video/compositor/tests.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,16 @@ async fn test_compositor_output_format_runtime_change() {
25022502
};
25032503

25042504
// Start with no output_format (RGBA8).
2505-
let config = CompositorConfig { width: 4, height: 4, ..Default::default() };
2505+
// Force CPU mode so the test isn't blocked by GpuContext::try_init()
2506+
// competing for the GPU with other parallel tests on the self-hosted
2507+
// runner. This test validates runtime output_format switching, not
2508+
// GPU compositing.
2509+
let config = CompositorConfig {
2510+
width: 4,
2511+
height: 4,
2512+
gpu_mode: Some("cpu".to_string()),
2513+
..Default::default()
2514+
};
25062515
let node = CompositorNode::new(config, GlobalCompositorConfig::default());
25072516

25082517
let node_handle = tokio::spawn(async move { Box::new(node).run(context).await });
@@ -2513,21 +2522,17 @@ async fn test_compositor_output_format_runtime_change() {
25132522
// Send a frame — should come out as RGBA8.
25142523
let frame = make_rgba_frame(2, 2, 255, 0, 0, 255);
25152524
input_tx.send(Packet::Video(frame)).await.unwrap();
2516-
// Give the compositor enough ticks to process the frame. On the
2517-
// self-hosted GPU runner many tests run in parallel, so the
2518-
// compositor thread may be starved for CPU. 300ms ≈ 9 ticks at
2519-
// 30 fps — generous enough even under heavy load.
2520-
tokio::time::sleep(tokio::time::Duration::from_millis(300)).await;
2525+
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
25212526

25222527
// Send UpdateParams to switch output_format to NV12.
25232528
let update = serde_json::json!({ "output_format": "nv12" });
25242529
ctrl_tx.send(NodeControlMessage::UpdateParams(update)).await.unwrap();
2525-
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
2530+
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
25262531

25272532
// Send another frame — should come out as NV12.
25282533
let frame2 = make_rgba_frame(2, 2, 0, 255, 0, 255);
25292534
input_tx.send(Packet::Video(frame2)).await.unwrap();
2530-
tokio::time::sleep(tokio::time::Duration::from_millis(300)).await;
2535+
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
25312536

25322537
drop(input_tx);
25332538
drop(ctrl_tx);

0 commit comments

Comments
 (0)