Skip to content

obs-scene: Port the scene item order rules - #2899

Merged
rdoupe merged 11 commits into
masterfrom
fix/rust-port-scene-item-order-reord-254
Oct 29, 2026
Merged

rdoupe merged 11 commits into
masterfrom
fix/rust-port-scene-item-order-reord-254

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2895

What and why

Ports the scene item order, reorder and group membership decisions of libobs/obs-scene.c.h to rust/obs-scene, as a new module item_order, next to item_names, group_transform and transform_update (#2874). Move Up/Down/Top/Bottom, every drag in the source tree (obs_scene_reorder_items2()), obs-websocket's item index (obs_sceneitem_get_order_position(), obs_sceneitem_set_order_position()) and every group add and remove go through them. The design is #2874's: C keeps the locks, the walks and every link write, and asks the core each decision where it made it.

Six commits, then the review fixes (below):

  1. Move (behaviour-neutral): the decisions go to libobs/obs-scene-item-order.c.h, behind eight functions (ten after the review fixes) declared in the new obs-scene-item-order.h without EXPORT (hidden):
    • obs_scene_item_order_anchor(movement, has_prev, has_next): where obs_sceneitem_set_order() puts the item back (after prev->prev, next, prev or the last item, the bottom, or nowhere for a movement outside the enum). It is asked before the detach, from the neighbours C reads there.
    • obs_scene_item_order_position(position, has_first, &steps): the bottom for position 0 or an empty scene, else position - 1 steps (none for 1 or a negative position). C's walk from the first item stops at the last item, as before.
    • obs_scene_item_order_item_attached(has_item, has_parent): the item check of obs_sceneitem_get_order_position() and obs_sceneitem_group_ungroup2(). The C has none.
    • obs_scene_item_order_match_item(): the inner loop of sceneitems_match() for obs_scene_reorder_items().
    • obs_scene_item_order_reorder_check() and obs_scene_item_order_group_run_end(): the compare of sceneitems_match2() (now sceneitems_check2(), which still builds and frees build_current_order_info()'s pairs) and the end of each group's run in obs_scene_reorder_items2().
    • obs_scene_item_order_add_item_allowed() and obs_scene_item_order_remove_item_allowed(): the parent checks of obs_sceneitem_group_add_item() and obs_sceneitem_group_remove_item(). The C has none for the remove.
    • obs-scene.c.h keeps every full_lock, scene reference, list walk, prev/next/first_item/parent write, move_would_recurse(), the group transforms, resize_group(), the hotkey moves, every signal and every log, in their order. The pointers are only compared, never followed.
    • Checked against the unchanged functions. A scratch harness (not committed) compiles origin/master's ten functions and their helpers verbatim, and the moved ones, over a stand-in scene that logs every lock, reference, signal, group transform, resize, active-child move, hotkey move, recursion check and log, then dumps every scene's list and every item's links after each call. It ran every item of lists of 0-6 items for 16 movements and positions (including the int ends and the detached item), plus random scenes with groups and a foreign scene under all ten calls, with flat and pair orders that are rearranged, rebuilt into other groups, cut, repeated, extended with foreign items, regrouped and emptied. That is 1,001,120 calls with identical logs and dumps under gcc and clang, -O0 and -O2, with and without ASan/UBSan. Six planted mutants all differ: an up move to the bottom, a walk one step too far, a match that never clears, a size mismatch taken as the same order, a run one short at the end, and a caller that skips the entry after a run.
    • The file stays in libobs.core-source for this commit. Exports unchanged (1766).
  2. Characterization: test_scene_item_order_steps, 15 cases (16 after the review fixes) on the moved file alone (ASan and UBSan): the anchors for every neighbour pair and a list model of each movement at the bottom, middle and top and with one item; the bottom and steps of each position and a model of the walk; the match step and a model of the flat refusal (same order, permutation, missing, extra and repeated items); the pair check and the group runs; the add and remove gates.
  3. RED: Tier 1 in the crate, against todo!().
  4. GREEN: the safe core and the #[no_mangle] shims, in a new libobs.ported-scene-item-order group whose PCH is the header alone. The export lists, source-sets.json, the unity lists and ci/test_ported_sources.py are updated, and test_scene_item_order_steps_rust runs the unchanged characterization against the shims. The shims read struct obs_sceneitem_order_info in place (mirrored as OrderInfo) and compare by address. obs-scene.c.h checks enum obs_order_movement's values and the pair's size at compile time.
  5. Tier 3: a C oracle and parity tests, with the mutation check.
  6. Docs: the README rows, the crate's description and lib.rs, and a port_comparison bench file. docs/rust-port/naming.md already maps libobs/obs-scene*.c.h to rust/obs-scene.

Review fixes (five more commits; RED 5230504fc, GREEN 4e0525ca3):

  • The group run is asked one entry at a time. Commit 1 computed the whole run before full_lock(sub_scene). obs_scene_item_order_in_group_run(order, size, head, index) replaces obs_scene_item_order_group_run_end(). It is asked at the top of each inner-loop iteration, inside the group's lock and after the entry before it was moved, which is exactly where the C compared sub_info->group.
  • The add gate compares in order. obs_scene_item_order_add_item_allowed(parent, scene, group_scene) takes the item's parent and the two scenes. It compares with the group's scene only after the parent matched the parent scene, as the C did, instead of the caller evaluating both comparisons as arguments.
  • move_active_child()'s gate (in rust: Port the scene item order and group membership rules in obs-scene.c to obs-scene #2895's scope) is now two steps, obs_scene_item_order_moves_scene() and obs_scene_item_order_item_active(), so active_refs is still loaded only once the scenes differ.
  • The new export-list entries are sorted in rust-exports.map, rust-hidden.txt and rust-unexports-macos.txt. There are ten functions now.
  • The move harness was rerun with move_active_child() taken verbatim from both files (its atomic load logged) and the orders on the heap at their exact size: 1,001,120 calls with identical logs and dumps under gcc and clang, -O0 and -O2, with and without ASan/UBSan. Five new mutants are caught: the load before the scene check, a run against the head's group, an inactive count taken as active, a same-scene move, and a read one past the order (ASan).
  • test_scene_item_order_steps now has 16 cases (one new for the active-child gates). The RED commit fails 6 of 29 Tier 1 cases with "not yet implemented" (the four changed functions; the other 23 pass). GREEN passes 29/29 and Tier 3 12/12. An in-run compare against the head's group, an add gate without its second check, an inactive count taken as active and a same-scene move each fail parity.
  • item_active() takes std::ffi::c_long, so the shim converts nothing (clippy's useless conversion on Linux, needed on Windows).

Not changed: obs_scene_insert_group()'s item gate and obs_scene_get_group()'s name match stay C. #2895 doesn't list them. Each is one compare whose second operand the C reads only after the first passes (item->is_group after item->parent != scene; strcmp(), a call that stays C, after is_group and the name check). Split as the rule requires, each would be a Rust function returning one == or &&, with no decision of its own. obs_scene_insert_group()'s items[count - 1] read is also left to its own fix.

Intentional differences (fixes, found by reading; none reported by a user; upstream OBS has each one). The C keeps its behaviour in libobs-c-reference and the C backend. Each is listed in the parity test header and in rust/README.md, and the parity test asserts each one exactly:

  1. obs_sceneitem_set_order() with a movement outside the enum detached the item and never attached it again, so the item vanished from the scene while still holding its references. The anchor is now OBS_SCENE_ITEM_ORDER_ANCHOR_STAY, and the caller unlocks and returns before the detach: the item stays where it was and nothing is signalled.
  2. obs_sceneitem_get_order_position() and obs_sceneitem_group_ungroup2() read item->parent before any check, and the getter locked a NULL scene for a detached item. A NULL or detached item now gives 0, or returns.
  3. obs_scene_reorder_items2() relinked any order that differed from the current one. A left-out item was unlinked while its parent still named the scene, so a later remove followed stale links, and a repeat or an item from another scene was linked in. An order whose items are not exactly the scene's items (top level and in groups), each once, is now refused (OBS_SCENE_ITEM_ORDER_INVALID). obs_scene_reorder_items() already checks this for flat lists. The frontend's source tree always passes every item, collapsed groups included, so its drags are unchanged.
  4. obs_sceneitem_group_remove_item() didn't check that the item is in the group: a top-level item, or one from another scene, lost the group's transform and moved to the group's parent scene. It now stays where it is. The frontend calls it only with the item's own group.

Kept, characterized, not endorsed: a negative position goes after the first item; a sub-item that doesn't follow its group's entry goes to the top level, and so does everything after it; the add gate's second check (already in the group's scene) can never decide, because an item has one parent.

Notes:

  • obs_scene_insert_group() reading items[count - 1] with a non-NULL items and count 0 is left to its own fix. This PR doesn't touch that line.
  • Exported symbols: 1766 on the C backend, the hybrid and libobs-c-reference, the same set as origin/master. The ten functions are local (t) in all three. In the hybrid they come from the Rust archive, and in the C backend and libobs-c-reference from libobs.ported-scene-item-order+.h.c.
  • Performance (port_comparison, x86_64 Linux, GCC, not pinned; median): a 16-entry reorder2 check with two groups, its two group runs (one entry at a time) and every anchor take 94.9 ns in Rust and 36.9 ns in C. The difference is fix 3: the Rust check sorts two copies of the items to validate the order, which the C never did. This runs once per drag.
  • The four fixes are user-visible to scripts and plugins, so docs/features.md gets one line under Fixed upstream bugs, Scripting.

RED → GREEN

  • RED commit: ce4d66004. soldr cargo test -p obs-data --test obs-tests-core scene::item_order:: fails 28 of 28 with "not yet implemented": the 15 ported steps_* cases and 13 edge_* cases, 8 of them proptests. On it, --lane lint passed, and uv run ci/local_gate.py --test-diff origin/master ran 4954 tests: 4926 passed, those 28 failed, 6 skipped (run before a clang-format fix to the characterization's C file, which no Rust test reads).
  • GREEN: 71ffd3cc5. Tier 1 passes 28/28. With Tier 3 (9507e6640), 40/40. After the review fixes (GREEN 4e0525ca3): 29/29, and with Tier 3, 41/41.
  • Mutation check: an up move without a next to the bottom, a position one step too far, a check that accepts any order, a run that takes any grouped entry, and a match that never clears each fail the parity tests (1 or 2 of the 12 each).
  • Tier 2 ran under a private Xvfb -noreset with dbus-run-session, a fresh HOME, ulimit -c 0 and TMPDIR unset, with 0 skipped. libobs-c-reference was built with ninja libobs-c-reference and is newer than the last C change, and the C-reference runs load it (checked with ldd):
Test C backend hybrid libobs-c-reference
test_scene_item_order_steps 16/16 16/16 16/16
test_scene_item_order_steps_rust (not built: needs the Rust archive) 16/16 16/16
test_scene_list_remove, test_scene_enum_items_removal, test_scene_canvas_characterization, test_scene_group_transform, test_scene_dup_group_children, test_scene_duplicate_scale_ref, test_visibility_transition pass pass pass
test_group_recursion, test_group_child_drift, test_group_teardown_uaf, test_group_active_refs, test_group_empty_bounds pass pass pass
focus set total 13/13 14/14 14/14
  • Gates on the head: uv run ci/local_gate.py --test-diff origin/master ran 4967 tests, 4967 passed and 6 skipped by nextest's own filters; --lane lint and --lane cross passed; soldr cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets --locked -- -D warnings is clean; soldr cargo test -p obs-c-oracle --locked --bench port_comparison passes its per-module allocation check.
  • Runs were on 51c908ee3, based on f8ced38a1 (origin/master at the push): the quick ci/ checks, ./lint, ./unittest (Rust lanes 4968 and 845 passed, 6 skipped; its Docker Tier 2 lane can't reach Docker on this host), --lane lint, --lane cross, the Windows clippy, the bench test, the export comparison and the Tier 2 focus set above, natively. Earlier runs, before the rebase onto f8ced38a1 (which touched none of these files), are the ones counted under the review fixes.
  • Real app (UI, protocol output or logging changes): N/A, a port with no UI, protocol output or log change. The fixes are covered by Tier 1 and Tier 3.

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 (not stamped: the gate's Tier 2 lane needs Docker, which this host's user can't reach; lint, rust-test and cross passed in it)
  • Warning or flag changes (-W..., ratchets): not applicable, none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

rdoupe added 11 commits October 29, 2026 06:23
Behaviour-neutral extraction before the Rust port. The order, reorder
and group membership decisions of obs-scene.c.h move to
libobs/obs-scene-item-order.c.h, as eight functions on plain values
declared in the new libobs/obs-scene-item-order.h without EXPORT
(hidden, as -fvisibility=hidden keeps them):

- obs_scene_item_order_anchor(): where obs_sceneitem_set_order() puts
  the item back (after prev->prev, next, prev or the last item, at the
  bottom, or nowhere for a movement outside the enum);
- obs_scene_item_order_position(): the bottom test and the walk length
  of obs_sceneitem_set_order_position();
- obs_scene_item_order_item_attached(): the item check of
  obs_sceneitem_get_order_position() and obs_sceneitem_group_ungroup2()
  (none in C: both read item->parent whatever they are given);
- obs_scene_item_order_match_item(): the inner loop of
  sceneitems_match();
- obs_scene_item_order_reorder_check() and
  obs_scene_item_order_group_run_end(): the compare of
  sceneitems_match2() (now sceneitems_check2()) and the end of the
  group run in obs_scene_reorder_items2();
- obs_scene_item_order_add_item_allowed() and
  obs_scene_item_order_remove_item_allowed(): the parent checks of
  obs_sceneitem_group_add_item() and obs_sceneitem_group_remove_item()
  (none in C for the remove).

obs-scene.c.h keeps every lock, scene reference, list walk, link write,
build_current_order_info() and its free, move_would_recurse(), the
group transforms, resize_group(), the hotkey moves, every signal and
every log, in their order. The pointers are only compared.

Checked against the unchanged functions with a scratch harness that
compiles origin/master's functions and the moved ones over a stand-in
scene that logs every lock, reference, signal, transform, hotkey move
and recursion check, and dumps every list and link after each call:
1,001,120 calls with the same logs under gcc and clang, -O0 and -O2,
with and without ASan and UBSan. Six planted mutants all differ.

The file stays in libobs.core-source for this commit. Exports are
unchanged (1766).

Refs #2895.
test_scene_item_order_steps builds the moved
libobs/obs-scene-item-order.c.h into itself (ASan and UBSan) and calls
its eight hidden functions, 15 cases:

- the anchor of each movement for every pair of neighbours, and a
  model of obs_sceneitem_set_order() on a list: each movement at the
  bottom, in the middle and at the top, and a single item that stays;
- the position: 0 and an empty scene go to the bottom without writing
  the steps; position - 1 steps otherwise, up to INT_MAX; a negative
  position takes no step, so the item goes after the first item
  (characterized, not endorsed); and a model of the caller's walk,
  which stops at the last item;
- the match step of obs_scene_reorder_items() (found at its index,
  found elsewhere, missing, an empty order, a repeat counted at its
  first entry) and a model of the refusal: the same order, a
  permutation, a missing, an extra and a repeated item;
- the reorder2 check (the same pairs, an empty scene, the top level,
  inside a group, items moved in and out of a group) and the group
  runs (a run, one that ends the order, an empty group, and a
  sub-item that does not follow its group, which ends the run and
  goes to the top level: characterized, not endorsed);
- the add gate, whose second check can never decide in libobs, since
  an item has one parent (characterized, not endorsed), and the item
  and remove checks for an attached item in the group.

The C has no check for a movement outside the enum, a NULL or detached
item, a reorder2 order that is not the scene's items rearranged, or a
remove of an item that is not in the group: libobs reads past a list
or through NULL there, so those inputs are not pinned.

Refs #2895.
Tier 1 for the new obs_scene::item_order module, against todo!()
stubs of its safe API: anchor(), position(), item_attached(),
match_item(), reorder_check() with Entry, group_run_end(),
add_item_allowed() and remove_item_allowed().

The steps_* cases port test_scene_item_order_steps 1:1, its 15 cases
under the same names with the same inputs. The edge_* cases are new:
the four intentional differences of the port (a movement outside the
enum stays, a NULL or detached item stops the caller, a reorder2 order
that is not the scene's items rearranged is refused, and a remove of
an item that is not in the group does nothing), the run end past the
order, and proptests of every decision against models written another
way: any i32 movement and position, every item and movement of lists
of up to 7, any flat order, random scenes and orders, and the gates.

All 28 fail with "not yet implemented".

Refs #2895.
The safe core of obs_scene::item_order and the eight #[no_mangle]
shims in src/ffi/scene_item_order.rs, in a new
libobs.ported-scene-item-order group whose PCH is the header alone.
The hybrid libobs drops the C; libobs-c-reference and the C backend
keep compiling it. The export lists (all eight hidden),
source-sets.json, the unity lists and ci/test_ported_sources.py are
updated, and test_scene_item_order_steps_rust runs the unchanged
characterization against the shims.

The shims compare the item pointers by address and never follow
them; struct obs_sceneitem_order_info is mirrored as OrderInfo.
obs-scene.c.h checks enum obs_order_movement's values and the pair's
size at compile time.

Four intentional differences, each a fix the C callers now follow:

- an unknown movement gives OBS_SCENE_ITEM_ORDER_ANCHOR_STAY, and
  obs_sceneitem_set_order() unlocks and returns before the detach, so
  the item stays where it was and nothing is signalled (the C
  detached it and never attached it again);
- obs_sceneitem_get_order_position() and
  obs_sceneitem_group_ungroup2() stop for a NULL or detached item
  (0, or a return) instead of reading through it;
- obs_scene_reorder_items2() refuses (OBS_SCENE_ITEM_ORDER_INVALID)
  an order whose items are not exactly the scene's items, top level
  and in groups, each once, instead of relinking it and losing,
  repeating or stealing items;
- obs_sceneitem_group_remove_item() leaves an item that is not in the
  group where it is.

The C keeps its behaviour, so test_scene_item_order_steps pins only
what both share; Tier 1 pins the differences.

Refs #2895.
Tier 3 for obs_scene::item_order: the original
libobs/obs-scene-item-order.c.h compiled as oracle_* in obs-c-oracle
(oracle/scene_item_order.c, with a layout table), and
item_order_parity, 12 cases, shim against C:

- the layout of struct obs_sceneitem_order_info, the movement, anchor
  and check values;
- exhaustive: 14 movements around and at the ends of int for every
  neighbour pair, positions -10 to 10 and the ends with the steps
  written, every gate flag, every order of up to 5 entries over 4
  items for the match step, every order of up to 4 entries over 7
  items and 3 groups against six scenes for the pair check, and every
  order of up to 5 entries over 9 pairs for the group runs;
- proptests over any movement, position, flat order and run, and a
  model of obs_scene_reorder_items2()'s relinking over random scenes
  and orders: the same scene from both sides for every rearrangement,
  a refusal from the shims for anything else, and every item kept
  once by the shims.

The four intentional differences are the only inputs where the two
differ, and the test asserts each one exactly: an unknown movement,
a NULL or detached item, an order that is not the scene's items
rearranged, and a remove of an item not in the group.

Mutation check: an up move without a next to the bottom, a position
one step too far, a check that accepts any order, a run that takes
any grouped entry, and a match that never clears each fail the
parity tests.

Refs #2895.
The rust/README.md rows (the obs-scene crate row and the
libobs/obs-scene-item-order.c.h row: what moved, what stays C, what
is kept and characterized, the four intentional differences and the
tests), the crate's Cargo.toml description and lib.rs module docs,
and a port_comparison bench of a 16-entry reorder2 check with its
group runs and every anchor. docs/rust-port/naming.md already maps
libobs/obs-scene*.c.h to rust/obs-scene.

Refs #2895.
Review fixes to the scene item order port, behaviour-neutral in C:

- The group run of obs_scene_reorder_items2() was computed once, before
  full_lock(sub_scene). It is asked again one entry at a time with
  obs_scene_item_order_in_group_run(), at the top of the loop, inside
  the group's lock and after the entry before it was moved, where the
  C compared sub_info->group. It replaces
  obs_scene_item_order_group_run_end().
- obs_scene_item_order_add_item_allowed() takes the item's parent and
  the two scenes, and compares with the group's scene only after the
  first check passed, as the C did; the caller no longer evaluates
  both comparisons up front.
- move_active_child()'s gate is two steps,
  obs_scene_item_order_moves_scene() and
  obs_scene_item_order_item_active(), so active_refs is still loaded
  only once the scenes differ.
- The new entries of the three export lists are sorted.

The move harness, rerun with move_active_child() taken from both files
(its atomic load logged) and orders on the heap at their exact size:
1,001,120 calls with the same logs under gcc and clang, -O0 and -O2,
with and without ASan and UBSan. Five new mutants (the load before the
scene check, a run against the head's group, an inactive count taken
as active, a same-scene move, a read one past the order) are caught.

test_scene_item_order_steps follows (16 cases, a new one for the
active-child gates), and Tier 1, Tier 3 and the bench move to the new
functions. The Rust core of the four is todo!(): six Tier 1 cases fail
with "not yet implemented".

Refs #2895.
The Rust core of the four steps the last commit asks in place:
in_group_run() (an entry in the order whose group is the head's item;
a head or index past the end is never in a run, and reads nothing),
add_item_allowed() on the parent, the scene and the group's scene
(the second compare only after the first passes), moves_scene() and
item_active(). Tier 1 passes 29/29 and Tier 3 12/12; an in-run
compare against the head's group, an add gate without its second
check, an inactive count taken as active and a same-scene move each
fail the parity tests.

Refs #2895.
The rust/README.md row and the _rust test's comment name the ten
functions: the group run asked one entry at a time inside the group's
lock, the add gate on the item's parent with its second compare only
after the first, and the two steps of move_active_child()'s gate.

Refs #2895.
item_active() took an i64, so the shim's i64::from(c_long) was a
useless conversion on Linux and macOS (clippy -D warnings, --lane
lint and --lane cross) while Windows needs it. The core takes
std::ffi::c_long, the type the C loads, and the shim passes it as
it is; Tier 1 uses literals that fit a 32-bit long.

Refs #2895.
The run is now asked one entry at a time, so the bench's numbers on
x86_64 Linux are about 95 ns for the Rust side and 37 ns for the C.

Refs #2895.
@rdoupe
rdoupe force-pushed the fix/rust-port-scene-item-order-reord-254 branch from 57b42f9 to 51c908e Compare October 29, 2026 10:41
@rdoupe
rdoupe marked this pull request as ready for review October 29, 2026 10:54
@rdoupe
rdoupe requested a review from zackees as a code owner October 29, 2026 10:54
@rdoupe
rdoupe added this pull request to the merge queue Oct 29, 2026
Merged via the queue into master with commit 2bcddc2 Oct 29, 2026
38 checks passed
@rdoupe
rdoupe deleted the fix/rust-port-scene-item-order-reord-254 branch October 29, 2026 11:09
wesleyhawes pushed a commit to wesleyhawes/obs-studio that referenced this pull request Nov 21, 2026
…#5285) (obs-rust#5377)

* test: mirror scene-item order position characterization (RED, Refs obs-rust#5285)

Tier 1 mirrors every assertion of test_sceneitem_order_position.c against
the safe core; Tier 3 compares the original extracted C wrapper with the
shim on one fixture through the real-named full lock and the real parent,
head and link adapters, with mutants for a missing unlock, a walk after the
unlock, a walk before the lock, a head read under the lock and off-by-one
counts. The lock stand-in clears the head or the first link until the
unlock, so moved reads change the result. NULL and detached items are
undefined on the C reference (legacy predicate, obs-rust#2899), so they are left out
of differential execution and checked against the shim alone. The shared
real-named full-lock stand-in in scene_atomic_update.c now also dispatches
to an active order-position probe. The new private head adapter
(obs-scene-item-order-position-fields.c.h) reads scene->first_item.

The core and shim are stubs that always return 0, so:
  soldr cargo test -p obs-data --test obs-tests-core item_order_position
  test result: FAILED. 3 passed; 6 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* obs-scene: swap scene-item order position to safe Rust (Refs obs-rust#5285)

obs_sceneitem_get_order_position now comes from obs-scene in the hybrid
libobs. Safe Rust reads the item's parent through the existing
obs_sceneitem_parent_fields adapter and applies the obs-rust#2899 attached-item
predicate, so a NULL or detached item is 0 before any other read or lock.
It then reads the parent's head through the new private
obs_scene_item_order_position_first adapter before the C-owned full lock,
as the C did, and walks the links (obs_scene_lookup_next) and counts under
exactly one full lock. The original wrapper moves to the
libobs.ported-scene-item-order-position group for the C reference build.

  soldr cargo test -p obs-data --test obs-tests-core item_order_position
  test result: ok. 9 passed; 0 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795229913,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":95,"stamp":"d7dbd3fbf1ffd6e1093197af14ca8f97","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229913,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":95,"stamp":"346d77bb825006571b033895ab6ba1f8","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229913,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":95,"stamp":"0a43babaef33e2d26c3338b169490482","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229913,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":95,"stamp":"6fc65567b36c75e9abb6140b03a74209","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"general/all/client-lint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"5be43ac65a0aec330c80bd313c3a71e3","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229913,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":95,"stamp":"ace7cdd534f37533635066af4c9ef543","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"d5cf8807723bf9949309c1a862271321","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"7e4c330e1f362c0779514082055fad33","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"ba2ccf6b19d35c98fabade681410bca0","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"d8638d645cdb3531ea167ba0fcb341d5","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"0677bea1c2d000c9b7f764bd55f9f11c","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"5ce100ec980da8d95d82179611e7773b","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"91d090c2afbd179c43bd1fe7e7730513","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"5a77aeda0066ea1783ad4f88f933bb7c","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"3d445360e9c249f02ca4172a2bae90c2","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"6cdd2cc02146673296514c27d93bba33","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"9243dd113a13f400aafcc54549ee9d5a","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795229817,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f64b7a53d72554316961568bc00cd39e350f3b63c84cdd2bd2604f40138e1ef2","lane":"client-lint","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":58,"stamp":"b1f09cfca26259daf689349b48a5a07c","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}
Ci-Attestation: {"at":1795230130,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"8ed1cfaa8d34bbc0f2be7c23aabb417d1ca95e6677eed7509db2cb20c9ebf331","lane":"client-test-x86_64-unknown-linux-gnu","parents":["b4b7bc9aa9a5ade60ab64ae1f1ba5398c435056f"],"secs":216,"stamp":"0d83e9050c3b88482682a956c509628b","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"937eecf4675ee49570d7f20d514a8bc9e0a78b56","coverage":"all-tracked-applicable-files","diff":["ci/test_bench_libobs_stand_ins.py","libobs/build/libobs.core-output+.h.c","libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-encoder-group-num-started+.h.c","libobs/build/libobs.ported-scene-item-order-position+.h.c","libobs/build/ported-source-sets/encoder-group-num-started.json","libobs/build/ported-source-sets/scene-item-order-position.json","libobs/cmake/rust-exports.d/obs-scene-item_order_position.txt","libobs/cmake/rust-hidden.d/obs-output-encoder_group_num_started.txt","libobs/obs-encoder-group-num-started-fields.c.h","libobs/obs-scene-item-order-position-fields.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_encoder_group_num_started_swap_is_registered.rs","rust/obs-build/tests/native/registration/canonical_scene_item_order_position_swap_is_registered.rs","rust/obs-build/tests/native/registration/rust-static/cases/core-relinked/test_encoder_group_num_started_rust.json","rust/obs-c-oracle/benches/port_comparison.rs","rust/obs-c-oracle/oracle.d/scene-item-order-position.list","rust/obs-c-oracle/oracle/encoder_group_num_started.c","rust/obs-c-oracle/oracle/scene_atomic_update.c","rust/obs-c-oracle/oracle/scene_item_order_position.c","rust/obs-output/src/encoder_group_num_started.rs","rust/obs-output/src/ffi/encoder_group_num_started.rs","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/lib.rs","rust/obs-output/tests/output/encoder_group_num_started.rs","rust/obs-output/tests/output/encoder_group_num_started_parity.rs","rust/obs-output/tests/output/interleave_parity.rs","rust/obs-output/tests/output/main.rs","rust/obs-scene/src/ffi/item_order_position.rs","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/item_order_position.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/tests/scene/item_order_position.rs","rust/obs-scene/tests/scene/item_order_position_parity.rs","rust/obs-scene/tests/scene/main.rs","test/cmocka/build/test-graph.json","test/cmocka/encoder-group-num-started-record-support.c"],"head":"9de95d55e3b8f58ffd45fa842187f5ae3fc8374d","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"0259bed89774122a46cadeb0e49f537ad1f7698bc5ab0db3962327fef6c1f384","tree":"27651c64b06819be679edee2b7f19b4223a8a5dc"}}

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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 scene item order and group membership rules in obs-scene.c to obs-scene

1 participant