From c9cfc479dcba3e06a491ef8446406c23d3249515 Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sun, 20 Sep 2026 22:48:23 +0800 Subject: [PATCH] fix(wine): prefer bundled msvcp140 for UU 4.41 --- src/wine.rs | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/wine.rs b/src/wine.rs index 4cd4d8a..8ad4d27 100644 --- a/src/wine.rs +++ b/src/wine.rs @@ -141,13 +141,15 @@ pub fn setup(accept_eula: bool) -> Result<()> { /// - GameViewerServer.exe sees Windows 10 because current UU terminal builds /// gate their ConPTY transport on the OS version. Native input and display /// adapters handle the hardware capabilities separately; +/// - the UU client and service prefer their bundled msvcp140 runtime. Wine 10's +/// builtin implementation can stall UU 4.41 before the WebView starts; /// - the service must auto-start; /// - X11 focus/XIM tuning and CJK font substitution keep the controller /// usable. type RegistryEntry = (String, Vec<(&'static str, &'static str, &'static str)>); -pub fn apply_registry_compat(prefix: &Path) -> Result<()> { - let entries: Vec = vec![ +fn registry_compat_entries() -> Vec { + vec![ ( r#"Software\Wine\AppDefaults\msedgewebview2.exe"#.to_string(), vec![("Version", "REG_SZ", "win8")], @@ -156,6 +158,14 @@ pub fn apply_registry_compat(prefix: &Path) -> Result<()> { r#"Software\Wine\AppDefaults\GameViewerServer.exe"#.to_string(), vec![("Version", "REG_SZ", "win10")], ), + ( + r#"Software\Wine\AppDefaults\gameviewer.exe\DllOverrides"#.to_string(), + vec![("msvcp140", "REG_SZ", "native,builtin")], + ), + ( + r#"Software\Wine\AppDefaults\GameViewerServer.exe\DllOverrides"#.to_string(), + vec![("msvcp140", "REG_SZ", "native,builtin")], + ), ( r"System\CurrentControlSet\Services\GameViewerService".to_string(), vec![("Start", "REG_DWORD", "2")], @@ -175,15 +185,17 @@ pub fn apply_registry_compat(prefix: &Path) -> Result<()> { ("MS Shell Dlg 2", "REG_SZ", "Noto Sans CJK SC"), ], ), - ]; + ] +} - for (key, values) in &entries { +pub fn apply_registry_compat(prefix: &Path) -> Result<()> { + for (key, values) in registry_compat_entries() { let full = if key.starts_with("System") { format!("HKLM\\{key}") } else { format!("HKCU\\{key}") }; - for (value, reg_type, data) in values { + for (value, reg_type, data) in &values { let _ = Command::new("wine") .env("WINEPREFIX", prefix) .env("WINEDEBUG", wine_debug()) @@ -407,3 +419,21 @@ fn purge_wine_shortcuts() { } } } + +#[cfg(test)] +mod tests { + use super::registry_compat_entries; + + #[test] + fn bundled_cpp_runtime_is_preferred_for_both_uu_processes() { + let entries = registry_compat_entries(); + for executable in ["gameviewer.exe", "GameViewerServer.exe"] { + let key = format!(r"Software\Wine\AppDefaults\{executable}\DllOverrides"); + let values = entries + .iter() + .find_map(|(entry, values)| (entry == &key).then_some(values)) + .unwrap_or_else(|| panic!("missing DLL overrides for {executable}")); + assert!(values.contains(&("msvcp140", "REG_SZ", "native,builtin"))); + } + } +}