Skip to content

Add LoginFix, fixes the Canva sign-in crash under Wine - #57

Open
Gamedirection wants to merge 1 commit into
noahc3:mainfrom
Gamedirection:add-loginfix-plugin
Open

Add LoginFix, fixes the Canva sign-in crash under Wine#57
Gamedirection wants to merge 1 commit into
noahc3:mainfrom
Gamedirection:add-loginfix-plugin

Conversation

@Gamedirection

Copy link
Copy Markdown

Summary

Adds LoginFix, a plugin that fixes the Canva sign-in flow crashing under Wine. WineFix's own README already lists this as a known limitation:

Canva sign-in dialog patched out (temporary; pending protocol handler fix)

LoginFix is that fix. It lets sign-in complete instead of disabling it.

Root cause

Serif.Affinity.Application.ProcessCommandLineArguments references a WinRT type Wine does not implement (SharedStorageAccessManager), only reached on an unrelated affinity-open-file: argument. The .NET CLR resolves every type in a method body at JIT time. So any call into that method throws TypeLoadException, including the affinity:// OAuth callback path the sign-in flow depends on.

Harmony cannot patch ProcessCommandLineArguments directly either. Patching a method, even with a plain prefix, requires Harmony to decompile its IL. That means resolving every operand in the body, including the poisoned call.

The fix

LoginFix patches the method's two callers instead:

  • ProcessArguments(), the app's own startup command line
  • SingleInstanceThread(), the named-pipe listener that receives the sign-in callback from a second launched instance

Both only reference the poisoned type by signature, which Harmony can resolve safely. Both are fully replaced with a safe reimplementation that never calls the real ProcessCommandLineArguments. The only thing dropped is the unrelated affinity-open-file: handling, which needs SharedStorageAccessManager and cannot work under Wine regardless.

Structure

Follows WineFix's exact pattern:

  • LoginFix/LoginFix.csproj, LoginFixPlugin.cs, Patches/ProcessCommandLineArgumentsPatch.cs
  • LoginFix/README.md, LoginFix/LICENSE (GPLv2, with the same Canva Zero-Clause BSD exemption WineFix uses)
  • Registered in AffinityPluginLoader.sln
  • docs/loginfix/index.md, linked from docs/index.md and mkdocs.yml

Compatibility with WineFix

LoginFix and WineFix patch different methods and can run together. If both are installed, WineFix's sign-in dialog suppression and LoginFix's working sign-in flow may conflict, since one hides the dialog and the other completes it. Noted in both READMEs. Whether to adjust WineFix's own patch once LoginFix exists is your call, I have not touched WineFix's code in this PR.

Test plan

  • dotnet build LoginFix/LoginFix.csproj -c Release succeeds, 0 warnings, 0 errors.
  • dotnet build -c Release on the full solution succeeds, all 4 projects build cleanly.
  • LoginFix confirmed working end to end on a manual Wine install and on Lutris, on stock distro Wine 11.15.

WineFix's own README already lists "Canva sign-in dialog patched out
(temporary, pending protocol handler fix)" as a known workaround.
LoginFix is that fix. It lets sign-in complete instead of disabling
it.

Root cause: Serif.Affinity.Application.ProcessCommandLineArguments
references a WinRT type Wine does not implement
(SharedStorageAccessManager), only reached on an unrelated
affinity-open-file: argument. The .NET CLR resolves every type in a
method body at JIT time, so any call into that method throws
TypeLoadException, including the affinity:// OAuth callback path the
sign-in flow depends on.

Harmony cannot patch ProcessCommandLineArguments directly either.
Patching a method, even with a plain prefix, requires Harmony to
decompile its IL, which means resolving every operand in the body,
including the poisoned call.

LoginFix instead patches the method's two callers, ProcessArguments()
and SingleInstanceThread(). Both only reference the poisoned type by
signature, which Harmony can resolve safely. Both are fully replaced
with a safe reimplementation that never calls the real
ProcessCommandLineArguments.

Built and verified on a manual Wine install and on Lutris, tested on
stock distro Wine 11.15. No custom Wine build needed.

Adds LoginFix as a sibling plugin project, following WineFix's exact
structure (csproj, sln registration, README, LICENSE with the same
GPLv2 + Canva Zero-Clause BSD exemption, and a docs page). Verified
the full solution still builds cleanly with LoginFix added.
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.

1 participant