Prevent deadlock if working on non-main thread
This commit is contained in:
parent
756f00ae8f
commit
a97ba52dbf
@ -615,10 +615,15 @@ void MVKSwapchain::initSurfaceImages(const VkSwapchainCreateInfoKHR* pCreateInfo
|
||||
if (mtlLayer) {
|
||||
NSString* screenName = @"Main Screen";
|
||||
#if MVK_MACOS && !MVK_MACCAT
|
||||
// To prevent deadlocks, avoid dispatching to the main thread at the cost of a less informative log.
|
||||
if (NSThread.currentThread.isMainThread) {
|
||||
auto* screen = mtlLayer.screenMVK;
|
||||
if ([screen respondsToSelector:@selector(localizedName)]) {
|
||||
screenName = screen.localizedName;
|
||||
}
|
||||
} else {
|
||||
screenName = @"?";
|
||||
}
|
||||
#endif
|
||||
MVKLogInfo("Created %d swapchain images with size (%d, %d) and contents scale %.1f in layer %s (%p) on screen %s.",
|
||||
imgCnt, imgExtent.width, imgExtent.height, mtlLayer.contentsScale, mtlLayer.name.UTF8String, mtlLayer, screenName.UTF8String);
|
||||
|
Loading…
x
Reference in New Issue
Block a user