Skip to content

libobs: Take the Wayland keyboard from the seat that has one - #244

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/243-wayland-multiseat
Oct 11, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/243-wayland-multiseat

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

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) overwrites plat->seat for every wl_seat. When any seat reports a keyboard, platform_seat_capabilities() asks the last seat for it. If that seat has no keyboard, the compositor raises missing_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_remove was ignored, and only the last seat was released on shutdown.

  1. test: Wayland hotkeys must cope with several seats (RED) adds test_wayland_multiseat. It drives the real obs-nix-wayland.c over a socketpair against a small fake compositor (libwayland-server) in a forked child. The compositor announces several seats, enforces missing_capability, and on request changes a seat's capabilities or removes a seat. 5 of 6 cases fail here; the single-seat control passes.
  2. libobs: Take the Wayland keyboard from the seat that has one tracks 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 no leave follows. 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_remove handling 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:

How Has This Been Tested?

Automated and headless. The tests ran in a private Xvfb with WAYLAND_DISPLAY/DISPLAY unset, and the fake compositor connection never leaves the test.

  • C lane: test_wayland_multiseat fails 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.
  • Rust lane (ENABLE_RUST_LIBOBS=ON): test_wayland_multiseat 6 of 6 and test_wayland_hotkeys 4 of 4. Full ctest: 82 of 82.
  • clang-format and gersemi are clean.

Not tested:

  • Real multi-seat hardware or a real compositor's seat handling (sway, KDE, GNOME). The fake compositor follows the protocol, not a particular implementation.
  • Which seat's keyboard is used when several seats have one. The first one announced is used, as before; it need not be the seat Qt has focus on.
  • FreeBSD. The same sources are built there.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR
  • I am an AI agent being used to assist with this pull request: Claude Code (Claude Opus 5.5) wrote the code, commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 11, 2026 15:34
rdoupe and others added 2 commits October 11, 2026 08:42
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"}
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Verified locally, rebased onto master and stamped. Tier 2 builds with ENABLE_WAYLAND=OFF, so test_wayland_multiseat isn't compiled there. I built it in the Tier 2 container with ENABLE_WAYLAND=ON:

  • RED (8db7f8d73): 1 of 6 passed. empty_seat_does_not_release_keyboard, free_releases_every_seat, keyboard_moves_between_seats, keyboard_seat_then_pointer_seat and removed_keyboard_seat_hands_over failed (get_keyboard on seat 'seat1', which has no keyboard).
  • GREEN (25f0aea63): the test passed. Plain Tier 2 passed 81 of 81 with ENABLE_RUST_LIBOBS OFF and 81 of 81 with it ON, and the local gate passed.

The fake compositor needs no display, so CI's Wayland-enabled Ubuntu build should run it too. Merging once CI is green.

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.

bug: libobs: OBS dies on Wayland with more than one seat (keyboard requested from the wrong seat) (upstream #12929)

2 participants