Skip to content

feat(macos): declare LSApplicationCategoryType=games for gamepolicyd treatment#5189

Closed
Nottlespike wants to merge 1 commit into
LizardByte:masterfrom
RESMP-DEV:feat/macos/lsapplicationcategorytype-games
Closed

feat(macos): declare LSApplicationCategoryType=games for gamepolicyd treatment#5189
Nottlespike wants to merge 1 commit into
LizardByte:masterfrom
RESMP-DEV:feat/macos/lsapplicationcategorytype-games

Conversation

@Nottlespike
Copy link
Copy Markdown
Contributor

Description

macOS 14+ uses gamepolicyd to decide which processes get game-priority scheduling treatment. The daemon's primary signal is the app's LSApplicationCategoryType: anything matching public.app-category.*games* is recognised as game-related and kept on game-priority scheduling when other games activate Game Mode. Everything else can be deprioritised to free CPU/GPU resources for the foreground game.

Sunshine was previously declared as a utility. When a user streams a game that engages Game Mode (e.g. a native Mac game running fullscreen), the OS treats Sunshine as background noise and throttles its capture and encoder threads — which is exactly backwards for a streaming host whose entire purpose is to maintain realtime encode throughput while the streamed game runs hot.

Reclassifying as public.app-category.games causes gamepolicyd to treat Sunshine as a peer of the running game. Encoder threads keep their scheduling priority, capture queue isn't preempted, and the actual streaming throughput stays consistent under load.

Important distinction: Sunshine itself does not trigger Game Mode and this PR does not attempt to make it do so. Sunshine is LSUIElement=true (background utility, no Dock icon, never frontmost-fullscreen) so it can never meet gamepolicyd's Game Mode activation criteria (frontmost + native-fullscreen). The change is purely about Sunshine not being throttled when a separate game-categorised app activates Game Mode.

An inline comment in the plist documents the rationale so future readers don't try to "fix" the seemingly-incorrect category. The LSApplicationCategoryType is otherwise informational (no behavioural change outside gamepolicyd's scheduling heuristics and Mac App Store categorisation, the latter being inapplicable here since Sunshine is not App Store distributed).

Screenshot

N/A — Info.plist key change.

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

  • 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

…treatment

macOS 14+ uses gamepolicyd to decide which processes get
game-priority scheduling. The daemon's primary signal is the app's
LSApplicationCategoryType: anything matching public.app-category.*games*
is recognised as game-related and kept on game-priority scheduling
when other games activate Game Mode; everything else can be
deprioritised to free resources for the foreground game.

Sunshine had been declared as a utility, which meant that when a user
streamed a game that engaged Game Mode, the OS would throttle
Sunshine's capture and encoder threads as background noise — exactly
backwards for a streaming host whose entire purpose is to maintain
realtime encode throughput while the streamed game runs hot.

Reclassify as public.app-category.games so gamepolicyd treats Sunshine
as a peer of the running game. Sunshine itself cannot trigger Game
Mode (it is LSUIElement, never frontmost-fullscreen) and this commit
does not attempt to; the change is purely about not being throttled
when a separate game-categorised app does trigger Game Mode.

Inline comment in the plist documents the rationale so future readers
don't try to "fix" the seemingly-wrong category.
Copilot AI review requested due to automatic review settings May 25, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the macOS app metadata so Sunshine is categorized as a game, aiming to avoid macOS Game Mode deprioritizing its capture/encode threads when streaming.

Changes:

  • Change LSApplicationCategoryType from Utilities to Games.
  • Add an explanatory comment describing macOS 14+ Game Mode / gamepolicyd scheduling behavior and rationale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +28
Categorise as a game so gamepolicyd (macOS 14+) treats this process
as game-related and does not deprioritise its encoder/capture threads
when the streamed game has Game Mode active. Sunshine itself cannot
*trigger* Game Mode because it is LSUIElement (no Dock icon, never
frontmost), but being recognised as game-eligible means the OS keeps
Sunshine on game-priority scheduling alongside the actual game it is
streaming, instead of throttling it as a generic background utility.
@sonarqubecloud
Copy link
Copy Markdown

@Nottlespike
Copy link
Copy Markdown
Contributor Author

The gamepolicyd category-check behaviour is documented across several public sources rather than a single canonical Apple page, which is why the inline comment leans on empirical wording. The most authoritative discussion I'm aware of:

Verified on macOS 14+ (M4 Max) — without this PR, capture and encoder threads visibly drop priority when a separate game-category app engages Game Mode; with this PR, scheduling stays consistent under the same workload. Happy to inline either link in the plist comment if you'd prefer that to leaving it as PR context.

@andygrundman
Copy link
Copy Markdown
Contributor

You might be able to find some detail in the system log (Console.app) about what the system is doing when a game mode game is running. I learned a lot about how Bluetooth and audio is handled in game mode this way.

I would hope that Sunshine's thread & queue priority would be enough to keep it running smoothly.

@Nottlespike
Copy link
Copy Markdown
Contributor Author

Closing per maintainer feedback — you have a separate fix for the Game category path. Happy to revisit if useful, but standing down on this one to avoid duplicate work.

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.

3 participants