Skip to content

test: Extract and characterize canvas channel replacement before Rust swap #5134

Done

Description

@zackees

Scout C / rank 12: C-only prerequisite for the remaining Phase 6 canvas channel replacement orchestration, later targeting obs-core. Snapshot: master 5889b3936 (2026-11-18). This follows the existing policy/helper ports; it does not repeat them.

Context and scope

Exported entry points: obs_canvas_set_channel. Their live C definitions remain in libobs/obs-canvas.c.h:360-406. Public declarations are in the unchanged libobs headers.

Move only these public bodies verbatim to proposed libobs/obs-canvas-channel-setter.c.h, in the existing libobs/build/libobs.core-source+.h.c PCH family. Keep signatures, behavior, private dependency semantics and all original read/callback ordering unchanged. No Rust in this prerequisite; the whole-file Rust swap is a separate follow-up after this lands.

Rust-side confirmation: rust/obs-core/src/ffi/canvas_channel_getter.rs:20-36 exports only get_channel, delegating to view acquisition. canvas_rules.rs:158-166 contains global-signal/channel predicates only, and its docs explicitly leave calldata, mutexes, reference operations and activation in C. Both exact-name Rust hits for set_channel are comments. #4709's output-source API is a caller, not this canvas setter.

Characterization and build brief

Preserve channel assertion/bound check, channels_mutex scope, incoming strong-reference acquisition and same-source release/unlock shortcut. Emit local channel_change and conditional global signal with exact canvas/channel/prev_source/source calldata, reread callback-replaced source, store it while locked, free calldata and unlock before activation/deactivation/release. Keep the callback replacement's existing reference imbalance exactly as characterized in unchanged test_canvas_rules_callers::channel_replace (536-593); do not fix ownership during conversion. Pin initial/replace/same/clear cases, global MAIN routing, callback-observed ordering and activation, using real-header fixtures or a deterministic recorder. No invalid-channel test in an assertion-enabled process unless isolated.

Existing coverage to preserve: test/cmocka/test_canvas_rules_callers.c:536-593; test/cmocka/test_canvas_rules_steps.c

Dependencies and sequencing: No functional prerequisite. Use existing canvas/view layout boundaries and C-owned mutex/signal operations; preserve every flags read at its original point, especially across callbacks. Serialize canvas siblings. This is the largest C-only unit in this list, but remains one 47-line public body with a mature unchanged caller characterization.

Acceptance criteria

  • Reuse every applicable existing C characterization unchanged. Where coverage is incomplete, add a new focused test (never rewrite an existing C test). Show baseline behavior against unchanged original C first. Record RED for the missing extraction seam/new focused contract before GREEN; if the existing tests already pin the complete contract, use a focused extraction/build contract rather than inventing redundant assertions.
  • Extract the selected bodies behavior-neutrally in a separate C-only commit/PR; no public-header or signature edits, no existing C-test edits, no WebSocket plugin changes, no new workflow files. Scope any unity-local aliases/macros and undefine them at file end. New source membership and sorted metadata must agree.
  • Run the focused C tests against both C-reference and hybrid libobs, verify equal public symbol sets, and check affected native-build registrations. Run the repository lint once. Preserve host conditions from existing fixtures and validate Windows MSVC fixture linkage as applicable; no max_align_t or out-of-range enum sentinels.
  • Later swap: mirror the unchanged C assertions in the existing Core state / obs-data --test obs-tests-core category (no new Rust executable), commit Tier 1 RED before GREEN, add original-C Tier 3 differential/mutation coverage, and link any real private adapter into every affected Rust-static consumer. Rust through soldr, Python through uv; publication through ./push. Tier 4 is inapplicable to these non-protocol entry points; existing C++ WebSocket compatibility remains required.

Append points / lane CAV / core-source: libobs/build/libobs.core-source+.h.c; libobs/build/modules.d/core.json; applicable existing source inventories. New characterization only: test/cmocka/test_canvas_channel_setter.c, its tests.d fragment and sorted test/cmocka/build/test-graph.json registration. Later Rust append points are rust/obs-core/src/lib.rs, src/ffi/mod.rs, its existing category suite modules, per-unit source/export/oracle fragments and applicable real-adapter link-support fragments. Use existing native groups unless BUILD.md justifies a distinct family; a different source filename does not make the group independent.

Decisions

P2 / port / size:S / ready: the deliverable is one small, deterministic C extraction/characterization prerequisite, not the later Rust implementation or a behavior fix. Existing helper ports are reusable dependencies, not proof that the public entry points are ported. Naming is proposed and may follow equivalent current repository conventions. Coordinate shared-file/group landings and refresh claims immediately before implementation. This issue is unclaimed; the scout posted no Claiming comment.

Activity

  1. added
    port
    ready
    P2
    size:S
    on Nov 18, 2026
  2. wesleyhawes commented on Nov 18, 2026

    @wesleyhawes
    Contributor

    Claiming: characterize and extract obs_canvas_set_channel as a behavior-neutral C-only prerequisite.

    1. Add focused GPU-free characterization of initial assignment, replacement, same-source, clear, callback ordering, signal routing and activation/deactivation; keep existing C tests unchanged.
    2. Run the new fixture against the original C implementation, extract the public bodies verbatim into the canvas unity group, then rerun against C-reference and hybrid libobs.
    3. Verify symbol parity, native registration and full lint; open a focused PR after the required gates pass.

    I expect to open the first PR after the local C-reference/hybrid and lint gates complete.

  3. moved this from In progress to Ready in obs-rust Multiviewon Nov 19, 2026
  4. wesleyhawes commented on Nov 23, 2026

    @wesleyhawes
    Contributor

    Progress: the characterization PR #5142 merged as b80dfb17, with the focused test passing 100 serial runs against both the C reference and hybrid libobs. I’ve refreshed this branch onto master at 40fe9a883 and confirmed there is no competing open PR for obs_canvas_set_channel.

    I’m proceeding with the separate behavior-neutral C extraction. I’ll preserve the function body’s existing mutex, signal, reference, callback, activation and release ordering; the existing caller characterization remains responsible for callback-observed replacement behavior.

  5. wesleyhawes commented on Nov 23, 2026

    @wesleyhawes
    Contributor

    Progress: draft PR #5547 now contains the behavior-neutral extraction with a separate RED/GREEN pair. RED 9bfade4a6 exposed the orphaned .c.h through test_build_groups; GREEN 2d4cae72d registers it in the existing sorted core-source group. The group/module/source-fragment checks pass. Hosted native checks are pending fork-workflow approval; the PR remains draft until both Tier 2 modes and symbol parity pass.

  6. moved this from Ready to In review in obs-rust Multiviewon Nov 24, 2026
  7. vpacher commented on Nov 24, 2026

    @vpacher
    Member

    /reassign @wesleyhawes

  8. zackees commented on Dec 3, 2026

    @zackees
    MemberAuthor

    /reassign @wesleyhawes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2portreadysize:S

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions