Skip to content

Make the Canva sign-in callback reach Affinity v3 - #223

Merged
ryzendew merged 1 commit into
ryzendew:mainfrom
afonsofigs:fix/canva-sign-in
Oct 1, 2026
Merged

ryzendew merged 1 commit into
ryzendew:mainfrom
afonsofigs:fix/canva-sign-in

Conversation

@afonsofigs

Copy link
Copy Markdown
Contributor

Signing in to Canva ends with the browser opening an affinity:// URL. Under Wine it never reaches Affinity v3, or the running Affinity crashes when it does.

Two causes:

  • Affinity handles the URL in ProcessCommandLineArguments. The CLR cannot JIT that method without WinMetadata and the .NET WinRT facade System.Runtime.WindowsRuntime, which winetricks dotnet48 does not install.
  • Wine's generated handler runs wine start %u. With Wine 10.0 and 10.10 that crashes on URLs longer than about 300 characters, and the callback is about 1700.

Changes:

  • Copy the two facades from the .NET 4.8 offline installer (winetricks cache, or downloaded with the winetricks URL and SHA-256) into the prefix GAC, and check their SHA-256.
  • Register affinity-url-handler.desktop, which reuses the Exec line of Affinity.desktop, only when WinMetadata and the facades are present. A handler from another setup is left in place.
  • New Troubleshooting button "Fix Canva Sign-in (v3)". Docs in Known Issues and the GUI guide.
  • Wine 9.x and 10.x only. With Wine 11.12 the method also needs the Windows WinMetadata and the native wintypes.dll, which the installer only sets up for 9.14 and 10.10.

Tested on Ubuntu 26.04 with ElementalWarrior Wine 10.10, Affinity 3.3.0.4850 and 7-Zip 26.00. Sign-in completed with the facades and a handler that runs Affinity.exe directly. The installer functions were tested in a harness with a fake HOME. Wine 9.14 is untested. On Wine 11.12 I only compiled the method.

Not covered: p7zip on other distros, the Ubuntu Snapshot launcher with AFFINITY_WINE, and a download timeout. My other PR (Affinity setup crash on Ubuntu 26.04) adds the same affinity_v3_exe_path() helper. The two merge without conflicts, and the second one can drop its copy.

🤖 Generated with Claude Code

Signing in to Canva ends with the browser opening an affinity:// URL.
Two things stop it from reaching Affinity v3 under Wine:

1. Affinity handles the URL in
   Serif.Affinity.Application.ProcessCommandLineArguments, and the CLR
   cannot JIT that method without WinMetadata and
   System.Runtime.WindowsRuntime. `winetricks dotnet48` runs the .NET
   4.8 offline installer with the prefix set to Windows 7, and that
   installer only carries the WinRT facades inside its Windows 8+
   servicing packages; with the prefix set to Windows 10 they are not
   installed either. In the decompiled Serif.Affinity.dll, a second
   Affinity instance forwards its arguments to the running one over a
   named pipe. With the facades missing, the running Affinity crashes
   with FileNotFoundException when the URL is forwarded.

   install_windowsruntime_facades() copies System.Runtime.
   WindowsRuntime and System.Runtime.WindowsRuntime.UI.Xaml from the
   Windows 10 package inside ndp48-x86-x64-allos-enu.exe (winetricks
   cache, or downloaded with the winetricks URL and SHA-256) into the
   prefix GAC, and checks their SHA-256.

2. No working affinity:// handler is registered. The one Wine
   generates runs `wine start %u` with the system Wine. With Wine
   10.0 and 10.10, `wine start` crashes (c0000005) on URLs longer
   than about 300 characters. The callback is about 1700 characters.

   create_affinity_url_handler() writes affinity-url-handler.desktop,
   which reuses the Exec= line of Affinity.desktop (AffinityHook.exe
   with AffinityPluginLoader) plus %u, and makes it the default. It
   does so only when WinMetadata and the facades are in the prefix,
   since otherwise the running Affinity crashes when the URL arrives.
   It leaves an affinity:// handler from another setup in place and
   keeps the rest of mimeapps.list.

Wine 11.12 is left out. With it, the method compiles only when the
prefix also has the Windows WinMetadata and the native wintypes.dll,
which the installer sets up only for Wine 9.14 and 10.10. This was
checked by compiling the method in a test prefix. With any Wine other
than 9.x or 10.x nothing is installed, and a handler left from an
earlier Wine version is removed.

Both run after installing or updating Affinity v3, after Reinstall
WinMetadata, and from a new Troubleshooting button, "Fix Canva
Sign-in (v3)". The handler is
refreshed when the desktop entries or the graphics backend change and
removed on uninstall.

Tested on Ubuntu 26.04 with ElementalWarrior Wine 10.10, Affinity
3.3.0.4850 and 7-Zip 26.00. Sign-in completed in the running Affinity
with the facades and a handler that runs Affinity.exe directly. The
installer functions were tested in a harness with a fake HOME. With
AffinityPluginLoader and WineFix 0.3.0, the running Affinity stays up
after a URL is forwarded through AffinityHook.exe; with the facades
removed, it crashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ryzendew
ryzendew merged commit ae93914 into ryzendew:main Oct 1, 2026
ryzendew pushed a commit that referenced this pull request Oct 1, 2026
I added this helper in both #223 and #224. The two copies are
identical, and the later definition overrides the earlier one, so
removing the earlier copy changes nothing. This keeps the copy from
#223.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@afonsofigs
afonsofigs deleted the fix/canva-sign-in branch October 1, 2026 23:13
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.

2 participants