Repository navigation
fix(obs-util): the portal sleep inhibitor drops its bus connection at destroy (#3444) - #3447
Merged
Merged
Conversation
…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"}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inShared, 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 outlivesPortal::destroy, and disposingGTestDBuswaits 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
Sharedkeeps the connection in aMutex<Option<Arc<_>>>.Portal::destroytakes it out after it unsubscribes, in the C's order. Each call clones theArcand 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 ondestroyingbefore they would use it.RED → GREEN
test_destroy_pending_drops_the_connectiondestroys the inhibitor while its Inhibit call is pending. Fails: 0 drops at destroy, want 1.test_inhibit_sleep_dbusagainst the hybrid libobs (same test binary): 32.2 s before, 2.18 s after, no weak-notify warning;libobs-c-reference2.2 s. The sanitizer passes and valgrind save the same 30 s.🤖 Generated with Claude Code