Skip to content

fix(obs-util): the portal sleep inhibitor drops its bus connection at destroy (#3444) - #3447

Merged
vpacher merged 2 commits into
masterfrom
fix/3444-portal-inhibit-conn
Nov 1, 2026
Merged

vpacher merged 2 commits into
masterfrom
fix/3444-portal-inhibit-conn

Conversation

@vpacher

@vpacher vpacher commented Nov 1, 2026

Copy link
Copy Markdown
Member

Fixes #3444.

What

portal_inhibit_info_destroy() (libobs/util/platform-nix-portal.c.h) clears the bus connection at once (g_clear_object(&info->c)), even while a pending Inhibit call or the Response subscription still holds the info. The Rust port (#1660) kept the connection in Shared, which the GIO callbacks keep alive until GIO frees them on a later main-context iteration. With no such iteration after the last destroy, the connection outlives Portal::destroy, and disposing GTestDBus waits 30 s for it (GLib-GIO-WARNING: Weak notify timeout, object ref_count=1).

In the app, Qt iterates the GLib loop, so the reference goes soon after; no user-visible change. #1660 and the documented intentional differences (parity test header, rust/README.md) do not list the connection lifetime, so this brings the port back to the C.

Fix

Shared keeps the connection in a Mutex<Option<Arc<_>>>. Portal::destroy takes it out after it unsubscribes, in the C's order. Each call clones the Arc and drops the lock before it reaches GIO, so a callback on the same stack cannot block on it. A call after destroy finds no connection and does nothing; the callbacks already return on destroying before they would use it.

RED → GREEN

  • RED 8ddebb0: the fake transport's connection counts its drops; test_destroy_pending_drops_the_connection destroys the inhibitor while its Inhibit call is pending. Fails: 0 drops at destroy, want 1.
  • GREEN 62b2e1a: the 50 inhibit tests pass (Tier 1 and the Tier 3 parity suite against the C oracle). Local gate passes all lanes (stamped).
  • Tier 2, test_inhibit_sleep_dbus against the hybrid libobs (same test binary): 32.2 s before, 2.18 s after, no weak-notify warning; libobs-c-reference 2.2 s. The sanitizer passes and valgrind save the same 30 s.
  • Test cost: the new test runs in under 0.01 s, no own threads. Tier 4 does not apply.

🤖 Generated with Claude Code

vpacher and others added 2 commits November 1, 2026 21:21
…on at destroy (#3444)

portal_inhibit_info_destroy() clears info->c at once, even while a
pending Inhibit call or the Response subscription still holds the info.
The Rust port keeps the connection in Shared, which the GIO callbacks
keep alive until GIO frees them on a later main-context iteration. With
no such iteration after the last destroy, GTestDBus waits 30 s for the
session bus (test_inhibit_sleep_dbus: 32 s on the hybrid libobs, 2 s on
libobs-c-reference).

The fake transport's connection now counts its drops, and a new test
destroys the inhibitor while its Inhibit call is pending.

Fails: test_destroy_pending_drops_the_connection (0 drops at destroy,
want 1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion at destroy (#3444)

Shared keeps the connection in a Mutex<Option<Arc<_>>>. Portal::destroy
takes it out after it unsubscribes, as portal_inhibit_info_destroy()
clears info->c, so a pending call or the Response subscription can keep
the shared state alive but no longer the session bus. Each call clones
the Arc and drops the lock before it reaches GIO, so a callback on the
same stack cannot block on it. A call after the destroy finds no
connection and does nothing; the callbacks already return on
`destroying` before they would use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=2d68cad55ca238f757f42d3b2d9080c81f131551 secs=236 lanes=lint:run,rust-test:run,cross:run,tier2-linux:reused@ce478f56b10b,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1793564756,"gate":"rust/all/fmt","host":"linux-x86_64","key":"2a2d8fab70c09afca107f0d9a3e16562b873431fb2628daf4acc4c0b1a7c0e83","lane":"lint","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":84,"stamp":"2c2bd641055f60d15a355c19069088c7","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"2a2d8fab70c09afca107f0d9a3e16562b873431fb2628daf4acc4c0b1a7c0e83","lane":"lint","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":84,"stamp":"082c4281444b59b8295bc3161ec5f1da","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d0d55d156e0a65e454e651c9ca179eca3a8fa9ea8de3a6506a31c842ad4d165f","lane":"rust-test","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":99,"stamp":"c270a01080e2609082a4fe235a9f7076","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"e65f8d7847a0e9178921aa4cfcce28e4552383ee90f4a8a7195e268afe6c4e5b","lane":"cross","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":52,"stamp":"bd93e22e5e760921a6ae1cc51b7fa68c","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"e65f8d7847a0e9178921aa4cfcce28e4552383ee90f4a8a7195e268afe6c4e5b","lane":"cross","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":52,"stamp":"e90983f0a759218e3251a2f5920b6425","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"e65f8d7847a0e9178921aa4cfcce28e4552383ee90f4a8a7195e268afe6c4e5b","lane":"cross","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":52,"stamp":"45fc7fe7ca70fc71ae4f9bca6bbce99f","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564756,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"e65f8d7847a0e9178921aa4cfcce28e4552383ee90f4a8a7195e268afe6c4e5b","lane":"cross","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":52,"stamp":"ea256de6651d63864622a8206f0993ba","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"run"}
Ci-Attestation: {"at":1793564491,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ce478f56b10b4422fcb8ade1473c4313c97a3d3d35e8c4000f89e62c8d9fdae2","lane":"tier2-linux","parents":["8ddebb0b4c5a0bca3a46e077ed6a2710d4294fb1"],"secs":null,"stamp":"92f4a699209b1af2d6d847b383a5d016","tree":"2d68cad55ca238f757f42d3b2d9080c81f131551","v":1,"via":"reused"}
@vpacher
vpacher requested a review from zackees as a code owner November 1, 2026 20:30
@vpacher
vpacher enabled auto-merge November 1, 2026 20:31
@vpacher
vpacher added this pull request to the merge queue Nov 1, 2026
Merged via the queue into master with commit a473619 Nov 1, 2026
36 checks passed
@vpacher
vpacher deleted the fix/3444-portal-inhibit-conn branch November 1, 2026 20:58
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.

obs-util: the Rust portal sleep inhibitor keeps its session bus connection after destroy (test_inhibit_sleep_dbus waits 30 s)

1 participant