Repository navigation
Make the Canva sign-in callback reach Affinity v3 - #223
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ProcessCommandLineArguments. The CLR cannot JIT that method without WinMetadata and the .NET WinRT facadeSystem.Runtime.WindowsRuntime, whichwinetricks dotnet48does not install.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:
affinity-url-handler.desktop, which reuses the Exec line ofAffinity.desktop, only when WinMetadata and the facades are present. A handler from another setup is left in place.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.exedirectly. 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 sameaffinity_v3_exe_path()helper. The two merge without conflicts, and the second one can drop its copy.🤖 Generated with Claude Code