Skip to content

libobs: Characterize and extract obs_sceneitem_defer_update_begin/end - #5056

Merged
rdoupe merged 2 commits into
masterfrom
test/4646-defer-update-extract
Nov 18, 2026
Merged

rdoupe merged 2 commits into
masterfrom
test/4646-defer-update-extract

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

obs_sceneitem_defer_update_begin and obs_sceneitem_defer_update_end still live in the middle of obs-scene.c.h. This is the C-only step before their Rust port: characterize them against the unchanged C, then move both bodies verbatim into their own file. No Rust changes, no edits to existing C tests or public headers.

What changes

  • test/cmocka/test_scene_item_defer_update.c (new, registered through tests.d/): eight actual-library cases, observed through the scene's item_transform signal and the source's size reads:
    • NULL item: each function returns after one LOG_DEBUG line, "obs_sceneitem_defer_update_begin: Null 'item' parameter" / "..._end: ...", and changes no item.
    • begin() never asks for a transform; the matching end() of an item of a scene computes it at once (one size read, one signal), every time.
    • Nested pairs: only the end() that brings the count back to exactly zero computes, once; a position setter while deferred computes nothing.
    • An unmatched end() takes the count below zero: no dispatch, and a negative count does not defer (a setter computes at once). Two begin()s bring it back to zero without dispatching; the next pair behaves as usual. The count is not clamped (characterized, not endorsed).
    • A child of a group: end() only sets the update flag (nothing read or signalled); the next walk of the outer scene computes it and clears the flag.
    • The group item itself is an item of a scene: its end() computes at once.
    • An item removed from its scene but still referenced: end() reads nothing and signals nothing, nested or not.
  • libobs/obs-sceneitem-defer-update.c.h (new): both bodies, byte-for-byte, right after obs-scene.c.h in the core-source unity group. do_update_transform() is a macro private to obs-scene.c.h, so the new file maps it onto the existing live adapter obs_sceneitem_bounds_update_transform() (obs-scene-item-bounds-setters-fields.c.h), which wraps that same macro and is what the extracted bounds setters already call. obs-scene.c.h loses those 17 lines.

The existing test_scene_transform_update_walk, test_scene_transform_states, test_scene_rotated_scale_filter and test_scene_item_bounds_setters are unchanged and keep passing.

Evidence

Characterization against the unchanged C (first commit only):

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 \
  --tests '^test_scene_item_defer_update$|^test_scene_transform_update_walk$'
IDENTICAL (1768 symbols)
== [OFF] tests load /build/tree/libobs-c-reference/libobs.so.30
100% tests passed, 0 tests failed out of 983
== [ON] tests load /build/tree/libobs/libobs.so.30
100% tests passed, 0 tests failed out of 983

A cmocka skip() also reports Passed, so I ran the binary directly in the same build tree under xvfb-run, against both libraries: [ PASSED ] 8 test(s), all eight [ OK ], none skipped. (A first draft probed with the crop setter, which only sets the flag; the C reference failed it, which is how the position setter came to be the probe.)

After the move (both commits):

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 \
  --tests '^test_scene_item_defer_update$|^test_scene_transform_update_walk$|^test_scene_transform_states$|^test_scene_rotated_scale_filter$|^test_scene_item_bounds_setters$'
IDENTICAL (1768 symbols)
[OFF] 100% tests passed, 0 tests failed out of 983; repeat x3: 5/5
[ON]  100% tests passed, 0 tests failed out of 983; repeat x3: 5/5

Run directly again after the move: 8/8 on both libraries; nm -D libobs.so.30 still exports both as T. The two function bodies, cut from the old obs-scene.c.h and from the new file, diff empty. ci/test_build_groups.py and ./lint pass.

Not covered: concurrent begin()/end() from two threads; the atomics moved unchanged.

Fixes #4646

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 18, 2026 01:58
Actual-library cmocka cases against the unchanged C: NULL diagnostics,
begin never dispatching, nested pairs dispatching once on the outer end,
an unmatched end taking the count negative (no dispatch, no deferral),
group children only setting the update flag, the group item computing
at once, and a parentless item reading nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move both bodies verbatim out of obs-scene.c.h into
obs-sceneitem-defer-update.c.h, after it in the core-source unity group.
end() reaches the scene's do_update_transform() through the existing
obs_sceneitem_bounds_update_transform adapter, which wraps that same
macro. No behavior change, no Rust swap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1794985229,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":56,"stamp":"99fa100a3a379a3c25b26458b71b1ec6","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985229,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":56,"stamp":"d8918577fb20bdea6976380622319124","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985229,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":56,"stamp":"6f53480863e10ad37a0a6ce1a490b8ac","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985229,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":56,"stamp":"5295df2712f9bd840cd9590079562483","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"general/all/client-lint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"0a44954887aa2e71d60790dee4e2f68e","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985229,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":56,"stamp":"d74561106fb3b7e5c317c67ce4fe7956","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985173,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"2c994e7e25725d952f41743d6ca53160","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985173,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"98d833d83cdb4a0893d9f7f809046908","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"b87f735843ea84346deb74ea9cab4eae","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"4c8d6fb71b0430d4b0a1220305039bf2","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"c14d1cca1c2c1b5f465f6ed166052313","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"2e409d3f5b8a9788089bf3d24934ac3e","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"684f5228c5cb067420b13bfadd3cec5c","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985173,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"ba107908fbd7fe9e05484a286ec6717f","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"61d3efdaeae74be204da1861652dd8c1","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"60d41a0ec892fadd092e4ea51c4a816b","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"bf775447eae89f6a540748a8e13417a9","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985172,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"5fb221d6c6223d35092a8aff1e1b51875e9edaed9132e40e82c0d542725be413","lane":"client-lint","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":66,"stamp":"eabd299b0340b2f75a112e0337a8f0bb","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}
Ci-Attestation: {"at":1794985465,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"92cee59f812ec9a75919929d764b159419fe223b7dea9ba24bda1d36f3eaea38","lane":"client-test-x86_64-unknown-linux-gnu","parents":["07fe0967193674ab5f5ef2787388c338dc2e1563"],"secs":235,"stamp":"bafdc399a9c86a65462fc8ddf3737de0","tree":"80b5bc277ffd7135c06c300471156630d0173634","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"b0222edd92ae02507975f5585f8c15f01ee5bd9f","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/obs-scene.c.h","libobs/obs-sceneitem-defer-update.c.h","test/cmocka/test_scene_item_defer_update.c","test/cmocka/tests.d/test_scene_item_defer_update.cmake"],"head":"a2a752b98449a1b7ea4b393ad681d3d4f8f595c5","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":"21fb69f4859a6bb5f22c18903ae10473b21e569884ae03f1e2c574cd5b80ecaf","tree":"80b5bc277ffd7135c06c300471156630d0173634"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 18, 2026 07:04
@rdoupe rdoupe changed the title libobs: Extract obs_sceneitem_defer_update_begin/end (Refs #4646) libobs: Characterize and extract obs_sceneitem_defer_update_begin/end Nov 18, 2026
@rdoupe
rdoupe enabled auto-merge November 18, 2026 07:33
@rdoupe
rdoupe added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit 136dcad Nov 18, 2026
43 checks passed
@rdoupe
rdoupe deleted the test/4646-defer-update-extract branch November 18, 2026 08:34
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.

libobs: characterize and extract scene-item transform-update deferral before Rust

1 participant