Skip to content

obs-source: Port the source rename - #4860

Merged
rdoupe merged 4 commits into
masterfrom
fix/rust-port-port-the-source-rename-840
Nov 14, 2026
Merged

rdoupe merged 4 commits into
masterfrom
fix/rust-port-port-the-source-rename-840

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4857

What and why

Ports the source rename, obs_source_set_name() in libobs/obs-source-set-name.c.h, to obs-source::set_name. The C was extracted and characterized in #4643 (test/cmocka/test_source_set_name.c); this swaps it in hybrid libobs.

  • The safe core keeps the original order: the NULL check with its debug line; the unchanged-name check, where a NULL or empty request or a NULL current name always renames; the canvas rename (obs_canvas_rename_source()) for a public source that requires a canvas; otherwise the table path. There the previous name is copied before the rename, the context is renamed through the public source table (with no table for a private source), new_name is the context's name read after the rename, privacy is read again before the global source_rename, the local rename always follows, and the payload and the copy are freed after both signals. A private scene that knows its canvas takes the table path, as in C.
  • C keeps the source and context layouts, the name tables, the canvas rename and signal delivery behind a live adapter, libobs/obs-source-set-name-fields.c.h (in core-source+, the obs-canvas-set-name-fields.c.h shape), one read or one call per function. No Rust borrow of context.name spans a C call, and the port adds no lock: the table call takes its own, as before.
  • The shim exports obs_source_set_name (rust-exports.d/obs-source-source_set_name.txt); the original file moves into its own ported group, libobs.ported-source-set-name+, registered in ported-source-sets/source-set-name.json, so the C reference keeps it unchanged.

No intentional differences from C.

The audio-pause callbacks, planned next to this one, are not in this PR: issue #4375 already has a branch with that port.

RED → GREEN

  • RED commit: bfad6c4. soldr cargo test -p obs-data --test obs-tests-core -- source::set_name:: fails 9/9 Tier 1 tests on the todo!() core (not yet implemented: obs_source_set_name): the five test_source_set_name_* ports and the NULL, empty, unnamed, non-UTF-8 and NULL-source cases. On that commit --test-diff fails exactly those 9 (7911 passed, 6 skipped) and the lint lane passes.
  • GREEN: runs were on 1ca2ab3.
    • Tier 1 and Tier 3: 9/9 Tier 1 and 3/3 parity tests. The Tier 1 model stands in for what stays in C as the C test sees it (the public source table, the canvas source table, and the canvas rename with its source, canvas and main-canvas-only core signals), so each test_source_set_name.c case asserts the same handler order (GL, L, LCG, LC, L), payloads, published name, lookups and unchanged-name checks. Tier 1 alone also catches the eight core mutants below. The parity test runs the unchanged extracted C and the Rust ABI over the real private source layout through the production adapters, with tracing stand-ins for the canvas rename, the context setters and signal delivery. It compares every call with its name, every signal with its handler and payload, and the final name and privacy, for NULL, empty, equal, occupied, long and non-UTF-8 names, any output flags, private sources, a table setter that flips privacy and a callback that edits the payload; a NULL source writes the same debug line. Eight planted mutants in the core (privacy not read again, signals swapped, payload built before the rename, canvas path for private scenes, empty names compared, a NULL current name kept, no global signal, tables swapped) are each caught.
    • Tier 2 (ctest -R 'source|scene|canvas|context|missing_files|hotkey', under Xvfb): C 195/197, hybrid 218/221, c-ref 218/221, 0 skipped. test_source_set_name, test_context_names, test_canvas_rules_callers and the two hotkey tests that failed in the parallel run pass on all three when run alone (they race for xvfb-run -a displays under -j8). test_source_audio_settings times out on all three, plain C included, because the test host has no sound server.
    • Exported symbols identical on C, hybrid and c-ref (1768); the adapter functions are local (t) in each, and hybrid's obs_source_set_name calls the Rust core.
    • Every cmocka test builds and links on C and hybrid; ci/windows_link_check.py passes.
    • ./unittest: Rust 8524/8524 (6 skipped) and 916/916; Tier 2 in Docker 932/932 against hybrid libobs and libobs-c-reference (2 vivid tests skipped on each).
    • ci/local_gate.py --test-diff: 8508/8508 passed, 6 skipped (before the rebase onto current master; ./unittest above ran after it). --lane lint, --lane dylint, --lane cross ok; clippy --target x86_64-pc-windows-msvc --all-targets -D warnings clean.
  • Real app (UI, protocol output or logging changes): not applicable, no change in behaviour.

Test cost: new Rust tests: longest 0.02 s (the random parity test), peak RSS 10.6 MB over 20 runs with OBS_PARITY_CASES=reduced, no own threads (the NULL-source log check re-execs one child, as the other log probes do).

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)
  • 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: no warning or flag changes)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (none)

@rdoupe rdoupe changed the title obs-source: Test the source rename obs-source: Port the source rename Nov 14, 2026
Port test_source_set_name.c 1:1 to Tier 1 tests in the core category
binary, against a todo!() core in obs-source::set_name. The model
source stands in for what stays in C as the C test sees it: the
public source table, the canvas's source table, and the canvas
rename, which signals the source, the canvas and, on the main canvas
only, the core handler.

Each case asserts the C test's handler order (GL, L, LCG, LC, L),
every handler's payload with the new name already published, the
lookups after the rename and the unchanged-name checks. Add the
NULL, empty, unnamed and non-UTF-8 name edges, the NULL source's log
line, and the order of every read and call.

Refs #4857.
Port obs_source_set_name() to obs-source::set_name. The safe core
keeps the original order: the NULL check with its debug line, the
unchanged-name check (a NULL or empty request, or a NULL current
name, always renames), the canvas rename for a public source that
requires a canvas, and otherwise the table rename with its signals:
the previous name is copied before the rename, new_name is the
context's name after it, privacy is read again before the global
source_rename, the local rename always follows, and the payload and
the copy are freed after both.

C keeps the source and context layouts, the name tables, the canvas
rename and signal delivery behind the live adapter
obs-source-set-name-fields.c.h, one read or call per function. The
shim exports obs_source_set_name; the original file moves into its
own ported unity group for the C reference.

Refs #4857.
Compile the unchanged extracted setter and the production adapters
over the real private source layout, with tracing stand-ins for the
canvas rename, the context setters and signal delivery. Fixed and
random cases compare every call with its name, every signal with its
handler and payload, and the final name and privacy: NULL, empty,
equal, occupied, long and non-UTF-8 names, any output flags, private
sources, a table setter that flips privacy and a callback that edits
the payload. A NULL source writes the same debug line.

Planted mutants in the core (privacy not read again, signals
swapped, payload built before the rename, canvas path for private
scenes, empty names compared, NULL current name kept, no global
signal, tables swapped) are each caught.

Refs #4857.
Add the rust/README.md row for obs-source::set_name, and name the
port in the crate's Cargo.toml description and lib.rs module docs.

Fixes #4857.

Local-Gate: v1 tree=128b6f029b9c1b7dc80f215b643b2cee92d83d4b secs=2545 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a,client-checks:run,client-swift:n/a,client-lint:run,client-test:run,client-test-x86_64-unknown-linux-gnu:run,client-test-aarch64-unknown-linux-gnu:n/a,client-test-x86_64-pc-windows-msvc:n/a,client-test-aarch64-pc-windows-msvc:n/a,client-test-x86_64-apple-darwin:n/a,client-test-aarch64-apple-darwin:n/a
Ci-Attestation: {"at":1794659024,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7966adbb057092a1f36199833b76b0e965fae791b180c7deef559f5ea5c18c1d","lane":"lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":63,"stamp":"0a0e1235b0fd3cedc84c18b0621fecce","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7966adbb057092a1f36199833b76b0e965fae791b180c7deef559f5ea5c18c1d","lane":"lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":63,"stamp":"b5f19507104cb638b9c83d916f5e9689","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"6b959e52b9429f9ff0a111e737208c99d08d885cf52412aa607eff02a0fdc891","lane":"dylint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":0,"stamp":"a9c25575d3be5b9e4150a3ec7ad0b073","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"dda38f4afd5b2dd0113af01e6f13d83df678f62da4f69e3007107575a499d535","lane":"rust-test","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":204,"stamp":"f3eb05935584651b6c1b73d3cf272fe7","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"b93edb872e845fb47d693c8057aec81e7757d25ab7e8fc8bd0ca2872502968ba","lane":"cross","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":79,"stamp":"1a8b6e0f704c33d0a0c8b635756665fd","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"b93edb872e845fb47d693c8057aec81e7757d25ab7e8fc8bd0ca2872502968ba","lane":"cross","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":79,"stamp":"23148dc9ec22d46914de44672ca2dded","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"b93edb872e845fb47d693c8057aec81e7757d25ab7e8fc8bd0ca2872502968ba","lane":"cross","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":79,"stamp":"99d71bada0d1408ced7806b5fe2dd80c","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"b93edb872e845fb47d693c8057aec81e7757d25ab7e8fc8bd0ca2872502968ba","lane":"cross","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":79,"stamp":"44be866d8eac15f4dd3db7ec4b263a3d","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"04c51e3b965232af64e64c7a091f4cbfc8a777fb237c0440ef0358f8633af0ab","lane":"tier2-linux","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":2545,"stamp":"9c962708b86c2f2f72d7620842e7c4a8","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"python/all/self-test","host":"linux-x86_64","key":"becbe960dad8c700fc9febba541f3cae522d5d52177dff0d3d45d49b499f3158","lane":"client-checks","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":55,"stamp":"55055ed7687597959c88c038b3a63573","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"general/all/client-lint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"7dad8510aaaa542f76ebadbeb854c09d","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"7cb2bd12f4b7510559fdb1c096850c70","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"da330069619f43cbdd9b70b7d2952602","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"0b444de745c4c3f36947beef83672bb7","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"6f281cad723bf4833a0554e3c3b8ea1c","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"da59ce66aab013b3b8be3295981562dd","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"870fda1369db0219c0ae74da6137e2c8","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"447cc2eecbb807ae63909b6416c4dbaf","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"6bc82f5e9654e5ceab7da5acf8c493f7","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"b0984690d86bde19d9b2d5763e6270e6","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"f5c9ab34c614823055c5ebf11315b0dd","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"fe8a9d585c6623a764c1e2600259978e","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e9630370e0eb5e205a1d00023be6ad3588dbb115ccfc96b0a35d0476fee50ef6","lane":"client-lint","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":50,"stamp":"8763ed6eec999a66edcf270d62a17826","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
Ci-Attestation: {"at":1794659024,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"86b0f0bf2ec8ed6e718355c4245f8decac53a59ce7d4d9d9628d7992df6e39ad","lane":"client-test-x86_64-unknown-linux-gnu","parents":["4ce7618b0c902868dc9c9a3a88d152c5b36deac2"],"secs":298,"stamp":"1f50541332afbbf86267a661eb706574","tree":"128b6f029b9c1b7dc80f215b643b2cee92d83d4b","v":1,"via":"run"}
@rdoupe
rdoupe force-pushed the fix/rust-port-port-the-source-rename-840 branch from 05cee19 to 1ca2ab3 Compare November 14, 2026 12:24
@rdoupe
rdoupe marked this pull request as ready for review November 14, 2026 13:03
@rdoupe
rdoupe requested a review from zackees as a code owner November 14, 2026 13:03
@rdoupe
rdoupe added this pull request to the merge queue Nov 14, 2026
@rdoupe

rdoupe commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

Handed off to the coordinator

@obs-rust-project-manager obs-rust-project-manager Bot moved this to In merge queue in obs-rust Multiview Nov 14, 2026
@vpacher vpacher mentioned this pull request Nov 14, 2026
5 of 7 tasks
Merged via the queue into master with commit d762f20 Nov 14, 2026
42 checks passed
@rdoupe
rdoupe deleted the fix/rust-port-port-the-source-rename-840 branch November 14, 2026 16:05
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In merge queue to Done in obs-rust Multiview Nov 14, 2026
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 source rename to obs-source

1 participant