Skip to content

obs-scene: port obs_sceneitem_remove to Rust (Fixes #6039) - #6040

Merged
rdoupe merged 4 commits into
masterfrom
port/6039-sceneitem-remove
Dec 1, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/6039-sceneitem-remove

Conversation

@rdoupe

@rdoupe rdoupe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Ports obs_sceneitem_remove() from libobs/obs-scene.c.h to obs-scene, the same shape as the release (#6030) and do_transition (#6038) ports. obs_sceneitem_remove_internal(), full_lock() and full_unlock() stay C: remove_all_items() and the group teardown also use them.

Fixes #6039

Commits

  1. Characterization (test: characterize obs_sceneitem_remove): new test_sceneitem_remove, 5 cases on real scenes: NULL item; the item leaves its scene's list, is marked removed and "item_remove" fires once with the scene and the item while another thread cannot take the scene's video or audio mutex; the scene's reference is released after both mutexes are free (an item's last reference destroys it then, which the probe sees through its visibility hotkeys being unregistered); an already removed item gets no second signal and no second release; an item of a group leaves the group's scene and the outer scene keeps the group. 5/5 on hybrid libobs and the C reference before anything moved.
  2. Move (libobs: extract obs_sceneitem_remove verbatim): the function moves unchanged into libobs/obs-sceneitem-remove.c.h, in the live group libobs.core-source after obs-scene.c.h. test_sceneitem_remove 5/5 on both libraries.
  3. RED (obs-scene: Tier 1 for obs_sceneitem_remove, RED): the safe core obs_scene::item_remove as a todo!() stub and 6 Tier 1 tests over a model item.
    soldr cargo test -p obs-data --test obs-tests-core item_remove → test result: FAILED. 0 passed; 6 failed (each not yet implemented: #6039 GREEN).
  4. GREEN (obs-scene: port obs_sceneitem_remove to Rust, GREEN): the core runs the original's steps in order; the export obs_sceneitem_remove (rust-exports.d, it is EXPORT in obs.h) returns on a NULL item. The live adapter obs-sceneitem-remove-fields.c.h keeps the item fields, the original's two asserts on the parent, the static full_lock(), full_unlock() and obs_sceneitem_remove_internal() and the release in C, so no layout is mirrored. The original moves to the reference-only group libobs.ported-sceneitem-remove and reaches the static helpers through the adapter. Registration test, ported source set and rust/README.md line included.
    soldr cargo test -p obs-data --test obs-tests-core item_remove → test result: ok. 8 passed; 0 failed (6 Tier 1, 2 Tier 3).

Tiers

  • Tier 1: 6 tests on a model item: the C test's cases, a second remove after the first, and the exact call order with the parent read once before the lock (detaching clears it; the unlock still goes to the locked scene).
  • Tier 2: after GREEN, all pass on hybrid libobs and the C reference (linux-validate image): test_sceneitem_remove 5/5, test_group_active_refs 10/10, test_preview_only_hide 6/6, test_scene_dup_copy_lifetime 1/1, test_scene_item_hotkeys 2/2, test_scene_enum_items_removal 11/11, test_sceneitem_release 4/4, test_scene_item_select 4/4, test_sceneitem_transition_stop 4/4, test_scene_item_set_visibility 3/3, test_canvas_rules_callers 9/9, test_scene_item_defer_update 8/8.
  • Tier 3: oracle/sceneitem_remove.c runs the original and the export on the same real-layout item and scenes through the production adapter and the same recording stand-ins for the lock, unlock, internal removal (which clears the parent, as the real one does) and release, and compares the call logs field by field, each call with its argument and the scenes' lock depth, over every item (removed or not, NULL or not, in a scene or a group's). Eight planted mutants are caught; moving the release before the unlock in the Rust core also fails parity.
  • Tier 4: no protocol, does not apply.

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

./lint passes. The Rust test binaries link for x86_64-pc-windows-msvc; the cmocka half of ci/windows_link_check.py couldn't run here (the local soldr cc toolchain query fails), so CI's Windows link lane covers that.

Test cost: the 8 new 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 12 MB over 20 runs, no own threads.

🤖 Generated with Claude Code

rdoupe and others added 4 commits December 1, 2026 00:01
test_sceneitem_remove calls obs_sceneitem_remove() on items of real
scenes: a NULL item does nothing; the item leaves its scene's list, is
marked removed, and the scene's "item_remove" fires once with the scene and
the item while another thread cannot take the scene's video or audio mutex;
the scene's reference is released after both are free (the item's last
reference destroys it then, unregistering its visibility hotkeys); an item
already removed gets no second signal and no second release; an item of a
group leaves the group's scene, and the outer scene keeps the group. 5/5 on
hybrid libobs and the C reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_sceneitem_remove() moves unchanged into obs-sceneitem-remove.c.h, in the
live group libobs.core-source after obs-scene.c.h, whose static full_lock(),
full_unlock() and obs_sceneitem_remove_internal() it still calls.
test_sceneitem_remove passes 5/5 on hybrid libobs and the C reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The safe core obs_scene::item_remove (Remove trait, remove()) as a todo!()
stub, with 6 Tier 1 tests in the scene test binary over a model item, its
scene's list, "item_remove" signals, references and the two mutexes: the
cases of test_sceneitem_remove, a second remove after the first, and the
C's call order with the parent read once before the lock (detaching clears
it, and the unlock still goes to that scene).

soldr cargo test -p obs-data --test obs-tests-core item_remove
test result: FAILED. 0 passed; 6 failed (not yet implemented: #6039 GREEN)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Rust core runs the original's steps in order: an item already marked
removed is left alone; otherwise its parent is read once, full_lock() takes
the scene's video then audio mutex, obs_sceneitem_remove_internal() detaches
the item and signals "item_remove", full_unlock() releases that same scene
(detaching cleared the item's parent), and obs_sceneitem_release() drops the
scene's reference after the unlock. The export obs_sceneitem_remove
(rust-exports.d) does nothing for a NULL item. The live adapter
obs-sceneitem-remove-fields.c.h keeps the item's fields, the parent asserts,
the static full_lock(), full_unlock() and obs_sceneitem_remove_internal()
(still used by remove_all_items() and the group teardown) and the release in
C; the original moves to the reference-only group
libobs.ported-sceneitem-remove and reaches the static ones through the
adapter.

Tier 3 (oracle/sceneitem_remove.c) runs the original and the export on the
same real-layout item and scenes through the same recording stand-ins and
compares the call logs, with each call's argument and the scenes' lock
depth, over every item; eight planted mutants are caught.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1796102460,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":78,"stamp":"a97f45676b885e995903accdf116ae3f","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102460,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":78,"stamp":"e233f6651aa00d4fc76860c298d0c894","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102460,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":78,"stamp":"b71e6673ec9c1632b53f6cece8cfee95","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102460,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":78,"stamp":"c912be8423514ea1eb88a5a6f3f35a14","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"general/all/client-lint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"7f60e1860b9540df3c8d025da6a5620c","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102460,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":78,"stamp":"f0d11a2c8069a788d459a95aeda5dcc4","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"d984a9320e04a0f4959307508ccb0d92","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"79c5e95daa07ef1da53cb318e7b228e9","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"de526a1096dcd33981ed090d4fcd29a7","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"02dc15e9683f7589048fda5823e73033","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"d44544f932d5e55f39bec356c458e855","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"20dc51449851a890f3a83d693a296b5b","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"f4b4709c56f81e3e68b8a756181092a4","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"d53ce27a0897f9b34ac5b862c05ab77b","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"7fa68957cad1bfcf92a6e8ea66343a93","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102381,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"a705124bcc2b45a0b98edcc268fcedb0","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"6c4cdcfe1bfba26ed02ea4e01d514017","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102380,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e7ec31227abb81204e65c6e25bac4d12a5551a5b2e498b667d558e38180de875","lane":"client-lint","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":88,"stamp":"25a137297979275bf968928aa1a52724","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}
Ci-Attestation: {"at":1796102804,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"00e79b840d6a9e76b2bcdea876813c4dbdf4cc15858e9a051836123ed419c9f6","lane":"client-test-x86_64-unknown-linux-gnu","parents":["6ce64207de479dccdb85cdd138f07b6afe12bfb8"],"secs":343,"stamp":"c751abcae061c0ab7d685c730c7701ff","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"235bbebe72df073e4722c33960652f5296e8f0d5","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-sceneitem-remove+.h.c","libobs/build/ported-source-sets/sceneitem-remove.json","libobs/cmake/rust-exports.d/obs-scene-item_remove.txt","libobs/obs-scene.c.h","libobs/obs-sceneitem-remove-fields.c.h","libobs/obs-sceneitem-remove.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_sceneitem_remove_is_registered.rs","rust/obs-c-oracle/oracle/sceneitem_remove.c","rust/obs-scene/src/ffi/item_remove.rs","rust/obs-scene/src/ffi/mod.rs","rust/obs-scene/src/item_remove.rs","rust/obs-scene/src/lib.rs","rust/obs-scene/tests/scene/item_remove.rs","rust/obs-scene/tests/scene/item_remove_parity.rs","rust/obs-scene/tests/scene/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_sceneitem_remove.c","test/cmocka/tests.d/test_sceneitem_remove.cmake"],"head":"8bcaa6f978fe65f67f98c26e1e12f1c1fbaeb592","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":"ca5a941f38da7df4af7cf4568ed85ae49db45ac48b68322dc62281d687d11ef2","tree":"a69fc5d581da5e127440fe2f29f3bddb4700b2cd"}}
@rdoupe
rdoupe requested a review from zackees as a code owner December 1, 2026 05:26
@rdoupe rdoupe changed the title obs-scene: port obs_sceneitem_remove to Rust, GREEN (Fixes #6039) obs-scene: port obs_sceneitem_remove to Rust (Fixes #6039) Dec 1, 2026
@rdoupe
rdoupe enabled auto-merge December 1, 2026 05:27
@rdoupe
rdoupe added this pull request to the merge queue Dec 1, 2026

@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 (post-queue): LGTM. It ports the public obs_sceneitem_remove, and the rust-exports.d entry keeps the ABI. It adds a new Tier 2 test, test_sceneitem_remove.c, and Tier 1 and Tier 3 parity, with no memcmp over padded log entries. No existing C test or header is edited, and it has a Test cost line.

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_remove to obs-scene

2 participants