Skip to content

fix(linux): explain a missing graphical session when no capture method starts - #6095

Merged
ReenigneArcher merged 2 commits into
SunshineStream:masterfrom
sudoeren:linux-no-session-hint
Nov 13, 2026
Merged

ReenigneArcher merged 2 commits into
SunshineStream:masterfrom
sudoeren:linux-no-session-hint

Conversation

@sudoeren

@sudoeren sudoeren commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

When Sunshine starts on Linux without WAYLAND_DISPLAY and DISPLAY (for example as a systemd user service that started before the desktop session exported its environment), every capture method fails, then every encoder fails the probe, and the last lines say:

Fatal: Unable to find display or encoder during startup.
Fatal: Please check that a display is connected and powered on.

The real cause is only visible earlier in the log ([kwingrab] WAYLAND_DISPLAY not set), so it is easy to go looking at monitors and GPUs instead. I hit this on KDE Plasma 6 (Wayland, NVIDIA) with capture = kwin.

This adds one error line right after "Unable to initialize capture method" when neither variable is set, naming the missing session and how to export it to systemd. It is skipped when capture = kms, which works without a session. The check lives in a documented platf::log_missing_graphical_session_hint() helper so it can be tested without running capture or encoder probes.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

  • Added LinuxCaptureSessionHint.LogsOnlyWithoutSessionVariablesAndWithoutKms in tests/unit/platform/linux/test_misc.cpp. With both variables unset it expects the hint for automatic and kwin capture and no hint for kms; with WAYLAND_DISPLAY or DISPLAY set it expects no hint.
  • Built test_sunshine locally on Arch-based Linux (CachyOS) and ran ./cmake-build-debug/tests/test_sunshine --gtest_filter='LinuxCaptureSessionHint.*:ProcessEnvironmentSecurity.*': all 3 tests passed. The full test_sunshine suite also passed (937 passed, 5 skipped).
  • uv run --locked lb-update-clang-format produced no changes.
  • Reproduced the original problem with Sunshine 2026.1109.513 by running it with env -u WAYLAND_DISPLAY -u DISPLAY.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

The change and this description were prepared with the help of an AI coding assistant (Claude Code); I reviewed them and reproduced the problem on my machine.

This pull request update was prepared with Claude Code, Claude Opus 5.5, low thinking level

@ReenigneArcher ReenigneArcher left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 0dd6356 against current master (801abd5). Requesting changes for the missing regression coverage described inline and the incomplete PR template described below.

The PR description also needs the complete inherited PR template. Its opening instruction requires retaining every section and HTML comment, including sections that do not apply. The current body omits Testing, Checklist, AI Usage, Screenshot, Issues Fixed or Closed, Roadmap Issues, the remaining Type of Change options, and the template comments. Please restore the full template, put the reproduction and build-limit notes under Testing, select the fix and AI-use checkboxes, and retain the existing AI disclosure in the AI Usage section. Unused sections may remain empty and inapplicable boxes unchecked.

Local whitespace and changed-line clang-format checks passed against a copy verified to match the PR blob. Semantic PR, Read the Docs, and Sonar checks report success.

Verification limit: CI, common lint, and CodeQL await maintainer approval, and no Linux build or runtime tests were run locally on this macOS host. GitHub currently reports the PR mergeable with its target.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Comment thread src/platform/linux/misc.cpp Resolved
…d starts

When Sunshine starts without WAYLAND_DISPLAY and DISPLAY (for example as a systemd user service that started before the session exported its environment), every capture method fails, every encoder then fails the probe, and the last message asks to check that a display is connected. Name the missing session variables instead, unless KMS capture is selected, which works without a session.
- Move the hint into a documented platf::log_missing_graphical_session_hint() helper
- Test that it logs without WAYLAND_DISPLAY/DISPLAY for automatic and kwin capture
- Test that kms capture or a set session variable suppresses it
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.33%. Comparing base (9495701) to head (4b41ca5).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/linux/misc.cpp 66.66% 1 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #6095    +/-   ##
========================================
  Coverage   50.32%   50.33%            
========================================
  Files         148      148            
  Lines       32357    32366     +9     
  Branches    13692    13700     +8     
========================================
+ Hits        16285    16292     +7     
- Misses      14004    14781   +777     
+ Partials     2068     1293   -775     
Flag Coverage Δ
Alpine-aarch64 34.15% <55.55%> (+0.01%) ⬆️
Alpine-x86_64 34.27% <55.55%> (-0.01%) ⬇️
Archlinux 34.87% <55.55%> (+0.01%) ⬆️
FreeBSD-amd64 34.81% <0.00%> (-0.03%) ⬇️
Homebrew-macos-15 48.78% <ø> (ø)
Homebrew-macos-26 49.18% <ø> (ø)
Homebrew-ubuntu-24.04 37.40% <66.66%> (+<0.01%) ⬆️
Linux-AppImage-aarch64 40.02% <66.66%> (+<0.01%) ⬆️
Linux-AppImage-x86_64 40.27% <66.66%> (+0.01%) ⬆️
PowerShell 100.00% <ø> (ø)
Web-UI 57.74% <ø> (ø)
Windows-AMD64 40.49% <ø> (ø)
Windows-ARM64 34.37% <ø> (-0.01%) ⬇️
macOS-arm64 41.70% <ø> (+<0.01%) ⬆️
macOS-x86_64 40.59% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/linux/misc.h 0.00% <ø> (ø)
src/platform/linux/misc.cpp 43.84% <66.66%> (+0.27%) ⬆️

... and 34 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9495701...4b41ca5. Read the comment docs.

@github-actions

Copy link
Copy Markdown
Last Updated 2026-11-13 23:07:30 UTC
Source Run CI Run #6751
Commit 4b41ca56074fa93864b8f04a72e85bea6cad7d1c

Screenshot Comparison

PR #6095 screenshots vs screenshots baseline.

Matrix: AppImage-aarch64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: AppImage-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-AMD64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-ARM64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-arm64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

@ReenigneArcher
ReenigneArcher merged commit 657f9b6 into SunshineStream:master Nov 13, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants