Repository navigation
fix(linux): choose KMS capture later when no display was lit at startup - #6052
Open
miguelangel-nubla wants to merge 3 commits into
Open
miguelangel-nubla wants to merge 3 commits into
miguelangel-nubla wants to merge 3 commits into
Conversation
miguelangel-nubla
marked this pull request as ready for review
November 6, 2026 19:29
|
matteo-pacini
added a commit
to matteo-pacini/nixos-configs
that referenced
this pull request
Nov 14, 2026
… limit (#478) * chore(brightfalls): drop dead GDM monitors.xml rule GDM greeter users now have their home under /run/gdm/home, so nothing reads /run/gdm/.config/monitors.xml. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix(brightfalls): wait for the LUKS passphrase without a time limit The root volume only appears after the passphrase is typed. After the default 90 s device timeout stage 1 dropped to emergency mode and killed the Plymouth prompt. Wait for the device indefinitely, and allow unlimited passphrase attempts so three wrong ones cannot leave that wait with no prompt. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * feat(brightfalls): restore Sunshine with KMS-only capture Sunshine 2026.914 probes the XDG portal at every start when no capture method is set, which raised GNOME's remote-control dialog at each login. capture = kms skips that probe. The Plymouth wait comes back because a KMS-only start with no lit output never recovers; it waits on `SunshineStream/Sunshine#6052`. Force the monitors.xml link: GNOME Settings replaces it with a regular file, and Home Manager refuses to activate once a backup already exists. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
KMS lists only lit displays, and the capture method was chosen once, in platf::init(). Started while every screen was blanked (a login screen's power saving), Sunshine logged "Unable to initialize capture method" and kept no capture method for the life of the process: every client got "Failed to initialize video capture/encoding" until it was restarted with a screen on. When the configured capture method is KMS or automatic, platf::init() now logs a warning instead of failing, and choose_kms_capture_if_none(), run from display_names() and display() while nothing is chosen, chooses KMS once a display is lit. Only KMS is checked again: the other methods depend on the session's environment or a portal permission, settled at startup, and verifying the portal can restart Sunshine. With another capture method configured, init fails as before. display() no longer drops the DRM worker's privileges while nothing is chosen, as KMS still needs them. Since init no longer implies a display on Linux, the encoder fixture skips when no display is listed instead of failing the software encoder. Tests replace the KMS display check (set_kms_verifier_for_testing): KMS is chosen once a display is lit, display_names() makes the choice, a choice is kept, and nothing is checked again with another capture method configured.
…er maybe unused SonarCloud's findings on this PR.
Keeps init()'s cognitive complexity within SonarCloud's limit, and logs the missing graphical session hint from SunshineStream#6095 on both paths.
miguelangel-nubla
force-pushed
the
fix/linux-capture-redetect
branch
from
November 22, 2026 17:14
121d867 to
5678869
Compare
|
This branch has not been deployed
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 Linux the capture method is chosen once, in
platf::init(), and KMS only lists displays that are lit. If Sunshine starts while every screen is blanked (for example by a login screen's power saving, as on a GDM greeter that has gone idle), it logsUnable to initialize capture methodand keeps no capture method for the life of the process: every client then gets "Failed to initialize video capture/encoding. Is a display connected and turned on?" until Sunshine is restarted with a screen on, even after the screens are back.With this change, when the configured capture method is KMS or automatic,
platf::init()logs a warning instead of failing, andplatf::choose_kms_capture_if_none(), run fromdisplay_names()anddisplay()while nothing is chosen, chooses KMS once a display is lit. The selection at startup is unchanged.Only KMS is checked again. The other methods depend on the session's environment (
WAYLAND_DISPLAY,DISPLAY) or on a portal permission, which are settled at startup, and verifying the portal again could restart Sunshine (stale token) or ask for permission again. With another capture method configured,platf::init()fails as before.display()no longer drops the DRM worker's privileges while nothing is chosen, since KMS still needs them once a display is lit.One consequence for the tests, which I'd like your view on:
PlatformTestSuitetreats a successfulplatf::init()as "a display can be captured". On Linux that no longer holds without any display (a headless runner), so the encoder fixture now skips with "No display to capture" whenplatf::display_names()is empty, instead of failing the software encoder. With a display, as in CI's virtual desktop, nothing changes. If you'd rather keep headless runs failing loudly, I can drop that hunk.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
tests/unit/platform/linux/test_misc.cpp(CaptureSources.*), using small test hooks (set_kms_verifier_for_testing,reset_capture_sources_for_testing,kms_capture_chosen_for_testing) that stand in for the KMS display check: KMS is chosen once a display is lit after none was;display_names()makes that choice when nothing is chosen; a choice once made is kept without checking again; with another capture method configured (x11), KMS is never chosen later and the check isn't run.master(c8ea783), together with my two other PRs (retrying the encoder probe before a stream, and the Vulkan quality query on a device without video encode), with the Linux dependencies of the nixpkgs Sunshine package, and ran the wholetest_sunshinesuite in a container without any display. Compared with plainmasterin the same container: no new failures (the same 10, which need a display, a network or packaging scripts), and the four platform suites that fail at setup onmasterwithout a display (AudioTest,EncoderTest,MouseHIDTest,X11GrabTest) now set up, with the encoder tests skipped as "No display to capture". 897 passed, 15 skipped, 10 failed, against 881, 19 and 10 plus those four onmaster. I could not run CI's workflow with its virtual desktop.Unable to initialize capture methodat that restart (the state in which every request is refused); with it the launch answers 200. On real hardware too (an Intel Sandy Bridge iGPU host at a GDM login screen, Moonlight as the client): with every screen blanked and Sunshine restarted, it logs the startup failure and keeps running; the next stream request logsA display is lit now: screencasting with KMSand the client connects.uv.lock) reports no changes for the touched files.master(ab6140e). It conflicted with fix(linux): explain a missing graphical session when no capture method starts #6095 inplatf::init(): the missing graphical session hint from fix(linux): explain a missing graphical session when no capture method starts #6095 is kept, and logged on both paths (giving up, and checking KMS again later). That path is now a small helper,continue_without_capture_method(), which keepsinit()within SonarCloud's cognitive complexity limit. Built withscripts/linux_build.sh(no CUDA) in an Ubuntu 22.04 arm64 container and rantest_sunshineunder Xvfb: 974 tests, 968 passed, 6 skipped, 0 failed.Type of Change
Checklist
AI Usage
See our AI usage policy.