Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rare deadlock during launch via dlopen(). #2067

Merged

Conversation

billhollings
Copy link
Contributor

@billhollings billhollings commented Nov 15, 2023

  • Don't create global MVKPixelFormats instance during launch, as this triggers a call to MTLCopyAllDevices(), which can deadlock if app is also launching other services that use Metal.

Fixes #2050.

MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm Outdated Show resolved Hide resolved
MoltenVK/MoltenVK/API/mvk_datatypes.h Outdated Show resolved Hide resolved
@richard-lunarg
Copy link
Collaborator

I was hopeful when I saw this PR that it would fix a problem I've encountered with Qt frameworks that just started two releases ago. There's a deadlock somewhere (and Qt is using Metal for it's own GUI) as the GUI never shows up, although the render loop runs, and there are no validation errors. The error I'm encountering happens if I link statically, or use the Loader. This is a good fix, I'm just putting out there that there may be more deadlocks like this floating around.

- Don't create global MVKPixelFormats instance during launch,
  as this triggers a call to MTLCopyAllDevices(), which can
  deadlock if app is also launching other services that use Metal.
@billhollings billhollings force-pushed the fix-rare-dlopen-deadlock branch from 5f2c522 to 037ac4b Compare November 17, 2023 00:55
@billhollings
Copy link
Contributor Author

I was hopeful when I saw this PR that it would fix a problem I've encountered with Qt frameworks that just started two releases ago.

Thanks for reporting it.

Uggh. If you have more info about the Qt deadlock, can you open another issue focused on it, please?

@billhollings billhollings merged commit 9f73e77 into KhronosGroup:main Nov 17, 2023
5 checks passed
@billhollings billhollings deleted the fix-rare-dlopen-deadlock branch November 17, 2023 03:18
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.

Deadlock when loading MVK dynamically
4 participants