Skip to content

obs-util: Port the portal sleep inhibitor - #1660

Merged
zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:port/platform-nix-portal
Oct 22, 2026
Merged

zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:port/platform-nix-portal

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1631

What and why

The XDG portal sleep inhibitor (libobs/util/platform-nix-portal.c.h) is Rust on Linux and FreeBSD when GIO is found. It sits with the session D-Bus inhibitor (#1577) in LIBOBS_NIX_GIO_PORTED_SOURCES. The three entry points have no EXPORT, so the shims stay hidden. The C file remains the reference.

test_inhibit_portal includes the C file, so it still characterizes that file. test_inhibit_sleep is the public OFF/ON path.

Kept, characterized, not endorsed: destroying an active inhibit does not send Request.Close. Only portal_inhibit(..., false) does. A NULL reason becomes "". The other fields sit behind one mutex.

RED → GREEN

  • RED 5a2c20ea2, rebased onto ee148335c. Earlier SHAs of this commit: d375a1fb5, then e1891544e. Ten Tier 1 tests against todo!() panic with not yet implemented: test_discovery, test_request_and_success, test_rejected_responses, test_method_error, test_cancel_pending, test_destroy_pending, test_destroy_pending_close, test_response_before_reply, test_destroy_active, and test_discovery_logs_the_c_messages.
  • GREEN 792e1292c (was c17019f6e before this rebase). Arm64 image obs-rust-linux-validate:3b1aa631be7db514 (Ubuntu 26.04, image rustc 1.98.1, rust-lld). The GitHub ubuntu job is x86_64. cargo test -p obs-util --lib --locked portal_inhibit passed 17 tests: the 10 Tier 1 tests, 6 parity tests (discovery_matches_c, inhibit_and_release_matches_c, rejected_and_errors_match_c, cancel_and_destroy_match_c, response_before_reply_matches_c, random_response_matches_oracle), and nix_inhibit::test_portal_inhibit_and_release. The nix_inhibit filter passed 28. Setting INHIBIT_FLAGS to 0x4 failed inhibit_and_release_matches_c (Rust trace flags 4, C trace flags 12). Restored before the commit. cargo clippy --lib --locked -D warnings with --features gio on obs-util, and the same flags on obs-c-oracle and obs-build, was clean. Host export_list passed 3. The Docker command passed CFLAGS=-Wno-error so the pre-existing arm64 wchar_t warnings in dstr-libc.c.h and utf8.c.h stayed warnings. That flag is local only.
  • 27b82c4d3 names the test-host response callback. Fast Gate on c17019f6e failed clippy type_complexity on Rc<dyn Fn(u32)> in the two test hosts. After the alias, arm64 cargo clippy -p obs-util --all-targets --locked -D warnings no longer reports it, and the 17 portal tests passed again. That arm64 clippy still stops on two pre-existing unnecessary_cast notes in base_parity.rs and dstr_parity.rs, because c_char is unsigned there. x86_64 CI does not hit them.

Local CI before ready

  • Host soldr cargo fmt --all --check, workspace clippy -D warnings, and soldr cargo dylint --all -- --workspace --lib --bins passed. SOLDR_RUSTC_WRAPPER=none.
  • Host soldr cargo test --workspace --locked passed. The rust-test lane then stops on --target x86_64-pc-windows-gnu, which soldr will not host on this Mac. The cross lane stops on x86_64-pc-windows-msvc because the host cc has no Windows stdio.h.
  • Arm64 workspace cargo test is not the GitHub x86_64 job. With the workspace gio feature, dbus_inhibit_parity.rs does not compile here (c_char is unsigned). Left that file. The other crates failed in obs-graphics rounding (0x7f800001) and in two native_build tests that set CC=clang. This image has no clang.
  • Local Tier 2 (OBS_CTEST_JOBS=8) did not reach ctest. zccache lost 8 requests, the uncached recovery killed cc1plus, and the Mac Docker mount folded Obs.h onto obs.h (obs-frontend-api.h missing in the properties-dialog and screenshot tests). test_inhibit_sleep and test_inhibit_portal compiled. No portal error in the build log. Remote Tier 2 OFF and ON on c17019f6e already passed. This follow-up does not change the production inhibitor. Tier 4 does not apply.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (characterization is test: Characterize portal sleep inhibitor lifecycle #1633, 734ae280b; RED 5a2c20ea2; GREEN 792e1292c)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no flag change)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

@nathan-v
nathan-v force-pushed the port/platform-nix-portal branch 2 times, most recently from 6921a64 to c17019f Compare October 22, 2026 03:46
The safe core is todo!(). Ten Tier 1 tests mirror test_inhibit_portal
and panic not yet implemented.
The safe core follows platform-nix-portal.c. Ten Tier 1 tests cover the
cmocka cases, and the parity tests compare the host trace with the C
file. The three entry points stay hidden. The C file remains the
reference.
Rc<dyn Fn(u32)> in the test host fields trips clippy type_complexity
under -D warnings. Fast Gate stops there.
@nathan-v
nathan-v force-pushed the port/platform-nix-portal branch from c17019f to 27b82c4 Compare October 22, 2026 04:24
@nathan-v
nathan-v marked this pull request as ready for review October 22, 2026 04:25
@nathan-v
nathan-v requested a review from zackees as a code owner October 22, 2026 04:25
@zackees
zackees enabled auto-merge October 22, 2026 04:41
@zackees
zackees added this pull request to the merge queue Oct 22, 2026
Merged via the queue into obs-rust:master with commit 4131d2e Oct 22, 2026
27 checks passed
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.

rust: Port util/platform-nix-portal.c to obs-util

2 participants