Skip to content

bug: libobs: Rust libobs Linux builds no longer inhibit idle sleep while recording or streaming (regression from #403) #453

Closed

Description

@rdoupe

With ENABLE_RUST_LIBOBS=ON (the build the OBS-Studio-Rust .deb and AppImage ship), OBS on Linux no longer asks the desktop to stop idle sleep or locking while it records or streams. It only runs xdg-screensaver reset every 30 s, which does nothing on Hyprland and other wlroots compositors and may do nothing on GNOME. A long unattended recording or stream can be cut off by suspend, or a portal screencast blanked by the lock screen. Found in a review of the merges since #275; not reported by a user yet.

This is a regression from #403 (the platform-nix.c port, by Nathan V). OBS-Studio-Rust v0.1.0-beta.20261012 is the first release that contains it (Linux .deb and AppImage). The C build (ENABLE_RUST_LIBOBS=OFF) and the Flatpak, which does not turn the option on, are not affected. macOS and Windows keep their own C implementations and are not affected either.

Location

  • libobs/cmake/os-linux.cmake line 16, and os-freebsd.cmake line 30: util/platform-nix.c is left out when the option is ON.
  • os_inhibit_sleep_create, os_inhibit_sleep_set_active and os_inhibit_sleep_destroy then come from the Rust shims in rust/obs-util/src/ffi/platform_nix.rs (exported via libobs/cmake/rust-exports.d/obs-util-platform_nix.txt lines 35-37). nix::Inhibit in rust/obs-util/src/platform/unix/nix.rs (lines 1118-1244) ignores the reason and only starts a thread that runs xdg-screensaver reset every 30 s.
  • The C version (platform-nix.c, os_inhibit_sleep_create) first asks org.freedesktop.portal.Inhibit (platform-nix-portal.c, flags suspend and idle), then, outside a Flatpak, a session D-Bus inhibitor (org.freedesktop.ScreenSaver, org.freedesktop.PowerManagement.Inhibit, the MATE or GNOME session manager; platform-nix-dbus.c), and uses xdg-screensaver only when neither exists. Both files are still compiled with the option ON, but their only callers are in the excluded platform-nix.c, so they are dead code.
  • rust/README.md, the rust: Port libobs/util/platform-nix.c to obs-util #403 description and the comment in nix.rs say the portal and D-Bus files "stay C", which reads as if they were still used. The parity test skips this area ("Sleep inhibit is not compared").

Class

Silent loss of a recording or stream: suspend ends it, and nothing in OBS says the inhibitor is missing (no inhibitor shows up in the desktop's list for OBS).

How it is reached

  1. Install the OBS-Studio-Rust .deb or AppImage (beta.20261012 or later) on a Wayland desktop with an idle suspend or lock timeout (Hyprland with hypridle, a wlroots compositor, GNOME).
  2. Start a recording or stream and leave the machine alone longer than the timeout.

The machine suspends or locks. With the C build, OBS holds a portal (or ScreenSaver) inhibitor from the first output start to the last output stop, and the desktop stays awake.

Reproduced headlessly with a fake org.freedesktop.portal.Inhibit and a fake org.freedesktop.ScreenSaver on a private D-Bus bus: with the option ON, os_inhibit_sleep_set_active(true) makes no D-Bus call at all; with it OFF, it calls Inhibit with the reason and releases it on set_active(false).

Proposed fix and failing test

Fix: keep os_inhibit_sleep_* in C for Linux and FreeBSD in both lanes. Move it, unchanged, from platform-nix.c into a new util/platform-nix-inhibit.c that both lanes compile, and drop the three Rust shims, nix::Inhibit and their export entries, so there is one definition and the exported symbol set stays the same. The rest of the Rust port is unchanged. Update rust/README.md, the code comments and the parity test header.

RED test test_inhibit_sleep_dbus (no display; GTestDBus starts a private dbus-daemon, skipped without one):

  • test_portal_inhibit_and_release: a fake portal owns org.freedesktop.portal.Desktop. set_active(true) must call Inhibit with the reason and flags 0xC; set_active(false) must close the returned request.
  • test_screensaver_inhibit_and_release: no portal, a fake org.freedesktop.ScreenSaver. set_active(true) must call Inhibit("libobs", reason); set_active(false) must call UnInhibit with the same cookie.

Both fail with the option ON and pass with it OFF.

Activity

  1. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_inhibit_sleep_dbus (no display): fake org.freedesktop.portal.Inhibit and org.freedesktop.ScreenSaver on a private session bus; os_inhibit_sleep_set_active(true) must call Inhibit with the reason and set_active(false) must release it. 0 of 2 pass in the Rust lane today, 2 of 2 in the C lane.
    2. GREEN: keep the Linux/FreeBSD sleep inhibitor in C for both lanes (moved unchanged into platform-nix-inhibit.c) and drop the Rust stand-in.
      PR today.
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