7

I have macCatalyst app that recently gets some random crashes. Searched everywhere but without finding any good leads. My guess is that it's related to memory or too many views visible on the screen. I do not get a good stack trace, but this it what's showing in the log:

-[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f8cd811c600 (label: <no label set>):
<MTLToolsObject: 0x7f8b0f9e3d60> -> <MTLIGAccelTexture: 0x7f8cd8566a00>
    label = CAMetalLayer Drawable 
    textureType = MTLTextureType2D 
    pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB 
width = 772 
height = 1372 
depth = 1 
arrayLength = 1 
mipmapLevelCount = 1 
sampleCount = 1 
cpuCacheMode = MTLCPUCacheModeDefaultCache 
storageMode = MTLStorageModeManaged 
hazardTrackingMode = MTLHazardTrackingModeTracked 
resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked  
usage = MTLTextureUsageShaderRead MTLTextureUsageShaderWrite MTLTextureUsageRenderTarget MTLTextureUsagePixelFormatView 
shareable = 0 
framebufferOnly = 0 
purgeableState = MTLPurgeableStateNonVolatile 
swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] 
isCompressed = 0 
parentTexture = <null> 
parentRelativeLevel = 0 
parentRelativeSlice = 0 
buffer = <null> 
bufferOffset = 0 
bufferBytesPerRow = 0 
iosurface = 0x600002533060 
iosurfacePlane = 0 
allowGPUOptimizedContents = YES'
-[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f8cd811c600 (label: <no label set>):
<MTLToolsObject: 0x7f8b0f9e3d60> -> <MTLIGAccelTexture: 0x7f8cd8566a00>
    label = CAMetalLayer Drawable 
textureType = MTLTextureType2D 
pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB 
width = 772 
height = 1372 
depth = 1 
arrayLength = 1 
mipmapLevelCount = 1 
sampleCount = 1 
cpuCacheMode = MTLCPUCacheModeDefaultCache 
storageMode = MTLStorageModeManaged 
hazardTrackingMode = MTLHazardTrackingModeTracked 
resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked  
usage = MTLTextureUsageShaderRead MTLTextureUsageShaderWrite MTLTextureUsageRenderTarget MTLTextureUsagePixelFormatView 
shareable = 0 
framebufferOnly = 0 
purgeableState = MTLPurgeableStateNonVolatile 
swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] 
isCompressed = 0 
parentTexture = <null> 
parentRelativeLevel = 0 
parentRelativeSlice = 0 
buffer = <null> 
bufferOffset = 0 
bufferBytesPerRow = 0 
iosurface = 0x600002533060 
iosurfacePlane = 0 
allowGPUOptimizedContents = YES'

I'm running on a Intel Mac mini with 32Gb memory. It often crashes often when showing a MapView on screen. But also in some other cases.

Edit: Could be related to programatically zooming in animated in a MapView on MacCatalyst. A workaround is for now to disable the animation. Will research more.

Sunkas
  • 9,542
  • 6
  • 62
  • 102
  • Look like you need something to keep a strong reference to this metal object so it lives at least as long as the command buffer – Alexander Nov 04 '21 at 14:58
  • 2
    Is this possible a bug in Catalyst or MapView? I do not use any kind of low-level coding to interact with metal. I seems to happen a lot when I programatically zoom in animated on a MapView. But it happens (even not that common) in other situations as well. A workaround seem to be to disable the animation when zooming in. – Sunkas Nov 05 '21 at 07:47
  • 2
    "I do not use any kind of low-level coding to interact with metal." oh. that's... interesting. I have no idea :/ I would suggest you post on the apple dev forums, this looks like something that might need insider info to address – Alexander Nov 05 '21 at 12:32
  • I have a SwiftUI program for tracking a remote device that experiences the same issue. The target is drawn as a circle overlay 10-50 times/s. If it gets off-screen, setCenter is called to focus on the target. One mitigating factor that helps is to avoid updating the overlay when setCenter or setRegion are called. I block overlay updates for 0.1 seconds, and setCenter setRegion for 1-4 seconds. – George Valkov Feb 02 '23 at 12:25
  • 1
    Also under Edit Scheme..., Run, Diagnostics: uncheck Metal API validation. – George Valkov Feb 02 '23 at 12:26

0 Answers0