Skip to content

obs-scene: port obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2 to Rust (Fixes #6053) - #6054

Merged
rdoupe merged 4 commits into
masterfrom
port/6053-sceneitem-group-ungroup
Dec 1, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/6053-sceneitem-group-ungroup

Conversation

@rdoupe

@rdoupe rdoupe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Ports obs_sceneitem_group_ungroup() and obs_sceneitem_group_ungroup2() from libobs/obs-scene.c.h to obs-scene, the same shape as the remove (#6040) and add (#6042) ports. The static helpers they call (full_lock(), full_unlock(), signal_item_remove(), remove_group_transform(), obs_scene_add_internal(), duplicate_item_data(), apply_group_transform(), detach_sceneitem(), signal_refresh()) stay C: the scene's other paths use them too.

Fixes #6053

Consumers checked: the frontend's Ungroup (SourceTreeModel.cpp.hpp), test_scene_duplicate_scale_ref, scripting (through obs.h) and plugins reach the two EXPORT symbols, which stay under the same names. Nothing else in libobs calls them; obs_sceneitem_group_ungroup2() calls obs_sceneitem_group_ungroup() and the item check obs_scene_item_order_item_attached() (Rust since the item-order port).

Commits

  1. Characterization (test: characterize obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2): new test_sceneitem_group_ungroup, 6 cases on real scenes. A NULL item or an item that is not a group does nothing, but ungroup2 on an item that is not a group still fires "refresh" on its scene when asked; a group's items (one or three) come back in the group's order right where the group was, as new items of the same sources with the transform they had in the scene before they were grouped, their visibility and their lock; "item_remove" fires once with the scene and the group before anything moves, no "item_add" fires, and the group item and its source are gone; an empty group just goes; ungroup2 fires "refresh" once after the items are back only when signal is true. 6/6 on hybrid libobs and the C reference before anything moved. ungroup2 with a NULL or detached item isn't pinned there: the C reads through it 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): the two functions move unchanged into libobs/obs-sceneitem-group-ungroup.c.h, in the live group libobs.core-source after obs-scene.c.h. test_sceneitem_group_ungroup 6/6, test_scene_duplicate_scale_ref 6/6 and test_group_active_refs 10/10 on both libraries.
  3. RED (obs-scene: Tier 1 ..., RED): the safe core obs_scene::item_ungroup (Ungroup trait; ungroup(), ungroup2()) as todo!() stubs and 7 Tier 1 tests over a model scene and group.
    soldr cargo test -p obs-data --test obs-tests-core item_ungroup → test result: FAILED. 0 passed; 7 failed (each not yet implemented: #6053 GREEN).
  4. GREEN (obs-scene: port ... to Rust, GREEN): the core runs the original's steps in order: not a group, return; read the parent and the group's own scene; "item_remove" before any lock; lock the scene, then the group's scene; for each of the group's items, first to last, remove_group_transform(), obs_scene_add_internal() of its source after the previous new item (the group first, id 0), duplicate_item_data(dst, src, true, true), apply_group_transform() on the original, then read next; unlock the group's scene, detach the group, unlock the scene, release the group. ungroup2 returns on the item check, otherwise reads the parent, ungroups, then signal_refresh() on that scene only when signal is true. The exports obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2 (rust-exports.d, both EXPORT in obs.h) return on a NULL item. The live adapter obs-sceneitem-group-ungroup-fields.c.h keeps the item and scene fields, the static helpers and the release in C, so no layout is mirrored. The original moves to the reference-only group libobs.ported-sceneitem-group-ungroup and reaches the static helpers through the adapter under their own signatures. Registration test, ported source set and rust/README.md line included.
    soldr cargo test -p obs-data --test obs-tests-core item_ungroup → test result: ok. 9 passed; 0 failed (7 Tier 1, 2 Tier 3).

Tiers

  • Tier 1: 7 tests on a model scene and group (lists, lock depths, items with group flag, parent, source, transform offset, visibility, lock and references, and the two signals): the C test's cases, ungroup2 with a NULL item or a group with no parent, an add that gives NULL passed on unchecked as in C, and the exact call order with both scenes' lock depths at each call.
  • Tier 2: after GREEN, all pass on hybrid libobs and the C reference (linux-validate image, 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): test_sceneitem_group_ungroup 6/6, test_scene_duplicate_scale_ref 6/6, test_group_active_refs 10/10, test_scene_item_order_steps 16/16, test_scene_item_order_steps_rust 16/16, test_group_recursion 3/3, test_group_empty_bounds 18/18, test_scene_canvas_characterization 13/13, test_scene_dup_group_children 6/6, test_sceneitem_remove 5/5.
  • Tier 3: oracle/sceneitem_group_ungroup.c runs the original and the exports on the same real-layout group item, items and scenes through the production adapter and the same recording stand-ins for every helper (the add hands out new items or NULL as scripted; the detach clears the parent). It compares the call logs field by field (each call's arguments, the add's id, the copy's two flags and both scenes' lock depths, in order; no memcmp over padded entries, see master red: obs-scene item_release_parity fails on Windows (from #6030) #6035) over 360 calls: ungroup, and ungroup2 with signal false or true, on a NULL item or a group item that is a group or not, with or without a parent, with 0 to 3 items and every set of adds giving NULL. Fourteen planted mutants of the original are caught, and three mutants of the Rust core (insert_after never moving on, refresh with signal inverted, a second release) each fail Tier 1 and parity.
  • 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: 5 passed). Like #6040 and #6042, the cmocka half of ci/windows_link_check.py wasn't run here, so CI's Windows link lane covers that.

Test cost: the 9 new Rust tests run in about 0.01 s together in debug, with OBS_PARITY_CASES=reduced or full cases (the grid is exhaustive, no proptest). Peak RSS is 13.5 MB over 20 runs, and the tests start no threads of their own.

🤖 Generated with Claude Code

rdoupe and others added 4 commits December 1, 2026 04:15
…p_ungroup2 (Refs #6053)

test_sceneitem_group_ungroup dissolves groups of real scenes: a NULL item
or an item that is not a group does nothing, but ungroup2 on an item that is
not a group still fires "refresh" on its scene when asked; a group's items
come back to the scene in the group's order, right where the group was, as
new items of the same sources with the transform they had before they were
grouped, their visibility and their lock; "item_remove" fires once with the
scene and the group before anything moves, no "item_add" fires, and the
group item and its source are gone; an empty group just goes; ungroup2
fires "refresh" once after the items are back only when signal is true.
6/6 on hybrid libobs and the C reference.

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

obs_sceneitem_group_ungroup() and obs_sceneitem_group_ungroup2() move
unchanged into obs-sceneitem-group-ungroup.c.h, in the live group
libobs.core-source after obs-scene.c.h, whose static full_lock(),
full_unlock(), signal_item_remove(), remove_group_transform(),
obs_scene_add_internal(), duplicate_item_data(), apply_group_transform(),
detach_sceneitem() and signal_refresh() they still call.
test_sceneitem_group_ungroup 6/6, test_scene_duplicate_scale_ref 6/6 and
test_group_active_refs 10/10 pass on hybrid libobs and the C reference.

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

The safe core obs_scene::item_ungroup (Ungroup trait; ungroup() and
ungroup2()) as todo!() stubs, with 7 Tier 1 tests in the scene test binary
over a model scene and group scene (their lists and lock depths), items
(group flag, parent, source, transform offset, visibility, lock and
references) and the "item_remove" and "refresh" signals: the cases of
test_sceneitem_group_ungroup, ungroup2 with a NULL item or a group with no
parent, an add that gives NULL passed on as in C, 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_ungroup
test result: FAILED. 0 passed; 7 failed (not yet implemented: #6053 GREEN)

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

The Rust core runs the original's steps in order: an item that is not a
group is left alone; otherwise the item's parent and the group's own scene
are read, signal_item_remove() fires "item_remove" for the group before any
lock, full_lock() takes the scene and then the group's scene, and for each of
the group's items from first to last remove_group_transform(),
obs_scene_add_internal() of the item's source after the previous new item
(the group item first, id 0), duplicate_item_data(dst, src, true, true) and
apply_group_transform() on the original, reading next after that; then the
group's scene is unlocked, the group detached, the scene unlocked and the
group released. obs_sceneitem_group_ungroup2() returns on the item check of
obs-scene-item-order.c.h, otherwise reads the parent, ungroups and fires
signal_refresh() on that scene only when signal is true. The exports
obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2
(rust-exports.d, both EXPORT in obs.h) return on a NULL item. The live
adapter obs-sceneitem-group-ungroup-fields.c.h keeps the items' and scenes'
fields, the static helpers of obs-scene.c.h and the release in C, so no
layout is mirrored; the original moves to the reference-only group
libobs.ported-sceneitem-group-ungroup and reaches the static helpers through
the adapter under their own signatures.

Tier 3 (oracle/sceneitem_group_ungroup.c) runs the original and the exports
on the same real-layout group, items and scenes through the same adapter and
recording stand-ins and compares the call logs field by field (each call's
arguments, flags and both scenes' lock depths, in order) over 360 calls;
fourteen planted mutants are caught.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1796116933,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":77,"stamp":"5241d203d2f3e159e2d7728a5c4c45d7","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116933,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":77,"stamp":"3a91eaa56a7e2e24df853745a394b739","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116933,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":77,"stamp":"3886c0a2c1cf75cf318def4bb8f1ad98","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116933,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":77,"stamp":"daeff25bc2d29cb0275cf05f525a7346","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"general/all/client-lint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"47727826b93f12db103c5f1e7abfc1e0","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116933,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":77,"stamp":"db6f23f8f57e49380468f250a81dad72","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116856,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"de52fee1e720c5a0555a4eeb78072ff3","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116856,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"ac34d4c86474c2abe3036e8b20c7dfa7","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"b4f80b2b2d182d7d794512f03cefc8eb","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"47e0b1876f742848a29bf5a7af8cf255","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"f08023ebe7b0b5d2feb24df02e1d98f0","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"8384ebf1b47050131f3ca1c1fe33deb0","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"bf4fe15494e866fda37554cbe177ddf1","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"2fa4cac8020970ae6091e91fc16fdbe4","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"594033e8fdcef36bfec03c0d8a4cc254","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"1950433257f591b7a89c21b0182a86b5","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"5ec465998e7958f1e36a43c063633b63","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796116855,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"95cbab01affd6a2bca81d237df3fc8350148c3e6c6bee231eb615a65da2b5c8a","lane":"client-lint","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":55,"stamp":"cbbcfb450ddc7d6081162f6ce8ff82fe","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}
Ci-Attestation: {"at":1796117256,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"f21332aa06c43b4c5bbe82666a65fd4e77f3725f61c1d277458f35f30773a68d","lane":"client-test-x86_64-unknown-linux-gnu","parents":["755bdfd691f73c0bad5853c9a2a010c5aa611cf2"],"secs":322,"stamp":"b7d74f9002103549b398536e9f5dd4ce","tree":"959eb03bd881eac137225e60afa0137750ddd30a","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"ccf6978740609b0a581c359c244585eca70843a7","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-sceneitem-group-ungroup+.h.c","libobs/build/ported-source-sets/sceneitem-group-ungroup.json","libobs/cmake/rust-exports.d/obs-scene-item_ungroup.txt","libobs/obs-scene.c.h","libobs/obs-sceneitem-group-ungroup-fields.c.h","libobs/obs-sceneitem-group-ungroup.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_sceneitem_group_ungroup_is_registered.rs","rust/obs-c-oracle/oracle/sceneitem_group_ungroup.c","rust/obs-scene/src/ffi/item_ungroup.rs","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/item_ungroup.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/tests/scene/item_ungroup.rs","rust/obs-scene/tests/scene/item_ungroup_parity.rs","rust/obs-scene/tests/scene/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_sceneitem_group_ungroup.c","test/cmocka/tests.d/test_sceneitem_group_ungroup.cmake"],"head":"43df6ca23d733b0cd1416a4f731a0fd8170ee0b3","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":"6a0451e6f9918c6c89341fde6412a39766d7d92fb05eb47d1d93368ba2c78092","tree":"959eb03bd881eac137225e60afa0137750ddd30a"}}
@rdoupe
rdoupe requested a review from zackees as a code owner December 1, 2026 09:27
@rdoupe rdoupe changed the title obs-scene: port obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2 to Rust, GREEN (Fixes #6053) obs-scene: port obs_sceneitem_group_ungroup and obs_sceneitem_group_ungroup2 to Rust (Fixes #6053) Dec 1, 2026
@rdoupe
rdoupe enabled auto-merge December 1, 2026 09:46

@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_ungroup and obs_sceneitem_group_ungroup2 with a rust-exports.d entry, a new Tier 2 test, test_sceneitem_group_ungroup.c, and Tier 1 and Tier 3 parity, with no memcmp over padded entries. No existing C test or header is edited, and it has a Test cost line. Auto-merge on.

@rdoupe
rdoupe added this pull request to the merge queue Dec 1, 2026
Merged via the queue into master with commit 9ba3044 Dec 1, 2026
53 checks passed
@rdoupe
rdoupe deleted the port/6053-sceneitem-group-ungroup branch December 1, 2026 10:16
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_ungroup and obs_sceneitem_group_ungroup2 to obs-scene

2 participants