Repository navigation
obs-core: Port the graphics task drain to Rust - #4742
Merged
Merged
Conversation
Tier 1 tests for obs-core's video_graphics_tasks, ported 1:1 from test_video_graphics_tasks.c over a model queue: queued tasks run oldest first, each once; a task queued while another runs runs in the same pass; and task_mutex is held for every size check and pop and released around every task. The model logs each call, so the tests also pin the C's order of lock, size check, pop, unlock, run and lock again. The drain is a todo!() stub, so all four fail. Refs #4408. Co-Authored-By: Zach Vorhies <[email protected]>
execute_graphics_tasks() in obs-video-graphics-tasks.c.h is now a bridge to the hidden obs_video_graphics_tasks_execute(), Rust in hybrid libobs (obs-core::video_graphics_tasks). The bridge passes the core and its accessors for task_mutex, tasks.size and a pop of one struct obs_task_info, so the deque and its mutex stay C-owned. The Rust keeps the C's order: take the mutex; while the queue is not empty, pop the oldest task, release the mutex, run the task through its own function pointer and take the mutex again; release it. The call site in obs_graphics_thread_loop() is unchanged. The original C is the C reference, in its own ported group (obs-video-graphics-tasks-reference.c.h), and the unchanged test_video_graphics_tasks runs against it and against the Rust. Refs #4408. Co-Authored-By: Zach Vorhies <[email protected]>
Tier 3 for obs-core's video_graphics_tasks. The oracle compiles the original C (obs-video-graphics-tasks-reference.c.h) and the production bridge's accessors over a real private core with a real task_mutex and deque. The parity test runs both over the same trees of tasks: some queued before the drain, the rest queued by their parent while it runs, the way another producer does. It compares the tasks run, in order, whether task_mutex was held for each, that every producer got the mutex, the queue left empty and the mutex released: for the characterization's queues, every tree of up to six tasks, and random trees of up to 62. Planted mutants caught: the mutex held across a task, one task per pass, and the queue taken whole before any task runs. Refs #4408.
The rust/README.md row for obs-video-graphics-tasks.c.h, its place in naming.md's obs-core row, and obs-core's Cargo.toml description and module docs. Refs #4408.
obs_queue_task() queues a NULL task without a check, and the graphics task drain calls it, so the graphics thread crashes (the C) or aborts (the Rust, which panics on it across the C ABI). The new null_task_is_skipped case queues a NULL task between two real ones on the oracle's real core and runs the Rust drain over it: it should run the two real tasks, in order, unlocked, and leave the queue empty and the mutex released. It aborts on "a queued graphics task" now. The oracle's push takes an optional task for it. Refs #4408.
The graphics task drain now skips a popped task whose function is NULL instead of calling it, as the audio task drain already does: obs_queue_task() queues one without a check, and calling it crashed the graphics thread. The tasks queued after it still run, and the mutex is released around each as before. This is the port's one intentional difference from the C, listed in the parity test header and the rust/README.md row, with its line in docs/features.md. Fixes #4408. Local-Gate: v1 tree=046cad34c620d2fab1186d87d7b372e3a19ee904 secs=2440 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1794527848,"gate":"rust/all/fmt","host":"linux-x86_64","key":"b55f4ad6d00b5afefa9a92bf79da3f7ec4fbeecd05782853af6e74d25509bcec","lane":"lint","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":61,"stamp":"fa63df07ac740661fb5b2053e7d2a7ad","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"b55f4ad6d00b5afefa9a92bf79da3f7ec4fbeecd05782853af6e74d25509bcec","lane":"lint","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":61,"stamp":"8905d7aa7d33f3ea8ce0208a56e55572","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"46e3b4cebcc7c6e904004b16bbdc7cc7e5d3f9bffcc030f5df71014fc2c6389c","lane":"dylint","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":0,"stamp":"22235d4296f349162d99da6d28cfe433","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"506c02b53123e54694c3f6c805fbdadfb1685d239fadeac11fb499522b4b4a12","lane":"rust-test","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":225,"stamp":"203bbd62ac24e99bf2f5d97cffde705a","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"7b57f59c3f725abfde890d3230e6505735111b127bdf01e3341dabe51b653291","lane":"cross","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":107,"stamp":"b4b5b6b4031706cc68a15d04c69131cd","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"7b57f59c3f725abfde890d3230e6505735111b127bdf01e3341dabe51b653291","lane":"cross","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":107,"stamp":"17d7e196bc3a2ca412495570f842603e","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"7b57f59c3f725abfde890d3230e6505735111b127bdf01e3341dabe51b653291","lane":"cross","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":107,"stamp":"322eab0aa0638d563258d3a07b7b1a75","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"7b57f59c3f725abfde890d3230e6505735111b127bdf01e3341dabe51b653291","lane":"cross","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":107,"stamp":"45b787735e77a164f581a5a2010e0211","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"} Ci-Attestation: {"at":1794527848,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9edf3a97d4984cd25fc77e348d4a56249c29ebf4e4a5c0b00a8b0420a88dbd28","lane":"tier2-linux","parents":["6dd2e890550fa34832412ae51400ba7ae69e12cd"],"secs":2440,"stamp":"918ffb009b27d150367e9fe1951b9818","tree":"046cad34c620d2fab1186d87d7b372e3a19ee904","v":1,"via":"run"}
rdoupe
force-pushed
the
fix/rust-port-port-the-graphics-task-800
branch
from
November 12, 2026 23:58
74b4edd to
23faf1f
Compare
rdoupe
marked this pull request as ready for review
November 13, 2026 00:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4408
What and why
Ports
execute_graphics_tasks()(libobs/obs-video-graphics-tasks.c.h), the graphics thread's per-frame drain of theOBS_TASK_GRAPHICSqueue, toobs-core::video_graphics_tasks. It is the Rust half of zackees' extraction (#4410, from #4403), and the last piece of thatobs-video.c.hsplit after the stop check (#4671) and the render size (#4541).This carries zackees' draft from
port/4408-graphics-tasks(theQueuetrait and the Tier 1 cases), rebased onto current master and reshaped like the stop check port, with his Co-Authored-By on the RED and GREEN commits.obs-video-graphics-tasks.c.his now a private bridge:execute_graphics_tasks()keeps its name and its call site inobs_graphics_thread_loop(), and calls the hiddenobs_video_graphics_tasks_execute()(declared in the new privateobs-video-graphics-tasks.h, notEXPORT, listed inrust-hidden.d) with the core and four accessors: lock and unlock oftask_mutex,tasks.size != 0, and a pop of onestruct obs_task_info. The deque and its mutex stay C-owned; the Rust reads no private layout.obs-video-graphics-tasks-reference.c.h,libobs.ported-video-graphics-tasks+).obs_queue_task()queues without a check and the C calls and crashes on, is skipped, and the tasks after it still run, as the audio task drain (obs-core::audio_callback) already does. The port itself keeps the C's behaviour (a NULL task aborts the graphics thread); the fix follows it. It is listed in the parity test header and the rust/README.md row, and has its line indocs/features.md(Fixed upstream bugs, Stability). Tier 3 can't compare it, since the C crashes;null_task_is_skippedcovers it on the oracle's real core.Upstream: no upstream issue. The C characterization and extraction are zackees' (#4410).
RED → GREEN
obs_core::video_graphics_tasks::{graphics_fifo, graphics_callback_enqueue, graphics_empty_then_second_drain, graphics_chain_drains_in_one_pass}(Tier 1, mirroringtest_video_graphics_tasks.c, with the C's call order logged) fail 4/4 on thetodo!()drain ("not yet implemented: execute_graphics_tasks");--lane lintpasses, and--test-difffails on those four tests only.obs_core::video_graphics_tasks_parity::null_task_is_skippedaborts on "a queued graphics task" (the panic crosses the C ABI);--test-difffails on that test only (8407 passed, 1 failed). GREEN 23faf1f skips it.obs_core::video_graphics_tasks4/4.test_video_graphics_taskspasses on the C build, against hybridlibobsand againstlibobs-c-reference. The video, graphics, task, shutdown and reset tests (ctest -R 'video|graphics|task|shutdown|reset', under Xvfb) pass 66/66 on the C build, 75/75 against hybridlibobsand 75/75 againstlibobs-c-reference, 0 skipped. Rerun on 23faf1f:ctest -R 'video|graphics|task'62/62 against hybridlibobsand 62/62 againstlibobs-c-reference, 0 skipped.obs_core::video_graphics_tasks_parity4/4 (3 parity cases, plusnull_task_is_skipped): the characterization's queues, every tree of up to six tasks, and a proptest over random trees of up to 62, where tasks queue more tasks through a real producer push. Planted mutants caught: the mutex held across a task, one task per pass, and the queue taken whole before any task runs.ci/local_gate.py --test-diff(8408 passed, 6 skipped, plus the Windows-GNU oracle build),--lane lint,--lane dylint,--lane cross, andcargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets -D warningsall pass. After the rebase,./unittestran the Rust tests (8437 passed, 6 skipped) and Tier 2 in Docker, whose C-reference pass came first and stopped it at 917/918:test_screencast_portal_teardowntimed out under load (SIGALRM). It passed alone 3/3 on the C reference and once each on the hybrid and C builds, and the local gate's own Tier 2 Linux run (both builds) then passed in full.obs_video_graphics_tasks_executeis local (t) in all three, and hybridlibobsdoesn't compile the reference group.OBS_PARITY_CASES=reduced), no threads of their own.null_task_is_skipped.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (the NULL-task crash fix, under Fixed upstream bugs, Stability)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)