Skip to content

obs-scene: port obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item to Rust (Fixes #6055) - #6056

Merged
zackees merged 4 commits into
masterfrom
port/6055-sceneitem-group-add-remove
Dec 1, 2026
Merged

zackees merged 4 commits into
masterfrom
port/6055-sceneitem-group-add-remove

Conversation

@rdoupe

@rdoupe rdoupe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Ports obs_sceneitem_group_add_item() and obs_sceneitem_group_remove_item() from libobs/obs-scene.c.h to obs-scene, the same shape as the ungroup (#6054), remove (#6040) and add (#6042) ports. The static helpers they call (full_lock(), full_unlock(), move_would_recurse(), remove_group_transform(), detach_sceneitem(), attach_sceneitem(), move_active_child(), apply_group_transform(), resize_group(), signal_refresh()) stay C: the reorder paths use them too.

Fixes #6055

Consumers checked: the frontend's "remove from group" (OBSBasic_SceneItems.cpp.hpp), scripting (through obs.h) and plugins reach the two EXPORT symbols, which keep their names. Nothing else in libobs calls them; they call the item checks obs_scene_item_order_add_item_allowed() and obs_scene_item_order_remove_item_allowed() (Rust since the item-order port).

Commits

  1. Characterization (test: characterize ...): new test_sceneitem_group_add_remove, 6 cases on real scenes: NULL group or item and a plain item do nothing; an item outside the group's scene (another scene, already in this group, another group) is not added; the group itself or a scene holding it is not added, with one warning naming both; an added item goes first in the group and keeps its transform values, which now count from the group (kept as in C, not endorsed); a removed item goes first in the scene, drawn where it was; the last item out; a round trip; one "refresh" per move and no "item_add"/"item_remove". remove_item with an item outside the group isn't pinned there: the C moves it anyway and libobs returns (the existing intentional difference of the item-order unit), so Tier 1 and Tier 3 cover it.
  2. Move (libobs: extract ... verbatim): both functions move unchanged into libobs/obs-sceneitem-group-add-remove.c.h, in the live group libobs.core-source after obs-scene.c.h.
  3. RED (obs-scene: Tier 1 ..., RED): the safe core obs_scene::item_group_add_remove (GroupMove trait) as todo!() stubs and 11 Tier 1 tests on a model scene, group and other scenes.
    OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core item_group_add_remove on 648e109 → test result: FAILED. 0 passed; 11 failed (each not yet implemented: #6055 GREEN).
  4. GREEN (obs-scene: port ... to Rust, GREEN): the core runs the original's checks and steps in order (see the rust/README.md line). The live adapter obs-sceneitem-group-add-remove-fields.c.h keeps the item and scene fields, the static helpers and the warning in C, so no layout is mirrored. The original moves to the reference-only group libobs.ported-sceneitem-group-add-remove and reaches the static helpers through the adapter under their own signatures. Registration test, ported source set, rust-exports.d entry and rust/README.md line included.
    Same command on the GREEN head → test result: ok. 13 passed; 0 failed (11 Tier 1, 2 Tier 3).

Tiers

  • Tier 1: 11 tests: the C test's cases, remove_item with an item outside the group, active and inactive items (the active-child link), and the exact call order with both scenes' lock depths at each call.
  • Tier 2: on the GREEN head, in the linux-validate image's kept build volume, each binary run under xvfb-run -a from the runtime dir, then again with LD_LIBRARY_PATH=/build/tree/libobs-c-reference (the unchanged C): test_sceneitem_group_add_remove 6/6 on both, test_group_active_refs 10/10 on both.
  • Tier 3: oracle/sceneitem_group_add_remove.c runs the original and the exports on the same real-layout group, item and scenes through the production adapter and the same recording stand-ins (the detach and attach set the parent; blog() and obs_source_get_name() recorded too). It compares the call logs field by field (each call's arguments, flags and lock depths in order, then the item's final parent; no memcmp over padded entries, see master red: obs-scene item_release_parity fails on Windows (from #6030) #6035) over 512 calls: both entries, a NULL group or item, a group item that is a group or not, the group's and item's parents each NULL, the scene, the group's scene or another scene, and the recursion check either way. All 17 planted mutants of the original are caught.
  • Tier 4: no protocol, does not apply.

No new intentional differences. No C test or public header changed.

./lint passes. The registration tests pass (soldr cargo test -p obs-studio-rust --test obs-tests-app canonical_sceneitem_group: 2 passed). The cmocka half of ci/windows_link_check.py wasn't run here, so CI's Windows link lane covers it.

Test cost: the 13 new Rust tests run in about 0.01 s together in debug with OBS_PARITY_CASES=reduced (the grid is exhaustive, no proptest). Peak RSS is 14.2 MB typical over 20 runs (one outlier at 46.7 MB), and the tests start no threads of their own.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner December 1, 2026 11:05
@rdoupe rdoupe changed the title obs-scene: port obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item to Rust, GREEN (Fixes #6055) obs-scene: port obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item to Rust (Fixes #6055) Dec 1, 2026
rdoupe and others added 4 commits December 1, 2026 03:21
…up_remove_item (Refs #6055)

test_sceneitem_group_add_remove moves items into and out of groups of real
scenes: a NULL group or item, or a group item that is not a group, does
nothing; an item in another scene, already in the group or in another group
is not added; an item that contains the group (the group itself, or a scene
that holds it) is not added, with one warning naming both; an added item
goes first in the group's list keeping its transform values, which now
count from the group (drawn where the group's transform puts its old place,
kept as in C), while the group's other items stay where they were and the
group grows; a removed item goes first in the scene's list, drawn where it
was, the rest of the group staying put; the group's last item out leaves an
empty group; each move fires "refresh" once on the scene and nothing else,
and the item keeps its one reference.
6/6 on hybrid libobs and the C reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…remove_item verbatim (Refs #6055)

obs_sceneitem_group_add_item() and obs_sceneitem_group_remove_item() move
unchanged into obs-sceneitem-group-add-remove.c.h, in the live group
libobs.core-source after obs-scene.c.h, whose static full_lock(),
full_unlock(), move_would_recurse(), remove_group_transform(),
detach_sceneitem(), attach_sceneitem(), move_active_child(),
apply_group_transform(), resize_group() and signal_refresh() they still
call.
test_sceneitem_group_add_remove 6/6, test_group_active_refs 10/10,
test_group_recursion 3/3, test_group_empty_bounds 18/18,
test_scene_item_order_steps 16/16 (and _rust 16/16),
test_scene_dup_group_children 6/6, test_scene_enum_items_removal 11/11 and
test_visibility_transition 8/8 pass on hybrid libobs and the C reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…group_remove_item, RED (Refs #6055)

The safe core obs_scene::item_group_add_remove (GroupMove trait; add_item()
and remove_item()) as todo!() stubs, with 11 Tier 1 tests in the scene test
binary over a model scene, group scene, second group and other scene (their
lists, active children and lock depths), items (group flag, parent,
transform offset, recursion, activity) and the warning and "refresh": the
cases of test_sceneitem_group_add_remove, an item not in the group for
remove (the item-order unit's intentional difference), active and inactive
items, and the C's call order with the lock depths of both scenes at each
call.
soldr cargo test -p obs-data --test obs-tests-core item_group_add_remove
test result: FAILED. 0 passed; 11 failed (not yet implemented: #6055 GREEN)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…remove_item to Rust, GREEN (Fixes #6055)

The Rust core runs the original's steps in order. Add: a NULL group, a
group item that is not a group or a NULL item returns; the group's parent
and own scene are read, then the item's parent for the item-order add check;
move_would_recurse() logs the original's warning and returns; otherwise
full_lock() takes the scene and then the group's scene,
remove_group_transform(), detach_sceneitem(), attach_sceneitem() first in
the group's scene, move_active_child() from the scene to the group's scene,
apply_group_transform(), resize_group(group, false), the unlocks in reverse
order and signal_refresh() on the scene. Remove: a NULL item, a NULL group
or a non-group returns; the item's and the group's parents are read and the
item-order remove check runs on whether the item is in the group's scene;
otherwise the same locks, remove_group_transform(), the detach, the attach
first in the scene, move_active_child() back, resize_group(group, false),
the unlocks and signal_refresh() on the scene. The exports
obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item
(rust-exports.d, both EXPORT in obs.h) keep their names. The live adapter
obs-sceneitem-group-add-remove-fields.c.h keeps the items' and scenes'
fields, the static helpers of obs-scene.c.h and the warning in C, so no
layout is mirrored; the original moves to the reference-only group
libobs.ported-sceneitem-group-add-remove and reaches the static helpers
through the adapter under their own signatures.
Tier 3 (oracle/sceneitem_group_add_remove.c) runs the original and the
exports on the same real-layout group, item and scenes through the same
adapter and recording stand-ins (blog() and obs_source_get_name()
included) and compares the call logs field by field (each call's
arguments, flags and the lock depths, in order, then the item's final
parent) over 512 calls; seventeen planted mutants are caught.
soldr cargo test -p obs-data --test obs-tests-core item_group_add_remove
test result: ok. 13 passed; 0 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1796122744,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":77,"stamp":"9c87f0ade49410f99c67d8296055afc4","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122744,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":77,"stamp":"d2bd326deee7026378e1ea865d3b3fa4","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122744,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":77,"stamp":"afe47987b6aeeb45b8b0d73469e24d67","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122744,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":77,"stamp":"acbfc12ba058c3f914f2e61547ceb162","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"general/all/client-lint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"152dc45abca22dcc7e197907b551ecd1","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122744,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":77,"stamp":"d150d84a45df1c28d3ea7e08ffcde44f","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"51dcdcb835bba49022488db50598e59c","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"0d226ddad7a30741eb2cb9987928494f","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"b80805ed230c89529244e1ff1cdc0b0a","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"2122a827967b171dba05968dd9503fdc","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"ef973a47a3648e2ae075efedef907e80","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"5b18efc1e72c8cf30d33336df2c5c7f5","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"fbd9f029d66feb203c5c74423c2be09a","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122666,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"f8b2a7197cc5a461f91f7925b4be70e5","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"1165aa2c57c5814130954075386a0335","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"452bae84eb2c117d26cc8e7edb5f7de9","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"6b1b5c3f640ea6390125af6b1ace4547","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796122665,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"2355a9a9166759e1693b7f8390d31e8049ad6228765fe2b1e8c07171e61bc282","lane":"client-lint","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":81,"stamp":"f3016b6a7017f69547822ece5f5f2c58","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}
Ci-Attestation: {"at":1796123120,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"08acee9cf83fd6f5ca1fceb8b1ea5637b51c0e34562e5cbe3b0f86ae472b514d","lane":"client-test-x86_64-unknown-linux-gnu","parents":["648e10959d1ac682f40803795e8dc82eb077fadf"],"secs":376,"stamp":"40df1e633155cea4c4b69b0642e22a56","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"9ba30444c9ae5ea342ea535d1bb8d0ceb80d5d80","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-sceneitem-group-add-remove+.h.c","libobs/build/ported-source-sets/sceneitem-group-add-remove.json","libobs/cmake/rust-exports.d/obs-scene-item_group_add_remove.txt","libobs/obs-scene.c.h","libobs/obs-sceneitem-group-add-remove-fields.c.h","libobs/obs-sceneitem-group-add-remove.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_sceneitem_group_add_remove_is_registered.rs","rust/obs-c-oracle/oracle/sceneitem_group_add_remove.c","rust/obs-scene/src/ffi/item_group_add_remove.rs","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/item_group_add_remove.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/tests/scene/item_group_add_remove.rs","rust/obs-scene/tests/scene/item_group_add_remove_parity.rs","rust/obs-scene/tests/scene/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_sceneitem_group_add_remove.c","test/cmocka/tests.d/test_sceneitem_group_add_remove.cmake"],"head":"8c9a989e4e5d752e7933d09f51453d353525c2d3","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":"da61e937f4488729615fcc00409db112afc2e88a70ca853a96b7d91c1695750b","tree":"748d8b15321b4bd570ff305cef17f4a8ff8c752b"}}
@zackees
zackees force-pushed the port/6055-sceneitem-group-add-remove branch from 1d21ba8 to c7a8f0d Compare December 1, 2026 11:21
@zackees

zackees commented Dec 1, 2026

Copy link
Copy Markdown
Member

Coordinator rebase onto master after #6052. One code conflict, in libobs/obs-scene.c.h: #6052 had already moved obs_scene_insert_group2 out, right before obs_sceneitem_group_add_item, which this PR extracts. I resolved it to master's text minus the two functions this PR moves. The diff against master removes exactly obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item, each defined once, in obs-sceneitem-group-add-remove.c.h. soldr cargo check -p obs-scene passes. Pushed with a lease.

Since every port in obs-scene.c.h now conflicts with the one before it, consider waiting for each to merge before opening the next, or basing the next PR on the previous branch.

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: LGTM. It ports the public obs_sceneitem_group_add_item and obs_sceneitem_group_remove_item with a rust-exports.d entry, a new Tier 2 test, test_sceneitem_group_add_remove.c, and Tier 1 and Tier 3 parity. No existing C test or header is edited, and it has a Test cost line. Auto-merge on.

@zackees
zackees enabled auto-merge December 1, 2026 11:21
@zackees
zackees added this pull request to the merge queue Dec 1, 2026
Merged via the queue into master with commit aaec64f Dec 1, 2026
51 checks passed
@zackees
zackees deleted the port/6055-sceneitem-group-add-remove branch December 1, 2026 12:11
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_group_add_item and obs_sceneitem_group_remove_item to obs-scene

2 participants