Repository navigation
obs-scene: port obs_scene_insert_group to Rust (Fixes #6058) - #6060
Conversation
test_scene_insert_group creates groups in real scenes: a NULL scene gives NULL with or without items and creates nothing; an item of another scene, a group or an item of a group, first, in the middle or last in the array, gives NULL with no group source, nothing moved and no signal; with no items (a NULL array, or a count of 0 whatever the array holds) the new group item, named as asked, with an empty scene of its own and held only by the scene, is last in the list and no signal fires; with items they move into the group's scene in the array's order, the group takes the place of the array's last item, every item keeps its one reference and is drawn where it was, and the group grows around them; one "item_add" with the scene and the group fires after the move, and no "item_remove" or "refresh"; on a showing scene a visible item's source stays shown once and a hidden one's stays hidden, both back to 0 when the scene stops showing. 6/6 on hybrid libobs and the C reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_scene_insert_group() moves unchanged into obs-scene-insert-group.c.h, in the live group libobs.core-source. It sorts before obs-scene.c.h, so it declares group_info and the static full_lock(), full_unlock(), detach_sceneitem(), create_id(), obs_scene_add_internal(), move_active_child(), remove_group_transform(), apply_group_transform() and resize_group() it still calls there. test_scene_insert_group 6/6 and the 33 other cmocka tests that create groups or build the scenes they touch (test_scene_add_group 7/7, test_group_active_refs 10/10, test_group_insert_empty 4/4, test_filter_clipboard 7/7, test_sceneitem_group_ungroup 6/6, ...) pass on hybrid libobs and the C reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The safe core obs_scene::scene_insert_group (GroupInsert trait; insert_group()) as a todo!() stub, with 9 Tier 1 tests in the scene test binary over a model scene, other scene and the group scenes the call creates (their linked lists, references, active children and lock depths), items (group flag, parent, links, a position counted from their group, activity), the canvas reference and "item_add": the cases of test_scene_insert_group, which items are checked before a refusal (last to first, the parent before the group flag), a NULL group item from the add passed on as in C, and the C's call order with the lock depths of both scenes at each call. OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core scene_insert_group test result: FAILED. 0 passed; 9 failed (not yet implemented: #6058 GREEN) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Rust core runs the original's steps in order: a NULL scene gives NULL; the array is walked from its last item back and an item whose parent is not the scene, or that is a group, gives NULL before anything is created; then the scene's canvas, create_id() with group_info.id and the name, the canvas release, and obs_scene_add_internal() of the group scene's source after the array's last item (at the end with no items). With no items the group scene's creation reference is released and the item returned. Otherwise full_lock() takes the scene and then the group's scene, the group scene's first item becomes the array's first, the items are taken out last to first (remove_group_transform(), detach_sceneitem()), and in the array's order each is linked to the next, given the group's scene as parent, moved as an active child and given the group transform; then the first item's prev is cleared, resize_group(group, false), the unlocks in reverse order, one "item_add" with the scene and the group, and the group scene's release. A NULL group item from the add is passed on unchecked, as in C. The export obs_scene_insert_group (rust-exports.d, EXPORT in obs.h) keeps its name. The live adapter obs-scene-insert-group-fields.c.h keeps the items' and scenes' fields (the list links included), group_info, the static helpers of obs-scene.c.h, the releases and the signal in C, so no layout is mirrored; the original moves to the reference-only group libobs.ported-scene-insert-group and reaches the static helpers through the adapter under their own signatures. Tier 3 (oracle/scene_insert_group.c) runs the original and the export on the same real-layout scenes, sources and items through the same adapter and recording stand-ins (the add and the detach link and unlink as the real ones do) and compares the call logs field by field (each call's arguments, both lock depths and the links of the item it gets, the signal's calldata, then every item's parent and links, each scene's first item and the result) over 7680 calls; twenty planted mutants are caught. OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core scene_insert_group test result: ok. 11 passed; 0 failed Co-Authored-By: Claude Opus 5.5 <[email protected]> Ci-Attestation: {"at":1796126284,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":77,"stamp":"0e4f4333131491404171266f4bc96f13","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126284,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":77,"stamp":"83fe00ff912125a76205514ce932a588","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126284,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":77,"stamp":"d418ef4c62b2198e1e68820787bc0c1d","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126284,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":77,"stamp":"e648fdaf6dbfa7c196a31857e67930c8","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"general/all/client-lint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"9217bd2ac7a2493990e1fd46106a14da","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126284,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":77,"stamp":"e4d8c4dcc977bb1d5b3cdba4e7b216b9","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"7ac2f523790887897ecb6c67c976342c","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"57a02b9a7f9a4bc52e9c564a36107201","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"09f0168d017ea550746cb5e92be9c95c","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"bb28aabbb4198c7c5766723c1b167ad4","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"87b0a15e02a8efbf26ff6770e7c79628","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"8e271d1c8ab75dd788f330cf0562c4a3","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"f7a966ef40e75e0cb69500067a674c3a","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"de5a46e716831a7e9d4e006c7f78bbd1","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"54ebf7e63a694ff54635118ee06e6601","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"d63b01d7d981e43f741f9edf024b2898","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"7656f496e1760d15be4570ed26f00031","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126206,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"eb3af38906c9959e1627c6ef682b1601416257f4f24217f2a8d8cd00dc427bd7","lane":"client-lint","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":101,"stamp":"81469359d87329521b9969b90392bc28","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Ci-Attestation: {"at":1796126638,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"1f65cb48e65773a18b556c42b81fcf3c3860cc4e499ee983c6bae65765e2b140","lane":"client-test-x86_64-unknown-linux-gnu","parents":["dd2ef0d008e0b25b64a3ed4f2bc25a7faf857383"],"secs":353,"stamp":"a14d40edb58a73eae0f828ba95f9f3e2","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1","v":1,"via":"run"} Client-Checks: {"checks":{"base":"15beb08201bcc258881d1336d64b13a4190e2d14","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-scene-insert-group+.h.c","libobs/build/ported-source-sets/scene-insert-group.json","libobs/cmake/rust-exports.d/obs-scene-scene_insert_group.txt","libobs/obs-scene-insert-group-fields.c.h","libobs/obs-scene-insert-group.c.h","libobs/obs-scene.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_scene_insert_group_is_registered.rs","rust/obs-c-oracle/oracle/scene_insert_group.c","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/ffi/scene_insert_group.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/src/scene_insert_group.rs","rust/obs-scene/tests/scene/main.rs","rust/obs-scene/tests/scene/scene_insert_group.rs","rust/obs-scene/tests/scene/scene_insert_group_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/test_scene_insert_group.c","test/cmocka/tests.d/test_scene_insert_group.cmake"],"head":"a197b5a9fa911be1e553a599cc90757ea18da151","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":"c092c859fcf8c58e00a18506df02fd329517b6456e43d11b9e159b11256495f8","tree":"c8516bc0620a0bb15c555f92e7f371cec6950cb1"}}
69bbf55 to
cca6a85
Compare
|
Coordinator rebase onto master after #6056. |
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: LGTM. It ports the public obs_scene_insert_group with a rust-exports.d entry, a new Tier 2 test, test_scene_insert_group.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.
Ports
obs_scene_insert_group()fromlibobs/obs-scene.c.htoobs-scene, the same shape as the group add/remove (#6056), ungroup (#6054) and add-group (#6052) ports. It is the core every group creation goes through:obs_scene_add_group(),obs_scene_add_group2()andobs_scene_insert_group2()(Rust since #6052) call it, and the frontend's "Group Selected Items" (SourceTreeModel.cpp.hpp), scripts and plugins call it directly throughobs.h. The static helpers it calls (full_lock(),full_unlock(),detach_sceneitem(),create_id(),obs_scene_add_internal(),move_active_child(),remove_group_transform(),apply_group_transform(),resize_group()) andgroup_infostay C: the scene's other paths use them too.Fixes #6058
Consumers checked: nothing else in libobs calls the static helpers through this function; the only callers of
obs_scene_insert_group()are the #6052 adapter (obs-scene-add-group-fields.c.h, which now reaches the Rust export), the frontend, and the cmocka tests (test_group_insert_empty,test_filter_clipboard,test_group_active_refs, ...). No oracle or link-support file defines the symbol under its real name (the #6052 oracle renames it to its stand-in).Commits
test: characterize obs_scene_insert_group): newtest_scene_insert_group, 6 cases on real scenes. A NULL scene gives NULL with or without items and creates nothing. An item of another scene, a group or a group's item, first, in the middle or last in the array, gives NULL with no group source, nothing moved and no signal. With no items (a NULL array, or a count of 0 whatever the array holds, even an item of another scene) the new group, named as asked, with an empty scene of its own and held only by the scene, is last in the list and no signal fires. With items, they move into the group's scene in the array's order, the group takes the place of the array's last item, each item keeps its one reference and is drawn where it was, and the group grows around them. One"item_add"with the scene and the group fires after the move, with no"item_remove"or"refresh". On a showing scene, a visible item's source stays shown once and a hidden one's stays hidden, and both go back to 0 when the scene stops showing. 6/6 on hybrid libobs and the C reference before anything moved.libobs: extract obs_scene_insert_group verbatim): the function moves unchanged intolibobs/obs-scene-insert-group.c.h, in the live grouplibobs.core-source. It sorts beforeobs-scene.c.h, so it declaresgroup_infoand the static helpers it calls there.test_scene_insert_groupand 33 other cmocka tests that create groups or build the scenes they touch pass on both libraries (list under Tiers).obs-scene: Tier 1 for obs_scene_insert_group, RED): the safe coreobs_scene::scene_insert_group(GroupInserttrait,insert_group()) as atodo!()stub and 9 Tier 1 tests on a model with linked lists.OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core scene_insert_groupon RED_SHA →test result: FAILED. 0 passed; 9 failed(eachnot yet implemented: #6058 GREEN).obs-scene: port obs_scene_insert_group to Rust, GREEN): the core runs the original's steps in order (see therust/README.mdline). The live adapterobs-scene-insert-group-fields.c.hkeeps the items' and scenes' fields (the list links included),group_info, the static helpers, the canvas and scene releases and the"item_add"signal's fixed calldata in C, so no layout is mirrored. The original moves to the reference-only grouplibobs.ported-scene-insert-groupand reaches the static helpers through the adapter under their own signatures. The registration test, the ported source set, therust-exports.dentry and therust/README.mdline are included. The obs-scene: port obs_scene_add_group, obs_scene_add_group2 and obs_scene_insert_group2 to Rust (Fixes #6049) #6052 README line now says thatobs_scene_insert_group()is Rust.Same command on the GREEN head →
test result: ok. 11 passed; 0 failed(9 Tier 1, 2 Tier 3).Tiers
xvfb-run -afrom the runtime dir, then again withLD_LIBRARY_PATH=/build/tree/libobs-c-reference(the unchanged C). All pass on both libraries:test_scene_insert_group6/6,test_scene_add_group7/7,test_scene_add7/7,test_scene_create2/2,test_scene_canvas_characterization13/13,test_group_active_refs10/10,test_group_insert_empty4/4,test_group_hide_transition_audio4/4,test_group_empty_bounds18/18,test_group_recursion3/3,test_group_child_drift3/3,test_group_teardown_uaf1/1,test_canvas_move_scene3/3,test_canvas_rules_callers9/9,test_filter_clipboard7/7,test_transform_clipboard8/8,test_preview_only_hide6/6,test_scene_dup_group_name4/4,test_scene_dup_group_children6/6,test_scene_dup_copy_lifetime1/1,test_scene_duplicate_scale_ref6/6,test_scene_item_defer_update8/8,test_scene_item_select4/4,test_scene_item_hotkeys2/2,test_sceneitem_group_ungroup6/6,test_sceneitem_remove5/5,test_sceneitem_save_add8/8,test_scene_enum_items_removal11/11,test_scene_transform_update_walk12/12,test_scene_transform_states4/4,test_shutdown_leaked_scenes5/5,test_shutdown_detach2/2,test_source_duplicate9/9,test_visibility_transition8/8. The move commit gave the same results.oracle/scene_insert_group.cruns the original and the export on the same real-layout scenes, sources and items, through the production adapter and the same recording stand-ins for the static helpers,obs_weak_canvas_get_canvas(),obs_canvas_release(),obs_scene_release()andsignal_handler_signal(). The add and detach stand-ins link and unlink as the real ones do. The test compares the call logs field by field (nomemcmpover padded entries, see master red: obs-scene item_release_parity fails on Windows (from #6030) #6035): each call's arguments, both lock depths and the parent and links of the item it gets, and the signal's handler, name and calldata; then every item's parent and links, each scene's first item and the result. It does this over 7680 calls: a NULL scene or not, a NULL array or 0 to 3 items in each of their six orders, each item in the scene or another scene and a group or not, and the add answering the group item or NULL. All twenty planted mutants of the original are caught. Six mutants of the Rust core each fail both Tier 1 and parity: lock order, the first item'sprevleft set, signalling while locked, the group flag ignored, the canvas kept, and the parent set after the active-child move.No intentional differences. No C test or public header changed.
./lintpasses. The registration tests pass (soldr cargo test -p obs-studio-rust --test obs-tests-app canonical_scene: 29 passed). As in #6052 and #6056, the cmocka half ofci/windows_link_check.pywasn't run here, so CI's Windows link lane covers it.Test cost: the 11 new Rust tests run in about 0.05 s together in debug with
OBS_PARITY_CASES=reduced(the grid is exhaustive and has no proptest, so full cases are the same). Peak RSS is 14.0 to 14.8 MB over 20 runs, and the tests start no threads of their own.🤖 Generated with Claude Code