From 7d7fd3541c74ffedd3e955ea5ddfbdcffb3b47a3 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 27 May 2026 18:14:22 -0400 Subject: [PATCH] Set process affinity on Windows We did this on Linux using taskset but Windows needs this treatment as well. Fixes #7 --- launcher/src/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index 8d660d4..fa8864e 100755 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -13,6 +13,11 @@ #ifdef Q_OS_WINDOWS #include + +#define WIN32_LEAN_AND_MEAN +#include + +#include "umbra_log.h" #endif #include "umbra-version.h" @@ -24,6 +29,22 @@ using namespace Qt::StringLiterals; int main(int argc, char *argv[]) { + // Restrict to first 14 threads on Windows as the game will crash when running on 16 or more threads. + // This is handled via taskset on Linux, but on Windows that doesn't exist. If we set our own affinity, that's then passed to our children. +#if defined(Q_OS_WIN) + HANDLE hProcess = GetCurrentProcess(); + + unsigned long lProcessAffinityMask = 0; + unsigned long lSystemAffinityMask = 0; + GetProcessAffinityMask(hProcess, reinterpret_cast(&lProcessAffinityMask), reinterpret_cast(&lSystemAffinityMask)); + + lProcessAffinityMask &= 0x3FFF; + + if (!SetProcessAffinityMask(hProcess, lProcessAffinityMask)) { + qCWarning(UMBRA_LOG) << "Could not set process affinity, the game will NOT launch correctly on certain systems!"; + } +#endif + KIconTheme::initTheme(); // TODO: KirigamiApp doesn't call this before app construction so it doesn't work on Windows KirigamiApp::App app(argc, argv);