Skip to content

Keep the main thread's QoS on Apple platforms - #317

Open
Sinan-Karakaya wants to merge 1 commit into
encounter:mainfrom
Sinan-Karakaya:apple-main-thread-qos
Open

Sinan-Karakaya wants to merge 1 commit into
encounter:mainfrom
Sinan-Karakaya:apple-main-thread-qos

Conversation

@Sinan-Karakaya

Copy link
Copy Markdown

Changing the scheduling policy permanently opts a thread out of QoS. The main thread must keep its user-interactive QoS, or UIKit's out-of-process UI (such as the document picker) stalls.

This behaviour can be observed on Dusklight built for iOS 27.2>= and prevent it from opening system UIs, such as the file picker sheet.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the change intended to preserve the Apple main thread’s QoS.

No open issues 🎉

What changed in this PR

Preserves the main thread’s QoS on Apple platforms to prevent UIKit system interfaces, such as document pickers, from stalling.

Changes:

  • Uses pthread_main_np() to detect the Apple main thread and skip changes to its scheduling priority.
  • Keeps existing priority-setting behavior for worker threads and non-Apple platforms.
File Description
lib/​thread.cpp Guards the SDL thread-priority call to preserve the Apple main thread’s QoS.

Review effort: Balanced

@encounter

Copy link
Copy Markdown
Owner

Do you have proof this does anything?

@Sinan-Karakaya

Copy link
Copy Markdown
Author

This PR is the one needed for this other PR for Dusklight: TwilitRealm/dusklight#2798

It's currently waiting for this one to be merged. If you try to launch Dusklight on iOS 27.2> without this thread fix, the FilePickerSheet and the renderer of the game will be blocked.

Other than this instance, I don't have any other example, but I guess a minimal example could be reproducible

@Antidote

Copy link
Copy Markdown
Collaborator

We have hundreds of users that are using iOS just fine without this, and that copilot comment means literally nothing to us, please give us an objective test case we can use to reproduce the problem.

@Sinan-Karakaya

Copy link
Copy Markdown
Author

I'll work on a minimal reproducible example in the next couple of days then, I'll link it to you by then :)

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.

4 participants