Repository navigation
obs-source: Port the transition child slots - #3563
Merged
Merged
Conversation
RED for #3562. obs_source::transition_slots has its API and docs, with todo!() bodies: clear(), enum_sources(), copy_source_state(), swap_begin() and swap_end(), generic over a Transition with one method per field read or write, per lock call and per call into the rest of libobs (obs_source_get_ref(), obs_source_release(), the active-child add and remove, the recursion warning). tests/source/transition_slots.rs runs them on a fake source graph that counts references and active-child links, records every call in order, and panics on a field touched without the lock the C holds there or a lock taken twice. The c_* cases follow test_source_transition_slots.c; the others pin which children are released, added or kept, what the destination stores when the add fails or the child is going away, which clock fields move, and every lock's order, with a proptest over any two transitions. 17 of the 18 fail on the stubs (obs-tests-core, source::transition_slots); the constants pass. Refs #3562.
The child slots of obs-source-transition-slots.c are Rust: obs_transition_clear(), obs_transition_enum_sources(), and the swap of obs_transition_swap_begin() (with copy_source_state()) and obs_transition_swap_end(). The clear and the swap stay EXPORT (rust-exports.d); obs_transition_enum_sources() is declared in obs-internal.h without EXPORT and stays hidden (rust-hidden.d). The export sets of the C, hybrid and C reference builds are unchanged (1767). The safe core makes the C's calls in its order and under its locks, generic over a Transition: one method per seam call (the check, each field, both mutexes, the render targets) and per libobs call. The shims in obs-source-seam implement it over the transition seam and, through Calls, over obs_source_get_ref(), obs_source_release(), the active-child add and remove and obs_source_get_name(), with the recursion warning through blog(). Libobs makes those calls through the C symbols; the parity test hands in the oracle's stand-ins. oracle/source_active_child_links.c gives obs-tests-core obs_source_add_active_child() and obs_source_remove_active_child() under their own names: the MSVC, MinGW and macOS linkers resolve every symbol the shims name, used or not, and that binary links no libobs. No test reaches them. The file moves from libobs.core-source into its own ported group, libobs.ported-source-transition-slots, whose precompiled header is obs-internal.h with the seam, start and load headers. Tier 1: 18/18. Tier 2: the transition tests pass 25/26 on the C build and 30/31 on the hybrid and C reference builds, 0 skipped; the one failure on all three is test_stinger_media_duration, whose stinger effect file is not in this tree's run directory. Refs #3562.
oracle/source_transition_slots.c builds the original obs-source-transition-slots.c renamed oracle_*, over the transition seam the settings oracle already compiles under its own names. Its calls into the rest of libobs (obs_source_get_ref(), obs_source_release(), the active-child add and remove, obs_source_get_name()) go to recording stand-ins: one graph of test sources (zeroed struct obs_source with a type, a name and both transition mutexes), each with a reference count, a link count per parent and child, and a trace of every call but the name reads, whose order the C leaves unspecified. tests/source_seam/transition_slots_parity.rs runs the C and the Rust shims (with the same stand-ins as their Calls) on the same graph, built afresh for each, and compares after every call and between each swap's begin and end: every slot, active flag, running flag, clock field and render target, which mutexes are held, every reference and link count, the calls in order and what the enum's callback got with the lock held. Every call on ten fixed graphs (the C test's running transition, a new one that held children, inactive slots, the new transition and a scene that contains it in the old one's slots, a transition holding itself, one child in both slots, an input with children, children going away, a manual and an audio-only transition) and a proptest over random graphs and sequences of up to seven calls. In a child process, the recursion warning is the C's line and level from both sides. Mutants in the core (no remove of the old child, no manual target, no stop of the audio, a refused slot left active, the old children not released) each fail it. The order of the lock calls is not visible here; the Tier 1 tests pin it. Refs #3562.
rust/README.md gets the row for obs-source-transition-slots.c (the core over the seam and the libobs calls, the locking, which functions are exported, what is kept and how each tier checks it) and the file in the obs-source and obs-source-seam rows; both crates' descriptions, lib.rs module docs and the obs-source-seam README name it, and so does naming.md's obs-source*.c.h row. No intentional differences, and no change a user can see, so docs/features.md gets no line. Fixes #3562.
rdoupe
force-pushed
the
fix/rust-port-port-the-transition-ch-568
branch
from
November 3, 2026 16:06
22c756b to
64f4f38
Compare
rdoupe
marked this pull request as ready for review
November 3, 2026 18:18
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 #3562
What and why
This ports the child slots of a transition (
libobs/obs-source-transition-slots.c.h, moved out ofobs-source-transition.cin #3530) torust/obs-source:obs_transition_clear(),obs_transition_enum_sources(), and the swap ofobs_transition_swap_begin()(with its file-localcopy_source_state()) andobs_transition_swap_end(). The clear and the swap stayEXPORTthroughobs.h.obs_transition_enum_sources()is declared inobs-internal.hwithoutEXPORT(obs-source.c's tree walks call it), so it stays hidden (rust-hidden.d).The safe core (
obs_source::transition_slots) is generic over aTransition: one method per field read or write, per lock call, and per call into the rest of libobs (obs_source_get_ref(),obs_source_release(), the active-child add and remove, the recursion warning). Each function makes the C's calls in the C's order and under the C's locks. The swap uses the rules ported with the transition start and load (child_active,copy_stores,swaps).The C shims go in
obs-source-seam, next to the settings shims, for the reason that crate's README gives. They reach the fields, both mutexes and the render targets only through the transition seam, sostruct obs_sourceis not mirrored. The libobs calls go through a smallCallstrait:Libobscalls the C symbols, and the parity test passes in the oracle's recording stand-ins. The locks are taken where the C takes them. The swap's begin takes both texture locks (the old transition's, then the new one's) and then both transition locks. It releases only the transition locks, and its end releases the texture locks after the render targets move. The enum's callback runs withtransition_mutexheld.The unity group moves from
libobs.core-sourceinto its ownlibobs.ported-source-transition-slots. Its precompiled header isobs-internal.hplus the seam, start and load headers.There are no intentional differences. Kept as the C has it, characterized but not endorsed:
obs_source_get_ref()returns NULL), its slot ends up empty but keeps the old transition's active flag.(no upstream issue)
RED → GREEN
obs-source: Add Tier 1 tests for the slots): 17 of the 18 Tier 1 tests insource::transition_slotsfail on thetodo!()core (the 18th checks constants).--test-diffon it: 6144 run, exactly those 17 failed, 6 skipped.test_source_transition_slots.cplus the hand-over plan, on a fake source graph that counts references and links, records every call and lock in order, and panics on a field touched without the C's lock.transition|swap|stinger|fade_to_color) pass 25/26 on the C build and 30/31 on hybrid libobs and onlibobs-c-reference, with 0 skipped (Xvfb). The one failure on all three builds, C included, istest_stinger_media_duration: the stinger's effect file isn't in that build tree's run directory.obs_transition_enum_sourceslocal.obs_source_add_active_child()andobs_source_remove_active_child(), andobs-tests-corelinks no libobs. The MSVC, MinGW and macOS linkers want every named symbol resolved, sooracle/source_active_child_links.cdefines both for that binary; no test reaches them. Without it, the MinGW build of the test binaries failed to link../unittest: rust-test passes (6432 tests and the 912obs-utilones, all passed, 6 skipped, and the MinGW build), and Tier 2 passes 711/711 on hybrid libobs and onlibobs-c-reference.--lane lintand--lane crosspass every step except Dylint, which has no driver for its nightly on this machine. The Windows clippy on--all-targetsis clean.Test cost: new tests: longest module 0.03 s (the parity tests, all four; 0.016 s with
OBS_PARITY_CASES=reduced), Tier 1 0.01 s, peak RSS 25 MB over 20 runs. No threads of their own; the warning test runs once in a child process.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-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