Skip to content

Fix Vulkan initialization on Parallels - #22104

Open
orisson003 wants to merge 6 commits into
AvaloniaUI:mainfrom
orisson003:fix/parallels-vulkan-fallback
Open

Fix Vulkan initialization on Parallels#22104
orisson003 wants to merge 6 commits into
AvaloniaUI:mainfrom
orisson003:fix/parallels-vulkan-fallback

Conversation

@orisson003

Copy link
Copy Markdown

What does the pull request do?

Detects the Parallels Display Adapter on Windows before initializing
Vulkan and skips Vulkan initialization when the adapter is present. This is to solve the bug: #22096.

This allows Avalonia to continue with its existing rendering-mode
fallback mechanism instead of crashing during Vulkan initialization.

What is the current behavior?

When running an Avalonia application with Vulkan enabled inside a
Parallels Desktop Windows VM, Vulkan initialization can result in a
native access violation, thus crashing the program and not invoking the fallback mechanism.

Investigation of the crash dump showed that the failure occurs during
Vulkan initialization. Because this is a native crash rather than a
normal Vulkan initialization failure, control does not return to
Avalonia's rendering-mode selection logic, so the configured fallback
renderer is never reached and the application terminates.

What is the updated/expected behavior with this PR?

When the Parallels Display Adapter is detected, Vulkan initialization
returns null before entering the failing Vulkan initialization path.
Avalonia can therefore continue through its existing rendering-mode
selection and use the next configured rendering mode.

This does not change the normal rendering-mode ordering. It only prevents Vulkan from being attempted on
the affected Parallels configuration.

The change was validated in a Parallels Desktop Windows VM:

  • Before the change, the application terminated during Vulkan
    initialization.
  • With the change, Vulkan is skipped and the application successfully
    launches using the fallback rendering mode.
  • Avalonia.Win32 builds successfully for both net8.0 and net10.0.
  • git diff --check passes.

How was the solution implemented (if it's not obvious)?

The Parallels virtual GPU is exposed to Windows as the
Parallels Display Adapter.

The implementation uses DXGI to enumerate the available display
adapters and checks the adapter description for
Parallels Display Adapter.

The existing DirectXUnmanagedMethods.CreateDXGIFactory1 and MicroCom
interfaces are reused for adapter enumeration. If the adapter is
detected, VulkanSupport.TryInitialize returns null, allowing the
existing rendering-mode fallback mechanism to proceed.

Checklist

Breaking changes

None.

Obsoletions / Deprecations

None.

Fixed issues

Fixes #22096

@orisson003

Copy link
Copy Markdown
Author

Parallels currently documents DirectX 11.1 and OpenGL 4.3 as the supported 3D acceleration APIs for Windows 11 on Arm, rather than Vulkan. Avalonia also has established ANGLE/D3D11 and OpenGL paths on Windows. We therefore treat the Parallels Display Adapter as an environment where Vulkan should be skipped rather than attempted and allowed to crash the process.

The intention here isn't to change the normal rendering-mode preference on Windows, but to avoid a known crash path on Parallels. We observed a native access violation during Vulkan initialisation in a Windows 11 ARM VM running under Parallels. Because the failure occurs as a native crash, Avalonia's existing rendering-mode fallback cannot take effect.

We validated this in the same Parallels VM: with the detection in place, Vulkan returns null and Avalonia successfully proceeds to the next configured rendering mode. Thus, we're making Vulkan gracefully opt out only when the problematic Parallels adapter is detected.

@cla-avalonia

Copy link
Copy Markdown
Collaborator

@orisson003,

Please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following:

@cla-avalonia agree
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ),
and conveys certain license rights to the AvaloniaUI OÜ ( “AvaloniaUI OÜ” ) for Your contributions to
AvaloniaUI OÜ open source projects. This Agreement is effective as of the latest signature date below.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form,
that is delivered by You to AvaloniaUI OÜ under this Agreement.

“Project” means any of the projects owned or managed by AvaloniaUI OÜ and offered under a license
approved by the Open Source Initiative (www.opensource.org).

“Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
Project, including but not limited to communication on electronic mailing lists, source code control
systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
discussing and improving that Project, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Submission.”

“Submission” means the Code and any other copyrightable material Submitted by You, including any
associated comments and documentation.

2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
Project. This Agreement covers any and all Submissions that You, now or in the future (except as
described in Section 4 below), Submit to any Project.

3. Originality of Work. You represent that each of Your Submissions is entirely Your
original work. Should You wish to Submit materials that are not Your original work,
You may Submit them separately to the Project if You (a) retain all copyright and
license information that was in the materials as you received them, (b) in the
description accompanying your Submission, include the phrase "Submission
containing materials of a third party:" followed by the names of the third party and any
licenses or other restrictions of which You are aware, and (c) follow any other
instructions in the Project's written guidelines concerning Submissions.

4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
Submission is made in the course of Your work for an employer or Your employer has intellectual
property rights in Your Submission by contract or applicable law, You must secure permission from Your
employer to make the Submission before signing this Agreement. In that case, the term “You” in this
Agreement will refer to You and the employer collectively. If You change employers in the future and
desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
and secure permission from the new employer before Submitting those Submissions.

5. Licenses.

a. Copyright License. You grant AvaloniaUI OÜ, and those who receive the Submission directly
or indirectly from AvaloniaUI OÜ, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable
license in the Submission to reproduce, prepare derivative works of, publicly display, publicly perform,
and distribute the Submission and such derivative works, and to sublicense any or all of the foregoing
rights to third parties.

b. Patent License. You grant AvaloniaUI OÜ, and those who receive the Submission directly or
indirectly from AvaloniaUI OÜ, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license
under Your patent claims that are necessarily infringed by the Submission or the combination of the
Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
import or otherwise dispose of the Submission alone or with the Project.

c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
granted by implication, exhaustion, estoppel or otherwise.

6. Representations and Warranties. You represent that You are legally entitled to grant the above
licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
have disclosed under Section 3 ). You represent that You have secured permission from Your employer to
make the Submission in cases where Your Submission is made in the course of Your work for Your
employer or Your employer has intellectual property rights in Your Submission by contract or applicable
law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
EXPRESSLY STATED IN SECTIONS 3, 4, AND 6 , THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

7. Notice to AvaloniaUI OÜ. You agree to notify AvaloniaUI OÜ in writing of any facts or
circumstances of which You later become aware that would make Your representations in this
Agreement inaccurate in any respect.

8. Information about Submissions. You agree that contributions to Projects and information about
contributions may be maintained indefinitely and disclosed publicly, including Your name and other
information that You submit with Your Submission.

9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the Republic of Estonia, and
the parties consent to exclusive jurisdiction and venue in the courts sitting in Talinn,
Estonia. The parties waive all defenses of lack of personal jurisdiction and forum non-conveniens.

10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
supersedes any and all prior agreements, understandings or communications, written or oral, between
the parties relating to the subject matter hereof. This Agreement may be assigned by AvaloniaUI OÜ.

AvaloniaUI OÜ dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1.

@orisson003

Copy link
Copy Markdown
Author

@orisson003,

Please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following:

@cla-avalonia agree

Contributor License Agreement

@cla-avalonia agree

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069159-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6

Copy link
Copy Markdown
Member

We already have Win32PlatformOptions.GraphicsAdapterSelectionCallback options API. It's currently only used by Angle, but might be extended for Vulkan on Win32.

public Func<IReadOnlyList<PlatformGraphicsDeviceAdapterDescription>, int>?
GraphicsAdapterSelectionCallback { get; set; }

@orisson003

Copy link
Copy Markdown
Author

Thanks, that’s a good point. The current implementation performs a DXGI adapter check directly in VulkanSupport because the immediate issue is that the Parallels Vulkan path can hit a native access violation before the existing rendering-mode fallback can run.

I’ll look into extending the existing adapter-selection mechanism to Vulkan instead, while keeping the Parallels case as the validation scenario.

@MrJul MrJul added bug os-windows backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Aug 31, 2026
@orisson003

orisson003 commented Aug 31, 2026

Copy link
Copy Markdown
Author

Thanks for pointing out Win32PlatformOptions.GraphicsAdapterSelectionCallback. After testing the suggested approach with the suggested options API, just found a significant difference that’s relevant to this issue.

In the Parallels Windows VM, forcing Avalonia.ControlCatalog.Desktop to use Vulkan produces:

MESA: warning: .../microsoft/vulkan/dzn_meta.c:220:
VK_ERROR_INITIALIZATION_FAILED
0xC0000005

The native stack is:

Avalonia.Vulkan.VulkanInstanceApi.CreateDevice(...)
Avalonia.Vulkan.Interop.VulkanDevice.Create(...)
Avalonia.Vulkan.VulkanPlatformGraphics.TryCreate(...)
Avalonia.Win32.Vulkan.VulkanSupport.TryInitialize(...)
Avalonia.Win32.Win32GlManager.InitializeCore()

Logging immediately before and after GraphicsAdapterSelectionCallback shows that neither message is reached before the crash. This might indicate the native crash occurs before the callback is invoked. Although the Vulkan adapters can be enumerated and represented as PlatformGraphicsDeviceAdapterDescription, this does not help with this failure.

Vulkan device creation can reach the point of the native access violation before the callback has an opportunity to select or reject an adapter. Avalonia.ControlCatalog.Desktop runs correctly when Vulkan is not selected, so the failure appears specific to the Vulkan initialization path in the affected Parallels environment.

Therefore, GraphicsAdapterSelectionCallback still seems appropriate for Vulkan adapter selection in general, but it is too late for this particular failure. The existing rendering-mode fallback appears to be a better fit: detect the affected Parallels environment before VulkanSupport.TryInitialize(), skip Vulkan, and allow the existing fallback to try WGL and then Software.

To my knowledge, the original approach based on these diagnostics appears more suitable for this particular failure mode. It avoids entering the Vulkan initialisation path responsible for the native crash. The diagnostics appear to support this.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069212-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069328-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@Gillibald

Copy link
Copy Markdown
Contributor

Can you use https://docs.vulkan.org/refpages/latest/refpages/source/vkEnumeratePhysicalDevices.html to enumerate devices and blacklist the Parallels gpu? That avoids having a dependency on DirectX

@orisson003

Copy link
Copy Markdown
Author

Can you use https://docs.vulkan.org/refpages/latest/refpages/source/vkEnumeratePhysicalDevices.html to enumerate devices and blacklist the Parallels gpu? That avoids having a dependency on DirectX

Many thanks for the suggestion. This version uses vkEnumeratePhysicalDevices to detect the Parallels adapter rather than relying on DXGI. The Parallels device is therefore skipped during Vulkan device selection based on the name returned by vkGetPhysicalDeviceProperties. This happens before vkCreateDevice which is where the native crash in the Parallels VM occurs.

If no other usable Vulkan device is found the normal Vulkan initialisation failure path is followed allowing the configured fallback rendering mode to be selected. This was tested on the Parallels VM with Vulkan forced as the first rendering mode and the application started without the previous native crash.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069352-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

});
}

private static unsafe bool IsParallelsDisplayAdapter()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now redundant, isn't it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aww, my bad. I removed IsParallelsDisplayAdapter() in the working tree earlier, but then I suppose when I run git rebase later, it just effectively restored the old version from the remote PR branch. Get it fixed now.

@orisson003
orisson003 force-pushed the fix/parallels-vulkan-fallback branch from 4403043 to 6f6a4a7 Compare September 2, 2026 13:20
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069358-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

instance.GetPhysicalDeviceProperties(physicalDevice, out var properties);

var deviceName = Marshal.PtrToStringAnsi((IntPtr)properties.deviceName);
if (deviceName?.StartsWith("Parallels Display Adapter", StringComparison.OrdinalIgnoreCase) == true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for vid/pid instead? Should also introduce some kind of configurable blacklist like we do with glx.

Also, please, post vulkaninfo output from your VM. If it's missing from system, get one from Vulkan SDK

@orisson003 orisson003 Sep 2, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m afraid that I doubt if VID/PID is workable here. Parallels doesn’t provide a native Vulkan driver; the Vulkan path in this VM appears to go through Microsoft’s D3D mapping/DZN implementation, which fails during initialization. vulkaninfoSDK reports VK_ERROR_INITIALIZATION_FAILED from DZN, and doesn’t successfully enumerate a usable Vulkan device. The output looks like this:


...> vulkaninfoSDK.exe --summary
ERROR: [Loader Message] Code 0 : loader_get_json: Failed to open JSON file C:\Program Files (x86)\Steam\SteamOverlayVulkanLayer64.json
ERROR: [Loader Message] Code 0 : loader_get_json: Failed to open JSON file C:\Program Files (x86)\Steam\SteamFossilizeVulkanLayer64.json
WARNING: [Loader Message] Code 0 : Removing layer VK_LAYER_MSFT_driver_sorting (C:\Program Files\WindowsApps\Microsoft.D3DMappingLayers_1.2608.1.0_arm64__8wekyb3d8bbwe\dzn_layer.x64.json) because it is a duplicate of VK_LAYER_MSFT_driver_sorting (C:\Program Files\WindowsApps\Microsoft.D3DMappingLayers_1.2608.1.0_arm64__8wekyb3d8bbwe\dzn_layer.arm64.json)
ERROR: [Loader Message] Code 0 : windows_read_data_files_in_registry: Registry lookup failed to get ICD manifest files.  Possibly missing Vulkan driver?
WARNING: [Loader Message] Code 0 : Layer VK_LAYER_MSFT_driver_sorting uses API version 1.3 which is older than the application specified API version of 1.4. May cause issues.
MESA: warning: C:\__w\1\s\mesa\src\microsoft\vulkan\dzn_meta.c:220: VK_ERROR_INITIALIZATION_FAILED
WARNING: [C:\__w\1\s\mesa\src\microsoft\vulkan\dzn_meta.c:220] Code 0 : VK_ERROR_INITIALIZATION_FAILED

So I’m not sure there is a reliable Vulkan VID/PID we can use for the blacklist. The Parallels device itself is exposed through WDDM/DXGI rather than a native Vulkan ICD.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069447-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch bug os-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vulkan backend does not gracefully fall back when rendering is unusable

7 participants