From c430c71c69fc75b30960da7b3f80d04c71fd1707 Mon Sep 17 00:00:00 2001 From: Emma Hare Date: Sun, 19 Jul 2026 04:55:23 -0700 Subject: [PATCH] WineFix: gate MainWindowLoaded patch behind setting, default off On Affinity 3.2.3 the HasPreviousPackageInstalled patch sends the app down the fresh-install onboarding path, which hosts a WebView2CompositionControl that crashes under Wine (TypeLoadException: Windows.UI.Composition.Compositor, see noahc3/AffinityPluginLoader#46). Forcing true instead triggers a bogus legacy beta font migration. Neither constant works on 3.2.x, so expose the patch as a main_window_loaded_fix setting defaulting to disabled; the unpatched method throwing under Wine skips onboarding, matching vanilla Affinity.exe behaviour. Trade-off: the prefs-saving fix is inactive unless the user opts in. Co-Authored-By: Claude Fable 5 --- WineFix/WineFixPlugin.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/WineFix/WineFixPlugin.cs b/WineFix/WineFixPlugin.cs index d05ea2c..d37bb5e 100644 --- a/WineFix/WineFixPlugin.cs +++ b/WineFix/WineFixPlugin.cs @@ -22,6 +22,7 @@ public class WineFixPlugin : AffinityPlugin public const string SettingWidenStubFix = "widen_stub_fix"; public const string SettingBezierSplitGuard = "bezier_split_guard"; public const string SettingCommandLineFileOpen = "command_line_file_open"; + public const string SettingMainWindowLoadedFix = "main_window_loaded_fix"; public override PluginSettingsDefinition DefineSettings() { @@ -69,6 +70,10 @@ public override PluginSettingsDefinition DefineSettings() defaultValue: true, restartRequired: true, description: "Fix opening files from the command line or desktop file manager.") + .AddBool(SettingMainWindowLoadedFix, "Preferences saving fix (HasPreviousPackageInstalled)", + defaultValue: false, + restartRequired: true, + description: "Patch OnMainWindowLoaded to skip the HasPreviousPackageInstalled check that throws under Wine (fixes preferences not saving). On Affinity 3.2.x this exposes the first-run onboarding/home page which is hosted in an in-app WebView2 that Wine cannot render, causing a startup crash. Leave disabled unless you know your Affinity/Wine combination doesn't hit the WebView2 path.") .AddSection("Crash Fixes") .AddBool(SettingForceSyncFontEnum, "Force synchronous font enumeration", defaultValue: true, @@ -108,8 +113,15 @@ public override void OnPatch(Harmony harmony, IPluginContext context) Patches.BezierSplitBudgetPatch.Apply(); } - context.Patch("MainWindowLoaded fix", - h => Patches.MainWindowLoadedPatch.ApplyPatches(h)); + if (context.Settings.GetEffectiveValue(SettingMainWindowLoadedFix)) + { + context.Patch("MainWindowLoaded fix", + h => Patches.MainWindowLoadedPatch.ApplyPatches(h)); + } + else + { + Logger.Info("Skipping MainWindowLoaded fix (disabled to avoid WebView2 onboarding crash on Affinity 3.2.x)"); + } if (context.Settings.GetEffectiveValue(SettingForceSyncFontEnum)) {