Skip to content

Related Projects LoginFix

gamedirection edited this page Aug 22, 2026 · 1 revision

LoginFix

LoginFix is a community plugin that fixes the Canva sign-in flow crashing under Wine. It is a plugin for AffinityPluginLoader (APL), but it is not an official APL or WineFix plugin. It is community-made. It was tested on Wine 11.15, on both a stock distro build and a custom-patched local build. Both worked the same way. No custom Wine build is required.

Source: Guides/Wine/LoginFix in this repository.

What It Fixes

Before this fix, clicking "Log in or sign up" and completing the Canva OAuth flow in your browser would crash Affinity. Sometimes the crash happened the moment you clicked "Open Affinity" in the browser. Other times, it happened right when clicking "Log in or sign up" itself.

Root Cause

A full managed stack trace and WINEDEBUG tracing traced the crash to this chain:

  1. Serif.Affinity.Application.ProcessCommandLineArguments has one branch, only reached for an unrelated affinity-open-file: argument, that calls Windows.ApplicationModel.DataTransfer.SharedStorageAccessManager.RedeemTokenForFileAsync.
  2. Wine has no WinRT implementation of that type.
  3. The .NET CLR resolves every type referenced anywhere in a method's body when it JITs that method, not just the branch that actually runs. So simply calling ProcessCommandLineArguments throws a TypeLoadException (System.TypeLoadException), regardless of which arguments were passed.

This matters because the Canva sign-in callback goes through this exact method: the second Affinity.exe instance the OS launches for the callback URL forwards its arguments to the already-running instance over a named pipe, and that named-pipe handler lands in ProcessCommandLineArguments. So login always crashed.

Harmony (the patching library APL plugins use) 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 method body, including the poisoned SharedStorageAccessManager call. A patch on that method throws the same TypeLoadException, which Harmony's own retry-and-defer logic keeps swallowing forever.

The Fix

LoginFix instead patches ProcessCommandLineArguments's two callers:

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

Neither caller references the poisoned type directly, only by method signature, which Harmony can resolve without a problem. LoginFix fully replaces both 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.

Building and Installing

See Login Solution and Scripts for the practical, action-first version of these steps. Requires the .NET SDK (targets net48).

  1. Install AffinityPluginLoader and WineFix first, if you have not already.
  2. Copy AffinityPluginLoader.dll from your Affinity install directory into the LoginFix project folder (next to LoginFix.csproj).
  3. Run dotnet build -c Release.
  4. Copy the built bin/Release/net48/win-x64/LoginFix.dll into apl/plugins/, alongside WineFix.dll.
  5. Relaunch Affinity through Affinity.exe (which is the AffinityHook launcher once APL is installed).

No Wine-side changes are needed. LoginFix works entirely inside Affinity's own process, so it works on your distro's stock Wine package.

Seeing It Work

  1. Click Log in or sign up in Affinity. Your browser opens to complete the Canva sign-in.

    Affinity's login dialog: 'Log in or sign up to Canva through your browser, then we'll bring you right back here'
  2. After signing in, the browser hands the callback back to Affinity through the affinity:// protocol. Your desktop may ask to confirm opening the app.

    Browser dialog asking to confirm opening Affinity for a page.service.serif.com link, with Affinity's own 'A new tab has been opened' dialog behind it
  3. With LoginFix installed, this completes instead of crashing, and you land back in Affinity signed in.

    Affinity's Welcome screen showing 'Welcome, Alexander Sierputowski', confirming a successful Canva sign-in

Troubleshooting

For build/install problems and the manual OAuth-callback injection fallback script, see Login Solution and Scripts.

Credits

Built and verified during this project's own troubleshooting sessions, confirmed working end to end on both a manual Wine install and a Lutris install. See Related-Projects-AffinityPluginLoader-WineFix for the loader LoginFix depends on, and full credit to noahc3 for APL itself.

Clone this wiki locally