Skip to content

obs-properties: Port libobs/obs-properties.c - #832

Merged
zackees merged 5 commits into
masterfrom
port/obs-properties-rust
Oct 15, 2026
Merged

zackees merged 5 commits into
masterfrom
port/obs-properties-rust

Conversation

@zackees

@zackees zackees commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Refs #828.

RED (obs-properties: Test the port against todo!() stubs): a new obs-properties crate with C ABI shims for all 109 obs-properties.h exports, over a safe core whose functions are todo!(). Tier 1 aborts on the first stub (todo!("obs-properties port (#828)") in test_common_fields).

  • Tier 1 tests/obs_properties.rs: 1:1 port of test/cmocka/test_obs_properties.c (test: Characterize obs-properties.c before port #830).
  • Tier 2 ENABLE_RUST_LIBOBS=ON drops obs-properties.c; exports in rust-exports.d/obs-properties-obs_properties.txt.
  • Tier 3 tests/parity.rs: random sequences of calls (every export: all add_* types, groups with and without params, removal, setters, list and frame-rate items, callbacks, apply, click) run on Rust and on the original obs-properties.c compiled as oracle_*. After each call it compares every return value, every callback (name, which set, priv, param destroys) and a snapshot that calls every getter on every property in the tree.

GREEN (obs-properties: Port libobs/obs-properties.c): the safe core keeps each set's properties in insertion order as Rc<RefCell<Prop>>; a group owns its content set; parents are Weak links. The C ABI layer calls modified/clicked/destroy callbacks with no RefCell borrowed, so plugin callbacks may look up, change, add and remove properties. obs_property_button_clicked reads the context through the exported obs_obj_get_data, not a mirror of obs_context_data.

Intentional differences (documented in ffi/obs_properties.rs), all where C crashes or leaks: null names and obs_properties_get_parent(NULL) return null; an insert past the end is ignored; neither leak from #831 is reproduced; a set added to two groups is shared, not double-freed.

Local:

  • Tier 1 10/10, Tier 3 parity (512 random sequences + a fixed group/callback sequence) green; ci/local_gate.py --lane rust-test ok (includes the Windows cross build).
  • Tier 2 rust/tools/linux-validate/run.sh: 245/245 OFF and ON, export sets checked.
  • Mutation: dropping the reverse in apply_settings_order fails groups_and_callbacks_match.
  • ./lint ok, including the oracle stand-in check (obs_obj_get_data copied verbatim from obs.c).

One unrelated OFF-build failure on a first local run, test_group_hide_transition_audio ("no program audio was mixed"), passed on rerun; it does not touch this code.

C only, no Rust: test_obs_properties pins creation, every property
type's getters and setters, wrong-type defaults, lookup and removal
through groups, tree-wide unique names, group recursion and clash
checks, list and frame-rate items, buttons, and the modified/
apply_settings callback order. Odd cases are marked characterized, not
endorsed.

Refs #828
New obs-properties crate: C ABI shims for all 109 obs-properties.h
exports over a safe core whose functions are todo!() stubs.
- Tier 1 (tests/obs_properties.rs): 1:1 port of test_obs_properties.
- Tier 3 (tests/parity.rs): random call sequences on Rust and on the
  original obs-properties.c compiled as oracle_*, comparing every result,
  callback and a full tree snapshot after each call.
- ENABLE_RUST_LIBOBS=ON drops obs-properties.c; exports in
  rust-exports.d/obs-properties-obs_properties.txt.

Refs #828
The safe core keeps each set's properties in insertion order as
Rc<RefCell<Prop>>, a group owning its content set, with Weak parent
links. The C ABI layer calls modified, clicked and destroy callbacks
with no RefCell borrowed, so callbacks may change the tree. Lookup,
tree-wide unique names, group checks, apply_settings order and every
getter default follow the C; neither leak from #831 is reproduced.

Refs #828
@zackees
zackees marked this pull request as ready for review October 15, 2026 17:04
@zackees
zackees added this pull request to the merge queue Oct 15, 2026
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

#830 merged; rebased onto master (replaced head 457d0f067 with 457d0f067, only the RED and GREEN commits remain) and dropped the stacked note.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Correction to my previous comment: that rebase did not run (the local branch name it used was gone), so the head stayed 457d0f067. Now actually rebased onto master: replaced head 457d0f067 with 052aae318. The branch is the RED and GREEN commits plus obs-c-oracle: Allow missing field initializers when compiling obs-properties.c, which I kept as is. soldr cargo test -p obs-properties and ./lint pass after the rebase.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Second correction: the rebase push above was rejected because this PR is already in the merge queue, so the head is still 457d0f067 (#830's two commits, already on master, plus RED, GREEN and obs-c-oracle: Allow missing field initializers…). No rebase is needed: the queue squash-merges the net diff against current master. Sorry for the noise.

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.

1 participant