Skip to content

rust: Port the canvas flag rules in obs-canvas.c to obs-core #2544

Closed

Description

@rdoupe

Rust port: the canvas flag rules and setter checks in libobs/obs-canvas.c.h, moved to obs-core as a new module canvas_rules, next to canvas_draw.

Scope

Rust takes over these decisions:

  • the flags each constructor passes: the main canvas's MAIN | PROGRAM, and obs_canvas_create, obs_canvas_create_private and obs_load_canvas masked to the public flags (load keeps its (uint32_t) cast of the saved int64 in C);
  • obs_canvas_create_internal: the view type (ACTIVATE gives the main view), the mix's mix_audio from MIX_AUDIO, and whether the canvas is named and signalled (not private);
  • obs_canvas_destroy: per source, whether a scene ref is released (SCENE_REF and a scene), and whether the name entry is removed (not private);
  • obs_save_canvas: no save for an ephemeral or removed canvas;
  • obs_canvas_has_valid_video_info and obs_canvas_reset_video_internal (mix_audio, the result);
  • obs_canvas_insert_source and obs_canvas_remove_source: the scene ref take and release, and the group walk only for a group;
  • obs_canvas_rename_source: the global source_rename signal only for the main canvas;
  • obs_canvas_reset_video: the refusal (no video info, the main canvas, video active);
  • obs_canvas_set_channel: the channel bound, the same-source shortcut, the global channel_change signal only for the main canvas, and the activate and deactivate steps;
  • obs_canvas_set_name: the refusals (no name, the main canvas, the same name), the private or hashed rename, and the global canvas_rename signal only for a public canvas;
  • obs_canvas_remove: the refusal for a removed or main canvas, and the new flags.

C keeps every read of canvas->flags where it is today (it is read without a lock, and obs_canvas_remove writes it from any thread), and asks the core with that read. C also keeps every allocation and free, the context data calls, the signal handler setup, the mutexes, obs_view_init/_free, the mix create and free under mixes_mutex, HASH_CLEAR and the walk that takes next before each release (the #2038 and #2049 order), obs_source_is_scene/_is_group, every ref and weak ref, channels_mutex, the calldata and every signal, obs_source_activate/_deactivate, strcmp (its result is passed in), obs_video_active(), obs_canvas_enum_scenes and every log.

Plan

The standard six commits:

  1. move;
  2. characterization test;
  3. Tier 1 RED;
  4. GREEN in a libobs.ported-* group;
  5. Tier 3 parity;
  6. docs.

Dependencies and existing tests

No other unit. Real-libobs tests that must stay green: the canvas tests under test/cmocka (ctest -N listed in the PR), test_view, and the multi-canvas frontend tests if any.

Notes

No SIMD, no per-OS code, no MSVC traps (masks and compares only; the int64 to uint32_t cast stays in C).

Activity

  1. added
    enhancement
    port
    on Oct 27, 2026
  2. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2544.

    1. Move the canvas flag rules and setter checks to libobs/obs-canvas-rules.c.h, one function per decision on plain values, behaviour-neutral (checked with a move harness).
    2. Characterization test (test_canvas_rules_steps).
    3. RED: Tier 1 tests of a new obs-core::canvas_rules module against todo!() stubs.
    4. GREEN: the core plus src/ffi/canvas_rules.rs, in libobs.ported-canvas-rules.
    5. Tier 3 parity against the C, with a mutation check.
    6. Docs.

    Draft PR once the RED commit exists, within the day.

  3. added
    ready
    on Oct 27, 2026
  4. moved this from In progress to In merge queue in obs-rust Multiviewon Oct 27, 2026
  5. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by PR #2546 (merged through the merge queue): the canvas flag rules and setter checks of libobs/obs-canvas.c.h now run in rust/obs-core as the canvas_rules module, seventeen hidden shims in the libobs.ported-canvas-rules group, with Tier 1, Tier 2 (including the new caller test) and Tier 3 parity tests. The exported symbol sets are unchanged.

    What is left: by design, the rest of obs-canvas.c.h stays C at its original points: allocations and frees, locks, the view and mix, HASH_CLEAR and the destroy walk, references, signals, obs_source_activate()/_deactivate() and logging. Kept as characterized, not endorsed: a saved flags value above 32 bits or negative keeps the low word's public flags; an out-of-enum video format counts as set; a removed canvas can still be reset and renamed.

    Follow-up issue: none filed. I found no open issue that tracks the remainder of the canvas code (searched open issues for "canvas" and "obs-canvas"), so the rest has no issue yet.

  6. moved this from In merge queue to Done in obs-rust Multiviewon Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions