Skip to content

feat(linux): use privileged EGL worker thread - #5709

Open
psyke83 wants to merge 2 commits into
LizardByte:masterfrom
psyke83:privileged_egl_worker
Open

feat(linux): use privileged EGL worker thread#5709
psyke83 wants to merge 2 commits into
LizardByte:masterfrom
psyke83:privileged_egl_worker

Conversation

@psyke83

@psyke83 psyke83 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Description

Delegate eglCreateContext to a privileged EGL worker thread and confine CAP_SYS_NICE to this thread.

This serves the dual purpose of hardening non-sandboxed Sunshine installations against unintended child process inheritance of CAP_SYS_NICE while also allowing EGL high-priority contexts to be used with Portal capture in conjunction with VAAPI encoding.

Portal capture previously required Sunshine to drop CAP_SYS_NICE so that xdg-desktop-portal could access Sunshine's /proc/pid/root. This prevented VAAPI from creating high-priority EGL contexts, which could cause the encoder to throttle if host GPU usage is high. Keeping CAP_SYS_NICE confined to the privileged EGL worker removes this tradeoff.

The privileged EGL context creation path is used by CUDA, VAAPI, kmsgrab and wlgrab; all relevant capture methods and encoders will support high priority contexts, but sandboxed installation types cannot avail of CAP_SYS_NICE due to the security policies enforced by their respective environments. This limitation mainly applies to Flatpak and AppImage installs.

Screenshot

Issues Fixed or Closed

Roadmap Issues

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
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@psyke83
psyke83 force-pushed the privileged_egl_worker branch from 5ff7c4b to 746ed49 Compare September 14, 2026 02:41
@sonarqubecloud

Copy link
Copy Markdown

Delegate eglCreateContext to a privileged EGL worker thread and confine
CAP_SYS_NICE to this thread.

This serves the dual purpose of hardening non-sandboxed Sunshine
installations against unintended child process inheritance of CAP_SYS_NICE
while also allowing EGL high-priority contexts to be used with Portal
capture in conjunction with VAAPI encoding.

Portal capture previously required Sunshine to drop CAP_SYS_NICE so that
xdg-desktop-portal could access Sunshine's /proc/pid/root. This prevented
VAAPI from creating high-priority EGL contexts, which could cause the encoder
to throttle if host GPU usage is high. Keeping CAP_SYS_NICE confined to
the privileged EGL worker removes this tradeoff.

The privileged EGL context creation path is used by CUDA, VAAPI, kmsgrab and
wlgrab; all relevant capture methods and encoders will support high
priority contexts, but sandboxed installation types cannot avail of
CAP_SYS_NICE due to the security policies enforced by their respective
environments. This limitation mainly applies to Flatpak and AppImage installs.
Also rename "warning" bool variable to avoid collision with BOOST_LOG level.
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.

1 participant