Skip to content

obs-scene: port obs_sceneitem_set_order to Rust (Fixes #5787) - #5789

Merged
rdoupe merged 2 commits into
masterfrom
port/5787-sceneitem-set-order
Nov 26, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/5787-sceneitem-set-order

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Ports obs_sceneitem_set_order() (extracted into libobs/obs-scene-item-set-order.c.h by #5650) to obs-scene, following the obs_source_filter_set_order() swap (#5776) and the obs-scene seam style of #5377.

What moved

  • Safe core rust/obs-scene/src/item_set_order.rs over a SetOrderScene trait, in the C's order. A NULL item, or a NULL obs_scene_get_ref(item->parent), returns before any lock. The full lock is taken, then next/prev pick the existing item_order::anchor() (rust: Port the scene item order and group membership rules in obs-scene.c to obs-scene #2895). For every anchor except Stay, the item is detached, then attached after prev->prev (read after the detach), next, prev, the last item (walked from next after the detach) or at the bottom. Then unlock, reorder on the item's parent, release. Stay unlocks and releases with no signal.
  • Shim rust/obs-scene/src/ffi/item_set_order.rs exports obs_sceneitem_set_order (libobs/cmake/rust-exports.d/obs-scene-item_set_order.txt). It goes through obs_sceneitem_parent_fields, obs_scene_get_ref/obs_scene_release, obs_scene_atomic_full_lock/unlock, obs_scene_lookup_next, and the new private adapters in libobs/obs-scene-item-set-order-fields.c.h (live core-source group, no EXPORT). Those adapters cover prev, detach_sceneitem(), attach_sceneitem() and signal_reorder(), which stay static in obs-scene.c.h.
  • C reference: the extracted C now builds in libobs.ported-scene-item-set-order. There, obs-scene-item-set-order-support.c.h forwards its static helpers to the same adapters and to the full-lock wrapper, because the helpers live in another unity group.
  • Tier 3: rust/obs-scene/tests/scene/item_set_order_parity.rs and rust/obs-c-oracle/oracle/scene_item_set_order.c. The shared real-named full-lock and source-reference stand-ins in oracle/scene_atomic_update.c hand off to an active set-order probe.
  • The obs-build registration test and the rust/README.md row are updated.

No public header or C test changes. The intentional difference is the one #2895 already made in the anchor: on the C reference, a movement outside the enum detaches the item and never re-attaches it. The hybrid's Stay leaves the item where it was.

RED

soldr cargo test -p obs-data --test obs-tests-core -- scene::item_set_order
test result: FAILED. 0 passed; 7 failed
panicked at rust/obs-scene/src/item_set_order.rs:53:5: not yet implemented: #5787

GREEN

soldr cargo test -p obs-data --test obs-tests-core -- scene::item_set_order
test result: ok. 12 passed; 0 failed        (7 Tier 1 + 5 Tier 3)
soldr cargo test -p obs-data --test obs-tests-core -- scene::
test result: ok. 665 passed; 0 failed
soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_scene_item_set_order canonical_scene_item_order_position
test result: ok. 2 passed; 0 failed
./lint                                       lane lint: ok
OBS_CMOCKA_LINK=false uv run --no-project ci/windows_link_check.py   exit 0
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests test_scene_canvas_characterization
  exported symbols C vs Rust: IDENTICAL (1769 symbols)
  [OFF] 100% tests passed, 0 tests failed out of 1123; repeat x3 passed
  [ON]  100% tests passed, 0 tests failed out of 1123; repeat x3 passed

To check that the cmocka cases really ran and were not skipped, I ran test_scene_canvas_characterization straight from the kept build volume under xvfb-run. It ran 13 tests and passed 13, including scene_item_set_order, on both the hybrid libobs and the C reference (libobs-c-reference/libobs.so.30, checked with ldd).

Tier 3 compares, on noise-filled real-header scenes:

  • the call trace: references, lock, detach, attach with its anchor, and the signal with the parent it read, each with the lock depth
  • every scene, source and item byte
  • the reference count and the lock depth

The inputs cover lists of 0 to 6 items in both link orders, every item, NULL, detached and dying-scene items, eleven movements, and a proptest over any int. It catches six mutants: signal under the lock, no release, always the bottom, no lock, prev for prev->prev, and a signal on Stay. Mutation check: making up-moves attach after prev in the core fails every_case_matches_c and four Tier 1 tests (reverted).

Fixes #5787

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 26, 2026 14:23
New obs-scene module item_set_order with a todo!() core over a
SetOrderScene trait, and Tier 1 tests on a model scene whose links,
lock, reference and signal behave as the C-owned ones do
(detach_sceneitem() and attach_sceneitem() copied onto indexes): every
movement (the four of enum obs_order_movement and seven outside it) on
every item of lists of 1 to 6 items, the exact calls of each anchor
(prev->prev and the walk to the last item read after the detach), a
single item, NULL, detached and dying-scene items, and the sequence of
test_scene_canvas_characterization's scene_item_set_order with its
reorder counts.

    soldr cargo test -p obs-data --test obs-tests-core -- scene::item_set_order
    test result: FAILED. 0 passed; 7 failed
    panicked at rust/obs-scene/src/item_set_order.rs:53:5: not yet implemented: #5787

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_sceneitem_set_order() moves to obs-scene's item_set_order module. A
NULL item, or one whose obs_scene_get_ref(item->parent) is NULL, returns
before any lock. Under the full scene lock (video, then audio) the
item's next and prev pick the existing item_order::anchor() (#2895); for
every anchor but Stay the item is detached and attached again after
prev->prev, next, prev, the last item (walked from next after the
detach) or at the bottom; then the lock is released, reorder signalled
on the item's parent and the scene reference released. Stay, a movement
outside enum obs_order_movement, unlocks and releases without a signal,
as the extracted C does on that anchor.

The shim reads the parent through obs_sceneitem_parent_fields(), the
next links through obs_scene_lookup_next(), takes the reference through
obs_scene_get_ref()/obs_scene_release() and the lock through
obs_scene_atomic_full_lock()/unlock(), and reaches prev,
detach_sceneitem(), attach_sceneitem() and signal_reorder() (static in
obs-scene.c.h) through the new adapters of
obs-scene-item-set-order-fields.c.h (live core-source group, no
EXPORT). The extracted C builds in the reference group
libobs.ported-scene-item-set-order, where
obs-scene-item-set-order-support.c.h forwards its static helpers to
those adapters and to the full-lock wrapper.

Tier 3 (item_set_order_parity, oracle/scene_item_set_order.c) runs the
original C and the Rust export on noise-filled real-header scenes, over
lists of 0 to 6 items in both link orders, every item, NULL, detached
and dying-scene items, eleven movements and a proptest over any int,
comparing the call trace (references, lock, detach, attach with its
anchor, signal with the parent it read, each with the lock depth),
every scene, source and item byte, the reference count and the lock
depth; it rejects six mutants (signal under the lock, no release,
always the bottom, no lock, prev for prev->prev, a signal on Stay). The
shared real-named full-lock and source-reference stand-ins in
scene_atomic_update.c dispatch to an active set-order probe. Mutation
check: making up attach after prev in the core fails
every_case_matches_c and four Tier 1 tests (reverted).

    soldr cargo test -p obs-data --test obs-tests-core -- scene::item_set_order
    test result: ok. 12 passed; 0 failed
    soldr cargo test -p obs-data --test obs-tests-core -- scene::
    test result: ok. 665 passed; 0 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795723101,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":94,"stamp":"ed90449a2ef0f0314a930431f987aef2","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723101,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":94,"stamp":"14b74a5baee6ae9be0c4b62fb499799f","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723101,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":94,"stamp":"1d897c9b6a7bc42a68da7e472f67c4ae","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723101,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":94,"stamp":"63bda9743cfe787e2e30b23213a41f18","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"general/all/client-lint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"c3be1785a3383f5b130d7e5a9a98653d","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723101,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":94,"stamp":"b64e20c5019ebd0e705056c080966654","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"625702e3869dc289f6796f676d409a6e","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"b544b371fdab103dd6cfe4baa97200e5","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"f28e729eaabe09c1d06c598e9aeda708","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"1a2178d7ae97ec6ba213b77326b3bc27","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"02d4b2bc78769ed3b3956d04f0a3260b","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"caa064a97bc8ba7a3af3f8dec5ee334d","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"993ca87e2acbde963dc93fa660ae6d6a","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"9e40d403a2703593ee0c95c0321ae327","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"b3db6bc300a9a3c001ba81aa3e393aa9","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"64ef465d038660bb08c0e7f497f0ee7e","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"8062cba37c9a9ab3ffc86a7fa341cb59","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723006,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"729355801c22161d58367e42557d48110ddf59291343b185cc9e4321f7677766","lane":"client-lint","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":129,"stamp":"b0883f2f71d7b9ac8caca4206256d8c5","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}
Ci-Attestation: {"at":1795723460,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"df8123bbff7852fc0762d4522471400d88962ff0344669f74afa7d0d7c6557c7","lane":"client-test-x86_64-unknown-linux-gnu","parents":["b7596b47f31dc2664b1359e6f31cd0d014746267"],"secs":359,"stamp":"b56e36be56f621d5d40f4fb37f67052a","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"5fd85c15ec022e55b5b0b3b7d7f59461fba59c2c","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-scene-item-set-order+.h.c","libobs/build/ported-source-sets/scene-item-set-order.json","libobs/cmake/rust-exports.d/obs-scene-item_set_order.txt","libobs/obs-scene-item-set-order-fields.c.h","libobs/obs-scene-item-set-order-support.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_scene_item_set_order_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/scene-item-set-order.list","rust/obs-c-oracle/oracle/scene_atomic_update.c","rust/obs-c-oracle/oracle/scene_item_set_order.c","rust/obs-scene/src/ffi/item_set_order.rs","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/item_set_order.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/tests/scene/item_set_order.rs","rust/obs-scene/tests/scene/item_set_order_parity.rs","rust/obs-scene/tests/scene/main.rs"],"head":"5ac7997f9842b33caae1c6173ff839a0ee9a590c","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":"d3fcef35860e109365e386d1e51ad9793a1422d1e162520f0eb921b09f90cdbe","tree":"955fcbc4c01b524eecc51837eaa540f6132f0ad4"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 26, 2026 20:04
@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 26, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
Merged via the queue into master with commit 246c4de Nov 26, 2026
48 checks passed
@rdoupe
rdoupe deleted the port/5787-sceneitem-set-order branch November 26, 2026 21:41
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Done in obs-rust Multiview Nov 27, 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 obs_sceneitem_set_order to obs-scene

1 participant