Skip to content

test: characterize canvas channel replacement - #5142

Merged
vpacher merged 3 commits into
obs-rust:masterfrom
wesleyhawes:test/canvas-channel-setter
Nov 23, 2026
Merged

vpacher merged 3 commits into
obs-rust:masterfrom
wesleyhawes:test/canvas-channel-setter

Conversation

@wesleyhawes

@wesleyhawes wesleyhawes commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a GPU-free C characterization for obs_canvas_set_channel: initial assignment, same-source no-op, replacement, clear, local/global signal routing, and signal payloads.
  • Assert activation at the synchronous source-refcount level. This fixture does not start a video tick and therefore makes no claim about deferred activate/deactivate callback ordering.
  • Register the fixture in the shared native CMake/Cargo test graph without modifying existing C tests.
  • Preserve callback-replacement ownership coverage in the existing caller test.

This is the characterization stage for #5134. The production C extraction will follow after the baseline fixture is confirmed by CI.

Validation

  • uv run ci/test_test_graph_sorted.py — passed.
  • git diff --check — passed.
  • Focused Tier 2 C test (test_canvas_channel_setter) — passed 100 serial repeats against both libobs-c-reference and hybrid libobs, under the repository's xvfb-run wrapper.
  • Full Tier 2 Linux suite — stopped after the first 500 of 1,066 tests passed without failures; the full suite remains unverified.
  • Client-lint formatting and static checks passed. The local native Rust/Clippy build could not complete because required host C/GIO development dependencies are unavailable; hosted CI remains needed for that lane.

@wesleyhawes
wesleyhawes requested a review from zackees as a code owner November 18, 2026 20:54
@wesleyhawes
wesleyhawes marked this pull request as draft November 18, 2026 20:55
@wesleyhawes

wesleyhawes commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto current master at 0419d4a26 to resolve the test-graph conflict. uv run ci/test_test_graph_sorted.py and git diff --check pass at head 89bc23b. GitHub's new Pull run is action_required with no jobs, so the baseline native test still has not run. Could a maintainer approve the fork workflow for this head? The local OBS client lint stopped at Clippy because the shared build volume has under 1 GiB free; I have not claimed native test success. Once the characterization test passes, I’ll proceed with the behavior-preserving extraction.

@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 (2026-11-21).

Read the diff against master: one new GPU-free cmocka fixture, test_canvas_channel_setter, registered once in test/cmocka/build/test-graph.json. No existing C test or public header is touched.

Correctness: each assertion matches obs_canvas_set_channel in libobs/obs-canvas.c.h:

  • The local signal fires, then the global one, and the global one only for the main canvas (obs-canvas.c.h:311-313).
  • Reinstalling the same source is a no-op.
  • On replacement, the incoming source is activated before the outgoing one is deactivated.

Reference handling is balanced: obs_get_main_canvas() returns a reference, which teardown releases, and the obs_canvas_get_channel() reference is released too.

Tiers: this is the characterization stage under the testing policy's "units without C tests" section. The extraction PR for #5134 will need the RED → GREEN pair, and Tier 2 must pass against both the hybrid build and the C reference. This PR is test-only, so it needs no features-ledger line.

Nits (not blocking):

  • tests.d/canvas_channel_setter.cmake contains only a comment. If the graph is the single registration point, check whether other fixtures keep an empty tests.d stub. If they don't, drop it.
  • Please confirm the test passes 100 serial repeats (rust/tools/linux-validate/run.py --repeat 100 --tests test_canvas_channel_setter). It is a signal and activation ordering test, and the policy asks for that on threading-adjacent cases.

Because this PR comes from a fork, its CI had not run since 2026-11-18 (action_required). I approved the pending runs. I'll queue the PR once CI is green.

@zackees

zackees commented Nov 21, 2026

Copy link
Copy Markdown
Member

Coordinator: CI ran (Tier 2 Linux, tests OFF and ON, both fail the same way), and the new test fails on its first assertion block:

[  ERROR   ] --- 2 != 3
[   LINE   ] --- test/cmocka/test_canvas_channel_setter.c:207: error: Failure!

(job log)

Cause: obs_canvas_set_channel() calls obs_source_activate() synchronously, and that only increments the activate and show refcounts. The source's activate/deactivate callbacks run later, from obs_source_video_tick() (libobs/obs-source.c.h:1081-1083, the now_active edge). This fixture starts libobs without obs_reset_video(), so no video thread ticks and the 'A'/'D' events never arrive. The log gets the local and global signals only. The C reference fails the same way, so the test's expectation is what's wrong, not the port.

Two ways to fix it, without touching libobs:

  1. Keep the fixture GPU-free: drop the 'A'/'D' records from events.count and the ordering assertions. Assert activation through obs_source_active() (which reads the refcount), as the test already does after each step.
  2. If the activation order matters to test: Extract and characterize canvas channel replacement before Rust swap #5134, start video in the fixture and drive ticks deterministically (wait for the tick, as test_destroy_queue_video_sync.c does; no sleeps), then assert the callback order.

Option 1 matches the PR's stated scope (signal routing, payloads, refcount-level activation). Once it is green, the coordinator will queue it.

@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Needs fix in obs-rust Multiview Nov 22, 2026
@wesleyhawes

Copy link
Copy Markdown
Contributor Author

I updated the characterization to match the fixture’s execution model: source active refcounts change synchronously, while activate/deactivate callbacks are deferred until a video tick. The test now asserts refcounts and local/global signal payloads without claiming callback ordering.

The focused Tier 2 test_canvas_channel_setter passed against libobs-c-reference under the repository’s xvfb-run wrapper. The full Tier 2 suite is still running locally. The latest commit currently has no hosted checks reported; could a maintainer approve/re-enable the fork workflow for this updated head so the required hosted checks can run?

@wesleyhawes

Copy link
Copy Markdown
Contributor Author

Follow-up: I ran the coordinator-requested 100 serial repetitions. test_canvas_channel_setter passed all 100 runs against both libobs-c-reference and hybrid libobs under the Tier 2 container’s Xvfb wrapper. The broader suite had 500/1,066 tests pass without failure before I stopped it; I am not claiming a full-suite pass. The new PR head still has no hosted checks, so the workflow approval request remains open.

@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to In review in obs-rust Multiview Nov 23, 2026
@vpacher

vpacher commented Nov 23, 2026

Copy link
Copy Markdown
Member

Coordinator: approved the fork workflow run for bc9a232, so PR CI is running now. The diff is test-only (the new cmocka fixture, its comment-only tests.d fragment and the graph entry). I read the new assertions against obs_canvas_set_channel() (libobs/obs-canvas.c.h:284): the main canvas raises the active refcount synchronously, and a non-main canvas only raises the show refcount (its view type is not the main view), so obs_source_active() stays false there, as the test says. If CI is green, I will queue it.

@vpacher
vpacher force-pushed the test/canvas-channel-setter branch from bc9a232 to fc8dfb3 Compare November 23, 2026 12:45
@vpacher
vpacher added this pull request to the merge queue Nov 23, 2026
Merged via the queue into obs-rust:master with commit b80dfb1 Nov 23, 2026
43 checks passed
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Done in obs-rust Multiview Nov 23, 2026
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.

3 participants