SaschaWillems / VulkanCapsViewer

Vulkan hardware capability viewer
GNU Lesser General Public License v3.0
319 stars 70 forks source link

Segfault on MacOS when no surface is available #192

Closed mizvekov closed 7 months ago

mizvekov commented 1 year ago

I am creating a homebrew "package" (formula) for vulkanCapsViewer. Note that homebrew is not MacOS specific, and supports linux as well, and some of the issues here relate to that.

Since this repo lacks any tests, and homebrew policy requires some minimum testing, I am writing some myself, on the package formula.

The homebrew linux CI is headless, and for vulkanCapsViewer this is quite a serious limitation as even --help will fail because it can't connect to X11/wayland.

So to work around that, I am running the tests under the QT_QPA_PLATFORM=offscreen environment variable. This is enough to get linux CI working for a simple "-- help works" test.

As this is not quite good enough testing, I am also writing a test case for "-s works and provides a json file". But at least on MacOS, this however crashes deep in the bowels of MoltenVK.

stacktrace:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                        0x188969408 objc_msgSend + 8
1   libMoltenVK.dylib                      0x10a0379f0 MVKSurface::MVKSurface(MVKInstance*, VkMacOSSurfaceCreateInfoMVK const*, VkAllocationCallbacks const*) + 120
2   libMoltenVK.dylib                      0x10a039fbc MVKInstance::createSurface(VkMacOSSurfaceCreateInfoMVK const*, VkAllocationCallbacks const*) + 56
3   libMoltenVK.dylib                      0x10a036eb0 vkCreateMacOSSurfaceMVK + 84
4   libvulkan.1.3.268.dylib                0x104cb8fe8 terminator_CreateMacOSSurfaceMVK + 156
5   vulkanCapsViewer                       0x10445bf38 VulkanCapsViewer::initVulkan() + 3188 (vulkancapsviewer.cpp:794)
6   vulkanCapsViewer                       0x10444e56c VulkanCapsViewer::VulkanCapsViewer(QWidget*) + 1396 (vulkancapsviewer.cpp:218)
7   vulkanCapsViewer                       0x10445c858 VulkanCapsViewer::VulkanCapsViewer(QWidget*) + 36 (vulkancapsviewer.cpp:146)
8   vulkanCapsViewer                       0x10438cdc8 main + 3188 (main.cpp:93)
9   dyld                                   0x1889b5058 start + 2224

This is tested on an ARM64 MacOS, vulkancapsviewer compiled in Debug mode.

SaschaWillems commented 1 year ago

I don't own any apple devices and can't help with this issue. If you need a fix for it, feel free to provide a PR. If it's a bug with MoltenVK, the please open an issue in the MoltenVK repo.

SaschaWillems commented 1 year ago

I also don't have plans to support a full headless mode. For that I have created https://github.com/SaschaWillems/VulkanCapsViewerCmdLine, which is a command line only version of the caps viewer with minimal dependencies (no Qt). This was a request by an IHV.