I am swizzling CAMetalLayer.nextDrawable using the code provided on StackOverflow in this answer so I can save the textures from each drawable.
@objc func newNextDrawable() -> CAMetalDrawable? {
// After swizzling, originalNextDrawable() actually calls the real nextDrawable()
let drawable = originalNextDrawable()
// Save the drawable
nextDrawableExtPropertyData._currentSceneDrawable = drawable
return drawable
}
However, when running in Instruments, this code is spawning a bunch of leaks involving CAMetalDrawable and NSMutableArray (I think the drawables are referencing arrays). I don't see these same leaks if I don't swizzle.
Anyone know why this would be leaking?
Thanks.