Skip to content

meta: 10 libobs units to move from C to Rust next #1846

Closed

Description

@zackees

Goal

Move more of libobs from C to Rust, faster. The hybrid build (libobs/build/source-sets.json) still compiles about 25,000 lines of unported libobs C. The biggest files (obs-source, obs-scene, obs.c, graphics.c, obs-output, obs-encoder) need seams first (#444), so they move slowly. This meta picks 10 units that can each delete a whole .c.h file (or a clean slice of one) from the production unity groups, with no open seam work and no overlap with claimed issues.

Selection rules:

Units (one issue and one PR each)

Each worker files the unit issue (format like #1822), claims it, and ticks it here.

Units 1–8 are independent and can run in parallel. 3 waits on #152 if that has not merged. 9 and 10 are the first slices of large files; each should close by filing its next slice here.

Common rules

  • docs/rust-port/testing-policy.md, all four tiers: characterization in test/cmocka/ against the C first (Tier 2, unchanged afterwards), RED then GREEN, Tier 1 unit tests, Tier 3 differential against the oracle in rust/obs-c-oracle/legacy/.
  • Move the include into a ported-* group in libobs/build/source-sets.json (see docs/rust-port/hybrid-build.md, "Migrating another unit"), check that the production build excludes the C and the C reference still includes it.
  • Add cases to the category's existing test binary; no new test executables.
  • Exported symbols and public headers stay unchanged.
  • Each PR records port_comparison numbers for its unit.

Done when

All 10 boxes are ticked and the listed C is out of the production libobs build (about 2,800 lines from units 1–8 removed whole, plus the first slices of obs-module and obs-audio, with their next slices filed).

Related: #444 (Phase 6), #153 (Phase 4), #45 (Phase 5), #4 (roadmap).

Activity

  1. rdoupe commented on Oct 23, 2026

    @rdoupe
    Collaborator

    A note on unit 8 (obs-service.c.h), from checking it before claiming: it does need a seam. Only the four obs_weak_service_* functions avoid private layout. The rest read:

    • struct obs_service fields after struct obs_context_data (info, active, destroy, output, owns_info_id), plus create's bzalloc(sizeof(struct obs_service));
    • struct obs_output (actually_destroy_service() clears service->output->service);
    • obs core (find_service() walks obs->service_types; create links into obs->data.first_service under services_mutex);
    • struct obs_module (obs_service_get_module() walks the module lists).

    obs-output.c.h, obs.c.h and obs-hotkey.c.h also read struct obs_service directly, so the struct can't move either. A port would be a #1550-style seam PR (hidden field/allocator/registry accessors) and then the port, so two PRs rather than one. I'm not claiming unit 8 for that reason, and am taking a different unit instead.

  2. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Unit 1 (util/platform-conversions.c.h) is already #262 slice 1, claimed by @rdoupe on 2026-10-21 (the move and test_platform_conversions landed; the port is theirs). I am leaving it to them and not opening a parallel PR; the box ticks when their port merges.

    Found while reading it, for whoever ports it: os_utf8_to_wcs passes out_len + 1 (= dst_size) as the capacity to utf8_to_wchar, so text exactly dst_size wide characters long converts in full and dst[dst_size] = 0 writes one past the buffer. os_wcs_to_utf8 passes dst_size - 1 and does not have this. A Rust slice port cannot write past dst, so it will differ there and should list it as an intentional difference.

  3. rdoupe commented on Oct 23, 2026

    @rdoupe
    Collaborator

    Unit 2 (util/dstr-libc.c.h): #1858, PR #1859. Withdrawn: #1855 / #1857 claimed unit 2 first. #1858 is closed as a duplicate and #1859 is closed.

  4. rdoupe commented on Oct 23, 2026

    @rdoupe
    Collaborator

    Unit 5 (graphics/texture-render.c.h): #1860, PR #1861. No seam needed: the file only calls public gs_* functions. Tier 3 compares against the original through a recording gs_* stand-in in obs-c-oracle, so no GPU and no CI change. One deviation from the common rules: the cmocka characterization is a new executable, test_texture_render, because no existing graphics test fakes a device. #1823's test_effect_lookups is the precedent; the Rust side adds a module to the existing obs-tests-graphics.

  5. rdoupe commented on Oct 23, 2026

    @rdoupe
    Collaborator

    Unit 9 (obs-module.c.h slice 1: search paths, data-path lookup, module info list): claimed in #1876.

  6. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Unit 4 (util/source-profiler.c.h): #1886, into obs-core. No seam needed: the two private reads already have accessors with the same result (obs_enter_graphics/obs_leave_graphics, obs_source_get_output_flags), details in #1886.

  7. rdoupe commented on Oct 23, 2026

    @rdoupe
    Collaborator

    Unit 9 slice 1 (module search paths): #1876, PR #1894. No seam: C passes module->data_path and each obs->module_paths entry in, plus the platform extension and the macOS bundle hook; the walk, obs_add_module_path and all loading stay C. The extraction is its own behaviour-neutral commit inside the one PR. Next slice candidates: obs_module_get_config_path and get_module_name.

  8. 5 remaining items

  9. vpacher commented on Oct 23, 2026

    @vpacher
    Member

    Unit 10 (obs-audio.c.h slice 1: the mix window and add loop, convert_time_to_frames, and the tick and timestamp arithmetic of the two buffering functions): claimed in #1903. No seam: the extracted helpers take plain values, and the source walk, locks, logging and deques stay C (precedent #1814 / #1842). Correction: obs-audio.c.h does not clamp, the clamping is in media-io/audio-io. Next slice candidates: ignore_audio / discard_audio, then the min-timestamp search.

  10. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Unit 6 (graphics/image-file.c.h): claimed in #1907.

  11. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Unit 7 (media-io/media-remux.c.h) needs a decision first. The unit text says "same FFmpeg FFI pattern as the media-io units already ported", but no Rust crate links FFmpeg today: no avutil or avformat in any Cargo.toml or build.rs, and the oracle doesn't link it either. The file's logic is packet timestamp math built on av_rescale_q_rnd and av_rescale_delta (with its per-stream state), plus the av_read_frame / av_interleaved_write_frame loop.

    There are two ways to do it, and each is a choice for maintainers:

    1. Link libavutil and libavformat into obs-media-io and the oracle. That's a new native dependency for the cargo test lanes on all three hosts.
    2. Reimplement the av_rescale* arithmetic in Rust for a pure timestamp core, and keep the FFmpeg I/O loop in C. The differential test would still need libavutil as the oracle for the rescale math.

    Decision needed: which one, or leave unit 7 until the FFmpeg-facing plugins are in scope. Units 1 and 5 are done (#1874, #1861), I ticked their boxes, and unit 8 slice 1 is #1899 (#1901 characterization, #1904 port).

  12. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Unit 7 filed and claimed: #1927 (media-remux → obs-media-io).

  13. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    All 10 units have landed. Mine: 2 (#1857), 3 (#1875), 4 (#1887), 6 (#1911), 7 (#1928). Other contributors: 1, 5, 8, 9, 10. Further obs-audio and obs-module slices continue under #1903 and #1876.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions