Repository navigation
libobs: Take the Wayland keyboard from the seat that has one - #244
Merged
Merged
Conversation
zackees
approved these changes
Oct 11, 2026
The Wayland hotkey platform stores only the last wl_seat it binds and asks that seat for the keyboard whenever any seat announces one. With a keyboard seat followed by a seat without a keyboard, the compositor gets wl_seat.get_keyboard on the wrong seat, a fatal missing_capability protocol error on the connection OBS shares with Qt, so OBS crashes at startup. A seat without a keyboard also releases the keyboard taken from another seat, only the last seat is released on shutdown, and a seat removed at runtime is never released. The test drives the real obs-nix-wayland.c against a small fake compositor in a child process, connected over a socketpair, which advertises several seats, enforces missing_capability, and on request changes a seat's capabilities or removes a seat. The single-seat case is a control that already passes. Upstream: obsproject/obs-studio#12929 (reported by chronically-late, first filed as obsproject/obs-studio#12237). Refs obs-rust#243. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A compositor may announce several wl_seat globals. The hotkey platform kept only the last one bound and requested the keyboard from it whenever any seat reported a keyboard, a fatal missing_capability protocol error when that last seat has none. As the connection is shared with Qt, OBS crashed at startup on such multi-seat setups. Track every bound seat with its registry name and capabilities. Request the keyboard from a seat that announced one, release it only when that seat loses the capability or is removed (clearing the held keys, as no leave event follows), then take another seat's keyboard if there is one. Seats removed at runtime are released, and all remaining seats are released on shutdown. Based on obsproject/obs-studio#12302 by kkartaltepe, with the seat tracking added. Upstream: obsproject/obs-studio#12929 (reported by chronically-late). Fixes obs-rust#243. Co-Authored-By: Kurt Kartaltepe <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=1a89de62bc4d0878c4ee5032d56b87d31f978b16 secs=91 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791733458,"gate":"rust/all/fmt","host":"linux-x86_64","key":"e82a61aac7dd7de570e53878849d758ed9a74b93120be57b807649cc71590fed","lane":"lint","parents":["ec0e85e85825a132834904c69a40367c771fcb64"],"secs":16,"stamp":"a9680de220ef02c3880187fea1074df5","tree":"1a89de62bc4d0878c4ee5032d56b87d31f978b16","v":1,"via":"run"} Ci-Attestation: {"at":1791733458,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"e82a61aac7dd7de570e53878849d758ed9a74b93120be57b807649cc71590fed","lane":"lint","parents":["ec0e85e85825a132834904c69a40367c771fcb64"],"secs":16,"stamp":"ac1d8e5a34ce928f0a4e22a6db7a9fd7","tree":"1a89de62bc4d0878c4ee5032d56b87d31f978b16","v":1,"via":"run"} Ci-Attestation: {"at":1791733458,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"36ab2cc794dcc36745240e99b21f6db43cd4aa72672637ef5d9d70cec658ffe5","lane":"rust-test","parents":["ec0e85e85825a132834904c69a40367c771fcb64"],"secs":29,"stamp":"112acefee69385cb7c8b1dfda12ce43d","tree":"1a89de62bc4d0878c4ee5032d56b87d31f978b16","v":1,"via":"run"} Ci-Attestation: {"at":1791733458,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"984d21e0cad7d1291712e46a0f1e8d64a977ec1ec5b8ba980766162930659193","lane":"tier2-linux","parents":["ec0e85e85825a132834904c69a40367c771fcb64"],"secs":46,"stamp":"da0b2ddb28cb4c71db99e59796cec308","tree":"1a89de62bc4d0878c4ee5032d56b87d31f978b16","v":1,"via":"run"}
Member
|
Verified locally, rebased onto master and stamped. Tier 2 builds with
The fake compositor needs no display, so CI's Wayland-enabled Ubuntu build should run it too. Merging once CI is green. |
zackees
force-pushed
the
fix/243-wayland-multiseat
branch
from
October 11, 2026 15:44
25f0aea to
0540efd
Compare
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.
Description
On a Wayland compositor with more than one seat, OBS could exit at startup with
wl_seat.get_keyboard called when no keyboard capability has existed. With this change OBS takes the hotkey keyboard from a seat that has one and keeps it when other seats change.The cause:
platform_registry_handler()(libobs/obs-nix-wayland.c:247) overwritesplat->seatfor everywl_seat. When any seat reports a keyboard,platform_seat_capabilities()asks the last seat for it. If that seat has no keyboard, the compositor raisesmissing_capability. That protocol error is fatal for the connection OBS shares with Qt. The same handler also releases the keyboard whenever any seat reports no keyboard.global_removewas ignored, and only the last seat was released on shutdown.test: Wayland hotkeys must cope with several seats (RED)addstest_wayland_multiseat. It drives the realobs-nix-wayland.cover a socketpair against a small fake compositor (libwayland-server) in a forked child. The compositor announces several seats, enforcesmissing_capability, and on request changes a seat's capabilities or removes a seat. 5 of 6 cases fail here; the single-seat control passes.libobs: Take the Wayland keyboard from the seat that has onetracks each bound seat with its registry name and capabilities. It requests the keyboard from a seat that reports one. The keyboard is released only when that seat loses it or is removed, and held keys are cleared because noleavefollows. Another seat's keyboard then takes over. Removed seats are released at runtime, and the rest on shutdown. All 6 pass.Motivation and Context
Fixes #243 (upstream obsproject/obs-studio#12929, reported by chronically-late; first filed as obsproject/obs-studio#12237 and closed upstream as a Qt issue)
Why this one: the crash hits real setups today. chronically-late runs sway with a second seat for a touchscreen and tablet, and OBS cannot start there. Sivecano tested obsproject/obs-studio#12302 upstream and confirmed that it stops the protocol violation. Two upstream fixes have been open since 2025 without review.
This builds on kkartaltepe's upstream PR obsproject/obs-studio#12302, which is ported here with kkartaltepe as co-author. Its seat-matching logic is kept, and seat tracking plus
global_removehandling are added. In davidedmundson's upstream PR obsproject/obs-studio#12293, davidedmundson noted that seat removal should also release the keyboard; this change does that.Against the new test, applied to the same base:
keyboard_seat_then_pointer_seat,empty_seat_does_not_release_keyboard,free_releases_every_seatandremoved_keyboard_seat_hands_over.free_releases_every_seat) and ignores a seat removed at runtime (removed_keyboard_seat_hands_over).How Has This Been Tested?
Automated and headless. The tests ran in a private Xvfb with
WAYLAND_DISPLAY/DISPLAYunset, and the fake compositor connection never leaves the test.test_wayland_multiseatfails 5 of 6 at RED and passes 6 of 6 at GREEN. It passed 10 of 10 repeated runs at GREEN. Full ctest at GREEN: 82 of 82.ENABLE_RUST_LIBOBS=ON):test_wayland_multiseat6 of 6 andtest_wayland_hotkeys4 of 4. Full ctest: 82 of 82.Not tested:
Types of changes
Checklist:
🤖 Generated with Claude Code