-
-
Notifications
You must be signed in to change notification settings - Fork 960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(win): use UCRT64 environment instead of MinGW64. #2323
Conversation
This resolves the regex CPU/memory hog issue:
Setting to UTF16 or UTF32 resolves the slowdown, but I'm not sure if that actually breaks our current regex parsing? |
Relevant discussion (see also in comments): https://stackoverflow.com/questions/59067280/does-stdwregex-support-utf-16-unicode-or-only-ucs-2 Setting to UTF16 doesn't break my en-IE keyboard mappings, but it could have consequences for other languages and may also break log parsing (see: cadd3da) |
I retested the #1477 by printing some Chinese characters with The result: Sunshine doesn't crash, regex doesn't consume CPU or memory, and the Chinese characters print in the web UI log correctly. This may be a viable fix, but @cgutman will probably want to review that change to make sure no other changes are required. |
Apologies for the spam, but my observations were flawed. It appears that MINGW64 builds were not setting the UTF-8 codepage correctly, so the default More context: msys2/MINGW-packages#20477 (comment) |
Two points on MSVCRT in the MSYS2 environments documentation:
This explains the behaviour we're seeing. I didn't mention in my prior comment, but setting the system default locale via
This suggests to me that we need a complementary PR for build-deps to also switch to UCRT64, so that the statically linked ffmpeg libraries don't cause unforseen issues. |
Regarding the UAC failing to trigger via shortcut launch: A workaround (or perhaps the only solution) is the following: diff --git a/src_assets/windows/misc/migration/migrate-config.bat b/src_assets/windows/misc/migration/migrate-config.bat
index 65d00d8f..aa8d10aa 100644
--- a/src_assets/windows/misc/migration/migrate-config.bat
+++ b/src_assets/windows/misc/migration/migrate-config.bat
@@ -39,9 +39,10 @@ rem Create the credentials directory if it wasn't migrated or already existing
if not exist "%NEW_DIR%\credentials\" mkdir "%NEW_DIR%\credentials"
rem Disallow read access to the credentials directory for normal users
-rem Note: We must use the SID directly because "Administrators" is localized
+rem Note: We must use the SIDs directly because "Users" and "Administrators" are localized
icacls "%NEW_DIR%\credentials" /inheritance:r
icacls "%NEW_DIR%\credentials" /grant:r *S-1-5-32-544:(OI)(CI)(F)
+icacls "%NEW_DIR%\credentials" /grant:r *S-1-5-32-545:(R)
rem Migrate the covers directory
if exist "%OLD_DIR%\covers\" (
This will grant the Edit: amended to use the SID to avoid localization issues. |
Whatever you end up doing, do not use On Windows you can actually set global locale to be |
oof, I'm embarrassed by that. Should have read https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-170
I guess it's possible we don't need to do this at all, but I think it might be a good idea to leave this in there anyway, so there isn't any appetite to add back UTF-8 in the future. |
msys2/MINGW-packages#20477 has been merged. Maybe we don't need to migrate to ucrt anymore (but still remove the UTF-8 locale)? |
It seems that mingw is becoming legacy, so probably worth migrating anyway. The WGC just won't depend on this now. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@tez011 did you see @psyke83 's PR into your branch? https://github.com/tez011/Sunshine/pull/1 |
Thanks for the ping and for patience. I didn't get any email notifications about that pull request until yours... though I did see it yesterday and thought it was closed. I guess if the service launches sunshine as administrator, it'll have access to the configuration files specified and the patch will work good. I've merged that change. Thanks for the patch @psyke83 ! |
No problem, but it seems that my commit was lost after you rebased your |
icacls "%NEW_DIR%\credentials" /inheritance:r | ||
icacls "%NEW_DIR%\credentials" /grant:r *S-1-5-32-544:(OI)(CI)(F) | ||
icacls "%NEW_DIR%\credentials" /grant:r *S-1-5-32-545:(R) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed with the change to config.cpp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so?
Test 1:
- Delete existing config directory
- Freshly install Sunshine built from current PR branch
- Set
port = 46989
- Stop sunshine service and relaunch from shortcut as non-admin
Result: Sunshine launches with the correct custom web UI port.
Test 2:
- Repeat test 1 with build that omits
migrate-config.bat
OR keep PR build+config from test 1 and remove Users read folder privilege manually.
Result: several second delay on "Waiting for Web UI to be ready....", and UI opens to the (incorrect) default port.
Now that C++20 is in, this can be considered. What's the appetite for merging this environment change? If it's slim-to-none, I can try porting the WGC change to mingw64 now that msys2/MINGW-packages#20477 is in. I have a suspicion that MSVCRT and the UWP runtime won't play together well, so hoping to get some confirmation here before I spend time in that rabbit hole. |
We'd like to move to UCRT64 since mingw seems to be considered legacy by the packaging team. |
Could we move forward with more detailed testing/review of this pull request soon? Assuming, of course, than 0.23.2 isn't coming up shortly. |
Yes, I am trying to knock out as many of these open PRs as possible. Sorry for the delay. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2323 +/- ##
=========================================
- Coverage 7.03% 6.96% -0.08%
=========================================
Files 87 87
Lines 17697 17692 -5
Branches 8406 8407 +1
=========================================
- Hits 1245 1232 -13
- Misses 13716 15773 +2057
+ Partials 2736 687 -2049
Flags with carried forward coverage won't be shown. Click here to find out more.
|
PR updating ffmpeg to UCRT64: #2572 |
Despite requesting UTF-8, MinGW appears to have been using the 'C' locale the whole time, so we should enforce that here even if UCRT's setlocale() actually works as advertised.
1) On UCRT64, std::filesystem::exists() interprets the credentials folder to not exist if the Users groups do not have folder read permissions, which results in a subsequent failure to create the already existing folder. 2) Similarly, non-admin shortcut launches may also throw an exception in boost::filesystem::create_directories() if the config folder has been deleted by the user after installation. Steps to reproduce: install Sunshine, quit Sunshine, delete config and then run launcher as non-admin. Fix 1) by setting User read access to the folder - but not its contents - so std::filesystem::exists() gives the expected result. Fix 2) by allowing non-privileged process to start the service even if no config was loaded, thus deferring config creation to service instance.
Thanks for merging this! I'll let this change stew for a bit while I ready the final WGC pull request. I hope to send that out soon! |
Co-authored-by: Conn O'Griofa <connogriofa@gmail.com>
Description
#2149 was reverted in #2320 and needs to be split into three changes:
If msys2/MINGW-packages#20477 is integrated, WGC can proceed without this change.
Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.