Skip to content

libobs: Move the transition start and set - #3820

Merged
rdoupe merged 2 commits into
masterfrom
fix/rust-port-extract-transition-sta-652
Nov 7, 2026
Merged

rdoupe merged 2 commits into
masterfrom
fix/rust-port-extract-transition-sta-652

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3794

What and why

The "Extracting a function before porting it" step for the transition start and set of libobs/obs-source-transition.c.h. There is no Rust and no change in behaviour; the port to rust/obs-source / obs-source-seam comes next.

  1. Characterization (test: Characterize the transition start and set): test/cmocka/test_source_transition_switch.c, 9 cases through the real libobs, registered in test/cmocka/build/test-graph.json (suite graphics, Linux with OpenGL, like the other transition tests) with its tests.d note.
  2. The move (libobs: Move the transition start and set): the start clock (struct transition_start_clock, write_start_clock()), set_source(), activate_transition(), the recursion check (struct transition_recursion_check, check_transition_recursion()), obs_transition_start() and obs_transition_set() move verbatim (origin/master lines 81-331) into libobs/obs-source-transition-switch.c.h. The ported start rules already have obs-source-transition-start.c.h, so this file is -switch. It is live C in libobs.core-source, ahead of obs-source-transition.c.h in the group's sorted order, with its own lock_transition / unlock_transition, #undef'd at its end (BUILD.md rule 5). Nothing outside the moved lines calls the four static helpers; obs_transition_set_manual_time() and obs_transition_start() still call obs_transition_set() through its public symbol. obs-source-transition.c.h loses 252 lines.

No source-set or naming.md entry is needed: the new file is a .c.h in an existing unity group (only headers are listed in source-sets.d/LIBOBS_SOURCES.json), and naming.md's obs-source*.c.h row already covers it; the port adds it to that row's list of seam shims.

Characterization. test_transition_start_steps pins the start rules on plain values and copies of the composition on a stand-in, and test_transition_recursive_destination, test_transition_set_active and test_transition_set_cycle pin the recursive destinations, the re-entering callbacks' clocks and the set's active reference. The new test pins the rest through the real libobs, with a transition type that counts its transition_start callback and handlers counting transition_start / transition_stop on the transition and source_transition_start / _stop on the core's handler (which hears only a public source, so the transition is a public one):

  • a start from idle; to slot A's source while idle (refused, as is a start to nothing with slot A empty); to it while running: the running transition ends on its destination (a stop signal), which becomes slot A, and the start goes back;
  • the running destination again, in either mode: the running transition ends there and the start is refused. A manual start to a running manual transition's destination is therefore refused too, never "done with nothing called" (characterized, not endorsed); a start to no destination;
  • the fixed duration replaces the one asked for, only while enabled;
  • a transition_start callback that starts the transition again: the nested start runs whole, then the outer destination wins;
  • obs_transition_set(): both slots cleared, the source in slot A, a stop signal only while running, and the refusal of the transition itself with its warning;
  • on an output channel, which children are active after each start and set.

Checked against origin/master's functions. A scratch harness (not committed) builds master's lines 81-331 with the lock macros, and the new file whole, each as its own program over one logging stand-in for struct obs_source and every call they make: the start rules (scripted results), refs and releases, the active child calls (scripted results), the recursion walk (scripted parent and child pairs, the transition among them), transition_valid() and transition_active(), the size and matrix recalculations, os_gettime_ns(), the signals, the logs, each lock (double locks flagged), and a plugin callback that re-enters the start or set. The program dumps every field of six sources after each call. The logs of 20,000 rounds of 12 random calls (243,069 calls with the re-entries) are byte-identical under gcc and clang at -O0, at -O2, and at -O1 with ASan and UBSan. All 25 planted mutants are caught, in the clock write, each slot read and write, the active flags, the active child calls, the releases, the recursion check, the mode, manual and fixed-duration writes, the signals and the lock around the first read.

The move commit is byte-identical to the text it replaces (checked with cmp).

RED → GREEN

  • RED commit: none, by design. This is a behaviour-neutral move: testing-policy.md's "Extracting a function before porting it" step, a separate commit with no Rust and no behaviour change, whose proof is that the unchanged C tests pass. The characterization test pins current C behaviour, so it passes before the move as well ("Characterization tests for units without C tests"). RED and GREEN come in the port that follows, as with the earlier transition moves (libobs: Move the transition settings and slots #3537, libobs: Move transition sizing, load and getters #3588).
  • GREEN: runs were on b03075e (the stamped head; e5848e423 before the stamp, same tree), rebased on current master, unless noted.
    • The transition tests pass on all three builds, none skipped: C 26/26, hybrid 31/31, libobs-c-reference 31/31.
    • The fixed-duration case waits for a video frame 400 ms after the start before it reads the disabled transition's time; with the fixed duration applied while disabled (planted in libobs), fixed_duration_replaces_the_asked_one fails.
    • Before the rebase (runs were on f02d2cef3): test_source_transition_switch passed 9/9 on the C, hybrid and libobs-c-reference builds, before the move and after it, under Xvfb with none skipped, and 15/15 repeated runs.
    • Before the rebase, the transition, scene and source tests (98 on the C build, 127 on hybrid and C reference) pass after the move, except test_source_audio_settings and test_source_monitor_only_load, which hang to their timeout on this machine's sessions without a sound server on every build; neither calls a transition function.
    • The export sets of the C, hybrid and C reference builds are unchanged (1767). obs_transition_start and obs_transition_set stay exported (T); activate_transition and check_transition_recursion are local (t), set_source and write_start_clock are inlined, as before.
    • The export sets of the C, hybrid and C reference builds are still identical after the rebase (1767).
    • Local gate, ci-lint local-gate run: lint, rust-test, cross and Tier 2 on Linux (tier2-linux) passed, and HEAD is stamped; the macOS and Windows native lanes do not apply on this host. The quick ci/ checks, ./lint, --lane cross, the Windows --all-targets clippy and the port_comparison bench pass. No Rust changed.
    • One earlier ./unittest run hit effect_parser_writer_parity::called_functions with a random proptest case. That is master's writer parity test, already filed as bug: obs-graphics: writer parity test feeds a dstr with a NUL #3802, not this change; the stamp's rust-test lane then passed.
  • Real app (UI, protocol output or logging changes): N/A, no behaviour change.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together). Here: the characterization test, then the move; no RED, see above.
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: no port)

Characterization before obs_transition_start() and obs_transition_set()
of obs-source-transition.c, with set_source(), activate_transition()
and the recursion check, move to their own file and are ported.
test_transition_start_steps pins their rules on plain values and copies
of the composition on a stand-in; the recursive destination and set
tests pin the recursion refusals, the re-entering callbacks' clocks and
the set's active reference. Nothing pinned the rest through the real
libobs.

test_source_transition_switch creates transitions through the real
libobs, with a transition type that counts its transition_start
callback and a handler counting the start and stop signals (on the
transition and on the core's handler, which hears only a public
source). 9 cases pin:
- a start from idle; one to slot A's source while idle (refused, and
  with an empty slot A a start to nothing); one to it while running
  (the running transition ends on its destination, then starts back);
- the running destination again, in either mode: the running
  transition ends there and the start is refused, so a manual start
  is never done with nothing called (characterized, not endorsed); a
  start to no destination;
- the fixed duration replacing the one asked for, only while enabled;
- a transition_start callback that starts the transition again: the
  nested start runs whole, then the outer destination wins;
- obs_transition_set(): both slots cleared, the source in slot A, a
  stop signal only while running, and the refusal of the transition
  itself with its warning;
- on an output channel, which children are active after each start
  and set.

Transitions need core video, so it builds on Linux only and runs
under xvfb-run; without a display the cases skip.

Refs #3794.
The start clock (struct transition_start_clock and
write_start_clock()), set_source(), activate_transition(), the
recursion check (struct transition_recursion_check and
check_transition_recursion()), obs_transition_start() and
obs_transition_set() move verbatim from obs-source-transition.c into
their own file, obs-source-transition-switch.c, ahead of their port to
rust/obs-source. The ported start rules already have
obs-source-transition-start.c, so this file is -switch.

It is live C in the libobs.core-source group, ahead of
obs-source-transition.c in the group's sorted order, with its own copy
of lock_transition() / unlock_transition(), #undef'd at its end
(BUILD.md rule 5). Nothing outside the moved lines calls the four
static helpers; obs_transition_set_manual_time() and
obs_transition_start() call obs_transition_set() through its public
symbol, as before. The moved text is byte-identical to the text it
replaces.

No behaviour change: the export sets of the C, hybrid and C reference
builds are unchanged.

Refs #3794.

Local-Gate: v1 tree=ff1b7bf549c4765f6c304f781bb9722aa3cbc7df secs=2472 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794029158,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f3a60aadd6f9865585e963263ce83ff037c4d3cde4d0b8af377e92d52f210a5f","lane":"lint","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":62,"stamp":"0963ac59a2a2c0761c3610b618459094","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f3a60aadd6f9865585e963263ce83ff037c4d3cde4d0b8af377e92d52f210a5f","lane":"lint","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":62,"stamp":"a5512c8b5ff8d36f18a9a5f4213d8bb9","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0c0086e991069a02b1d9b70dff4923b9a7ec09b315f6c3c559ec3205f1d29fa5","lane":"rust-test","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":259,"stamp":"c97e6a665ebedebfd9010cf095e54e72","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"049ac2020bf52efd3742309ba2c4c22778de8c2feabccc2beba820219bbeb7f8","lane":"cross","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":40,"stamp":"b3abb656a1ee90da098d4fe4ef1c68f7","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"049ac2020bf52efd3742309ba2c4c22778de8c2feabccc2beba820219bbeb7f8","lane":"cross","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":40,"stamp":"cda3acf969cdba132e729294921a2e38","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"049ac2020bf52efd3742309ba2c4c22778de8c2feabccc2beba820219bbeb7f8","lane":"cross","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":40,"stamp":"fdf5aba497664313a76cef01ce3c120f","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"049ac2020bf52efd3742309ba2c4c22778de8c2feabccc2beba820219bbeb7f8","lane":"cross","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":40,"stamp":"81f682d48919387a28baefbe7614db97","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
Ci-Attestation: {"at":1794029158,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f1c5d65643366eba59c38f9ea4620983ff7e631d3963d444deb9707218e7729a","lane":"tier2-linux","parents":["d446ae92c312e7ffa538ac8264685fa5241fecf6"],"secs":2472,"stamp":"de0e107b49e86d23148e1408ea84027e","tree":"ff1b7bf549c4765f6c304f781bb9722aa3cbc7df","v":1,"via":"run"}
@rdoupe
rdoupe requested a review from zackees as a code owner November 7, 2026 05:26
@rdoupe
rdoupe added this pull request to the merge queue Nov 7, 2026
@rdoupe

rdoupe commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Handed off to the coordinator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port the transition start and set (move them out of obs-source-transition.c)

1 participant