Repository navigation
obs-source: port obs_source_restore_filters to Rust (Fixes #5801) - #5802
Conversation
6de53cc to
0fd4cff
Compare
0fd4cff to
6ce0fca
Compare
6ce0fca to
5f9c735
Compare
Move obs_source_restore_filters() unchanged out of obs-source.c.h into obs-source-restore-filters.c.h, still compiled in the live core-source group. It is EXPORT and declared in obs.h, and the filter chain rules it asks are declared in obs-source-filter-chain.h (in the precompiled header), so the earlier position in the unity group needs no new declaration. No Rust, no behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New cmocka test through the real core (xvfb-run, skips without a display), against hybrid libobs and the C reference: a NULL source or array logs the validity check's line once (the source first) with filter_mutex free and changes nothing. Otherwise each array item reuses the first current filter whose name matches (the same filter, whatever the item's id; an unnamed filter never matches, not even an item named "", since no filter can have a blank name) or is loaded from its data, while the list is empty, the old filters have no parent and no target, and filter_mutex is free (probed from a second thread when a filter type's create callback runs). Each restored filter targets the next, the last the source; while a later item loads, an earlier one already targets its successor but has no parent yet: the parents are set once every target is (#2172). The new list holds one reference per entry, so a duplicated name lists the same filter twice with two references; the old filters are released once each, in old order, after the new list is in place and with the lock free, and one not reused goes away. No filter signal fires, and nothing logs when every item is reused. Whether a load is public or private is not checked (the C reference loads public, hybrid libobs private, a difference of the filter chain rules, #2981); a current filter whose last reference is gone can't be listed, so it goes to Tier 1 and Tier 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New obs-source module restore_filters with a todo!() core over a
RestoreList trait, and Tier 1 mirrors of test_source_restore_filters.c
on a model that records every call and checks the lock state of each:
the NULL lines (source first) with nothing touched; on every chain of up
to 6 current filters (an unnamed one, an empty name, a repeated name)
with every array of up to 3 items, with no filter or each listed one
unreferenceable, the C's order: under the lock each filter read and
unlinked and the list freed; with the lock free, per item the item and
its name, each current name until the first match and its reference,
the load (private, by the chain rule) when there is none or the
reference fails, the previous filter's target, the item's release; then
the last target, every parent, the new list stored under the lock, and
each old filter released in old order. Also the end state: the chain of
targets, the parents, one reference per listing, the old filters
unlinked and released, every item released.
soldr cargo test -p obs-data --test obs-tests-core -- source::restore_filters::
test result: FAILED. 0 passed; 7 failed
panicked at rust/obs-source/src/restore_filters.rs:104:5: not yet implemented: #5801
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Safe core restore_filters::restore over the RestoreList trait, with
source_filter_chain's restore match and restore step, and the shim in
ffi::source_restore_filters: the exported obs_source_restore_filters()
(rust-exports.d). The shim rejects NULL before any adapter runs; the
lock, the list reads, the unlinks, da_free(), the name reads,
obs_source_get_ref(), obs_load_source() and obs_load_private_source(),
the target and parent writes, the move of the new list into the source,
obs_source_release() and the obs_data array and item calls stay C in the
new obs-source-restore-filters-fields.c.h (live core-source group, no
EXPORT). The extracted C moves to the reference-only group
libobs.ported-source-restore-filters.
Tier 3 (restore_filters_parity, oracle source_restore_filters.c): the
original C and the Rust export on noise-filled real-header sources with
a stand-in array and recording references, loads and releases, over
every chain of 0 to 6 current filters (an unnamed one, a repeated name)
with every array of up to 3 items over 7 names plus longer patterns
(reusing, loading, duplicating and dropping filters), with no filter or
each listed one unreferenceable, and a proptest of up to 6 items. It
compares the new list, every target and parent, each item read, name
read and item release, reference, load and release in order with the
lock state and a digest of the list and every link at that moment, the
NULL lines, every other byte, the lock after and the item holds, and
rejects seven mutants. Registration test in obs-build; rust/README row.
soldr cargo test -p obs-data --test obs-tests-core -- source::restore_filters
test result: ok. 8 passed; 0 failed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795768045,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":95,"stamp":"92eba974e1ece5c8891f92c0beca9581","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795768045,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":95,"stamp":"0c5b3123b94f39ab68d033c2782bd5ad","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795768045,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":95,"stamp":"c5b1a844764aa1233b96083dfc054af8","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795768045,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":95,"stamp":"e7f0306f8bb64b3b65d5d9db3ab07cf2","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767948,"gate":"general/all/client-lint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"932c69a5bd4c3e05d56ac7ab43ff590c","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795768045,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":95,"stamp":"0f8e186c499bd4635e9122f272b4f648","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"0e7a26dd59cba6ceec2c72d421a19b3d","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"348dca7d135c5c08f39e95e823f5d9dd","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"597967026e038b02160ea166a5d3a1f3","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"95482b3a3342c8c9d71d27352c5b3c0f","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"77a64358b37aed9c1f06daeba44e66d0","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"0f95cded713930eca10005e392f16328","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"f8a017f5830c53988be4d7889605b607","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"515e1dc4ad39b45da879d4f3a321f9dc","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"6d57232f5533ce0dd42d09c972f6a702","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767949,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"d7158e2e0fd273d9107426d3ed56ae2c","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767948,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"bb95a366de0d7329f0d5d59be55a37e7","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795767948,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"654254869fdde294ac20c0aa79f7e78803489e5e7d1d8a2b11b4531529206646","lane":"client-lint","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":65,"stamp":"810a9aa9139f264a126627142eb4df6f","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Ci-Attestation: {"at":1795768305,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"c0a1b8675b84ad7474fd7c46d9143975033a8a667335d09f5ebcd30401ac9393","lane":"client-test-x86_64-unknown-linux-gnu","parents":["09be301526b7cfe0aea40c00a169db7b1d6613b2"],"secs":260,"stamp":"74d5869676e4d0bfb954ca3a78c98e16","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76","v":1,"via":"run"}
Client-Checks: {"checks":{"base":"723cd1c803bdee2e57f782a969203de768d45677","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-restore-filters+.h.c","libobs/build/ported-source-sets/source-restore-filters.json","libobs/cmake/rust-exports.d/obs-source-source_restore_filters.txt","libobs/obs-source-restore-filters-fields.c.h","libobs/obs-source-restore-filters.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_restore_filters_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-restore-filters.list","rust/obs-c-oracle/oracle/source_restore_filters.c","rust/obs-source/Cargo.toml","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_restore_filters.rs","rust/obs-source/src/lib.rs","rust/obs-source/src/restore_filters.rs","rust/obs-source/tests/source/main.rs","rust/obs-source/tests/source/restore_filters.rs","rust/obs-source/tests/source/restore_filters_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_restore_filters.c","test/cmocka/tests.d/test_source_restore_filters.cmake"],"head":"04b12d50daddfd4a758c3283cfa4ed7ad3e49d4e","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":"663cce4d0285db6663ba0457beeefc38ed2915f544fd3158f3dc0ea061726ed2","tree":"a17d3dc91777467c45032df16f9c8ac3dcd7be76"}}
5f9c735 to
000eb16
Compare
|
Coordinator: rebased onto master after #5812 landed. The only conflict was the |
vpacher
left a comment
There was a problem hiding this comment.
Coordinator review of 000eb16 (after my rebase onto #5812).
- The structure follows the testing policy: a verbatim extract, the cmocka characterization against both libraries, RED over a
todo!()core, then GREEN with the swap, the Tier 3 differential (restore_filters_paritywithoracle/source_restore_filters.c) and the registration test. Tier 2 and Tier 3 are both present, and the Tier 3 mutants are a good check. - The hybrid public-versus-private load difference comes from
restore_step(#2981), and the PR body explains it. The characterization correctly does not assert that difference. - No public header, existing C test or workflow changes. No user-visible change, so no features ledger line is needed.
One request (obs-worker §4, #2888): the PR adds Rust tests (Tier 1 restore_filters, Tier 3 restore_filters_parity with a proptest), but the body has no "Test cost" line. Please add one (the added wall time of obs-tests-core and the new cmocka test). It is a body edit only, so auto-merge stays on.
|
Added the Test cost line to the body: 8 |
Fixes #5801.
Rebased onto master after the
obs_source_filter_removeport (#5796) and the filter-copy port (#5794) merged; the only conflict was the obs-source crate description line. Re-verified on the rebased head 6ce0fca:./lintclean;soldr cargo test -p obs-data --test obs-tests-core -- source::restore_filters8 passed;soldr cargo test -p obs-studio-rust --test obs-tests-app -- source_restore_filters1 passed; Tier 2uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_source_restore_filters|test_source_filter_': symbols IDENTICAL (1769), 1129/1129 on both libraries, selected set 9/9.Ports
obs_source_restore_filters()toobs-source. The safe corerestore_filters::restoreruns over aRestoreListtrait and reusessource_filter_chain'srestore_matchesandrestore_step. The exported entry is the shim inffi::source_restore_filters(listed inrust-exports.d); it rejects NULL before any adapter runs.What stays C: the lock, the count and entry reads, the parent and target writes (the unlink and the relink),
da_free(), the move of the new list into the source, the name read,obs_source_get_ref(),obs_load_source()/obs_load_private_source(),obs_source_release(), and theobs_dataarray and item calls (count, item,"name"string, release). The Rust core reaches them through hidden, non-EXPORT adapters inlibobs/obs-source-restore-filters-fields.c.h, in the live core-source group. The extracted C builds in the reference grouplibobs.ported-source-restore-filtersfor Tier 3.One note on the issue's contract: it says an unmatched item is loaded with
obs_load_source(). That is the C reference. Hybrid libobs already asksobs_source_filter_chain_restore_step(), which is Rust and returnsLOAD_PRIVATE(the intentional difference of #2981), so hybrid loads withobs_load_private_source(). The port keeps that: it followsrestore_step, and the adapter file has both loads. The characterization doesn't check whether a load is public or private, because the two libraries differ there by design.The four commits, in order:
obs_source_restore_filters()moves unchanged intolibobs/obs-source-restore-filters.c.h, still in the live core-source group. No behavior change.test_source_restore_filters, through the real core against both hybrid libobs and the C reference. It covers:filter_mutexfree; nothing changed.id) and drops the rest. Nothing logs and no filter signal fires.filter_mutexis free (probed from a second thread inside the filter type'screatecallback).filter_removeon each old filter's destruction). A filter that isn't reused goes away.""matches nothing either, since no filter can have a blank name (libobs gives it a generated one).todo!()core.No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply. No user-visible change, so no features ledger line.
RED
GREEN
Tier 1 and Tier 3, on the pushed head:
restore_filters_parity, withoracle/source_restore_filters.c, runs the original C and the Rust export on noise-filled sources built from the real headers. Both sides get the same stand-inobs_dataarray and the same recordingobs_source_get_ref(), loads andobs_source_release(). It compares: the new list; every target and parent, current and loaded; each item read, name read, item release, reference, load (public or private) and release, in order, with the lock state and a digest of the list and every link at that moment; the NULL log lines; every other fixture byte; the lock afterwards; and the item hold balance.Tier 2, the C test against both libraries (full suite, then the repeat):
Run directly under
xvfb-runin the kept build volume,test_source_restore_filtersshows[ PASSED ] 8 test(s)against hybrid libobs and againstlibobs-c-reference, none skipped.Registration:
./lintpasses.ci/windows_link_check.pylinked the workspace test binaries forx86_64-pc-windows-msvcand all Tier 2 win-x64 binaries; I stopped it before its later stages../pushran prooft's client lanes (clippy and Dylint on all six targets, 10172 host tests passed), but the final commit isn't signed here, so the PR runs the full selected CI.Test cost:
obs-tests-coregains 8 cases (restore_filters+restore_filters_paritywith its proptest), 1.91 s wall locally (soldr cargo test -p obs-data --test obs-tests-core -- restore_filters); the new cmockatest_source_restore_filterstakes 0.08 s in the Tier 2 Linux job.🤖 Generated with Claude Code