Recently, I was asked to look at a customer issue involving Windows Presentation Foundation (WPF) apps on Windows Server 2019 with a GPU. In this case, the app only performed well on the primary monitor and was slow to render on other monitors. In some instances, the app would fail to draw entirely, which resulted in missing graphics.
Fortunately, I was able to reproduce the behavior with a small test app I wrote. Upon instrumenting the app and various hooks we use to enable hardware acceleration for WPF apps, I could see why the customer was seeing this rather peculiar problem.
There are undocumented registry settings admins can use to control the hook we inject into WPF apps. Toggling these settings results in hardware acceleration being available to WPF apps across all monitors, and I wanted to share this so you are also able to get the best out of your WPF apps running on Windows multi-session OS:
1) Open the Registry Editor on the VDA and navigate to the following key:
HKLM\Software\Citrix\CtxHook\AppInit_DLLs\Graphics Helper
2) Create or edit the follow registry values:
[REG_DWORD] AdapterHandle = 0x00000001
[REG_DWORD] DevicePath = 0x00000001
[REG_DWORD] Flag = 0x00000412
[REG_DWORD] WPF = 0x00000001
3) Create a sub-key with the executable name of your WPF app. For example, if your app is called “mywpfapp.exe”, create the following key:
HKLM\Software\Citrix\CtxHook\AppInit_DLLs\Graphics Helper\mywpfapp.exe
4) Reboot.
With these settings in place, both the customer and I were able to see consistent performance across all monitors without any slow rendering or missing graphics.
If you’re experiencing similar issues with WPF apps on Windows multi-session OS, I’d recommend trying this fix to see if it improves things for you. And let me know how it goes!
Please note, editing the registry incorrectly can cause serious problems that may require you to reinstall your operating system. Citrix cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk, and be sure to back up the registry before you edit it!