I have a similar issue. RC simulator may have used arm64 API, Have you excluded arm64 SDK for simulator in the build setting? That may cause the problem.
Post
Replies
Boosts
Views
Activity
It appears that the issue is caused by the RC version of the simulator using arm64-related APIs. Excluding the arm64 SDK for the simulator in the build settings could lead to this problem.
To add some additional information: even if I change modalPresentationStyle to UIModalPresentationPageSheet or UIModalPresentationFormSheet (and set preferredContentSize), after the presentation animation, the final page still appears as shown in the screenshot.
If I change it to UIModalPresentationCustom and add a custom transitionDelegate, manually specifying that the PHPickerViewController only covers half of the screen, all the buttons and cells within the picker are still non-interactive.
Below are parts of similar crash reports with slightly different stack traces:
0 libobjc.A.dylib 0x18c44e838 object_getClass + 48
1 Foundation 0x1930807b4 _NSKeyValueObservationInfoGetObservances + 264
2 Foundation 0x19307fc7c NSKeyValueWillChangeWithPerThreadPendingNotifications + 232
3 QuartzCore 0x19572f14c CAAnimation_setter(CAAnimation*, unsigned int, _CAValueType, void const*) + 128
4 QuartzCore 0x19572f0a4 -[CAPropertyAnimation setKeyPath:] + 52
5 UIKitCore 0x1963e8fc8 -[UIImageView startAnimating] + 684
6 UIKitCore 0x1963e8ce4 -[UIActivityIndicatorView layoutSubviews] + 1128
7 UIKitCore 0x196329c04 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528
8 QuartzCore 0x19573c7ec CA::Layer::layout_if_needed(CA::Transaction*) + 500
9 QuartzCore 0x19573c374 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144
10 QuartzCore 0x195742860 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464
11 QuartzCore 0x19573bb80 CA::Transaction::commit() + 648
12 QuartzCore 0x19573b828 CA::Transaction::flush_as_runloop_observer(bool) + 88
13 CoreFoundation 0x1940ff7bc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
14 CoreFoundation 0x1940fe1c4 __CFRunLoopDoObservers + 548
15 CoreFoundation 0x1940fd8e0 __CFRunLoopRun + 1028
16 CoreFoundation 0x1940fd3f8 CFRunLoopRunSpecific + 608
17 GraphicsServices 0x1d768b4f8 GSEventRunModal + 164
18 UIKitCore 0x1965238a0 -[UIApplication _run] + 888
19 UIKitCore 0x196522edc UIApplicationMain + 340
20 MyApp 0x1048431b0 main + 140
21 dyld 0x1b6e52dcc start + 2240
Thread 0 Crashed:
0 libobjc.A.dylib 0x18c44e838 object_getClass + 48
1 Foundation 0x1930807b4 _NSKeyValueObservationInfoGetObservances + 264
2 Foundation 0x19307fc7c NSKeyValueWillChangeWithPerThreadPendingNotifications + 232
3 QuartzCore 0x19572f14c CAAnimation_setter(CAAnimation*, unsigned int, _CAValueType, void const*) + 128
4 QuartzCore 0x195780354 -[CABasicAnimation setFromValue:] + 52
5 QuartzCore 0x195780200 CALayerCreateImplicitAnimation + 276
6 QuartzCore 0x195715f20 -[CALayer actionForKey:] + 420
7 QuartzCore 0x195715c84 CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*, objc_object*&) + 204
8 QuartzCore 0x195716984 CA::Layer::setter(unsigned int, _CAValueType, void const*) + 792
9 QuartzCore 0x195716644 -[CALayer setOpacity:] + 56
10 MyApp 0x100972ae4 -[CALayer(Visbility) setSimHidden:] + 200
Thread 0 Crashed:
0 libobjc.A.dylib 0x18c44e838 object_getClass + 48
1 Foundation 0x1930807b4 _NSKeyValueObservationInfoGetObservances + 264
2 Foundation 0x19307fc7c NSKeyValueWillChangeWithPerThreadPendingNotifications + 232
3 QuartzCore 0x19572f14c CAAnimation_setter(CAAnimation*, unsigned int, _CAValueType, void const*) + 128
4 QuartzCore 0x19572f0a4 -[CAPropertyAnimation setKeyPath:] + 52
5 QuartzCore 0x19572f050 +[CAPropertyAnimation animationWithKeyPath:] + 36
6 UIKitCore 0x196448c8c __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke_2 + 384
7 UIKitCore 0x196448a3c -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] + 1968
8 QuartzCore 0x195704dec CA::Layer::set_bounds(CA::Rect const&, bool) + 436
9 QuartzCore 0x195704c0c -[CALayer setBounds:] + 132
10 QuartzCore 0x1957048ac -[CALayer setFrame:] + 416
11 UIKitCore 0x1963102fc -[UIView _backing_setFrame:] + 240
12 UIKitCore 0x19630e7e8 -[UIView(Geometry) setFrame:] + 296
13 UIKitCore 0x19630fa38 -[UIImageView _setViewGeometry:forMetric:] + 160
14 UIKitCore 0x196367104 -[UIButtonLegacyVisualProvider layoutSubviews] + 108
15 UIKitCore 0x196367058 -[UIButton layoutSubviews] + 40
16 UIKitCore 0x196329c04 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528
17 QuartzCore 0x19573c7ec CA::Layer::layout_if_needed(CA::Transaction*) + 500
18 UIKitCore 0x19632ccb4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 296
19 MyApp 0x10465973c __74-[KKAssetBrowseCollectionViewController willOpenAssetThumbnailCompletion:]_block_invoke + 328
In my app, the 3rd party SDK (SDWebImage) is installed via Pods, SDWebImage it self includes a PrivacyInfo.xcprivacy, but when archiving the app, SDWebImage's privacy info is not shown in the PDF, only the app's PrivacyInfo is shown. How to solve this issue?
Thank you, I succeeded to open Quartz Composer on M1. But most of the files created by old version crash when editing on new Composer. Anyway, the tool is back to alive.
I used this method when setting the layer's properties like .frame, to prevent implict frame animation from being called.
@implementation CALayer (Animation)
(void)disableAnimation:(VoidBlock)block{
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
block();
[CATransaction commit];
}
@end
Please read this post:, I think this is a bug on iOS17. I have no choice, but downgrade to Xcode14.3.1 and iOS16, stay away from current version of iOS17. Now the crash disappears.
Same problem in this thread.
[https://developer.apple.com/forums/thread/743525)
I also encountered the same problem after I upgraded to Xcode 15.0, where I started experiencing crashes related to CoreAnimation. The crashes occur randomly, which is very annoying. I tried disabling implicit animations on many layers, which significantly reduced the frequency of the crashes. However, this is not a long-term solution.
I am using Xcode13.1 with iOS15.0, code is tested on photos shot with iPhoneXS, using objc and swift, both have this memory leak issue.
It seems that if I compile DeeplabV3FP16 model as objc class, the memory leak disappears, while as swift class, the memory leaks.
My comparison codes as below
Objc version
@implementation ViewController
(void)dealloc
{
		[DeepLabV3Generator destroy];
}
(void)viewDidLoad {
		[super viewDidLoad];
		// Do any additional setup after loading the view.
		
		
		NSString *name = [NSString stringWithFormat:@"DeeplabV3-%tu", nameIndex];
		nameIndex ++;
		CIImage *image = [[CIImage alloc]initWithImage:[UIImage imageNamed:name]];
		CVPixelBufferRef pb;
		CVPixelBufferCreate(kCFAllocatorDefault, image.extent.size.width, image.extent.size.height, kCVPixelFormatType_32BGRA, NULL, &pb);
		[CIContext.context render:image toCVPixelBuffer:pb];
		
		[DeepLabV3Generator.si loadDeeplabV3From:pb];
		
		CVPixelBufferRelease(pb);
}
#import "DeepLabV3Generator.h"
@implementation DeepLabV3Generator
static DeepLabV3Generator* sharedInstance = nil;
(DeepLabV3Generator*)si{
		if(sharedInstance != nil){
				return sharedInstance;
		}
		static dispatch_once_t onceToken;
		dispatch_once(&onceToken, ^{
				sharedInstance = [[DeepLabV3Generator alloc]init];
		});
		
		return sharedInstance;
}
(void)destroy{
		sharedInstance = nil;
}
(instancetype)init
{
		self = [super init];
		if (self) {
				NSError *error = nil;
				MLModelConfiguration *config = [MLModelConfiguration new];
				self.v3 = [[DeepLabV3FP16 alloc]initWithConfiguration:config error:&error];
		}
		return self;
}
(MLMultiArray *)loadDeeplabV3From:(CVPixelBufferRef)pixeBuffer{
		NSError *error = nil;
		DeepLabV3FP16Output *output = [_v3 predictionFromImage:pixeBuffer error:&error];
		if (error) {
				NSLog(@"error %@",error.localizedDescription);
		}
		return output.semanticPredictions;
}
Swift verisoin
@objc class DeepLabV3Generator: NSObject {
		private static var sharedInstance : DeepLabV3Generator?
		@objc class func si() -> DeepLabV3Generator { // change class to final to prevent override
				guard let uwShared = sharedInstance else {
						sharedInstance = DeepLabV3Generator()
						return sharedInstance!
				}
				return uwShared
		}
		@objc class func destroy() {
				sharedInstance = nil
		}
		let v3 : DeepLabV3FP16
		
		private override init() {
				let config = MLModelConfiguration()
				config.computeUnits = .all
				v3 = try! DeepLabV3FP16(configuration: config)
		}
		@objc func loadDeeplabV3(from pixelBuffer:CVPixelBuffer) -> MLMultiArray? {
				let output = try! v3 .prediction(image: pixelBuffer)
				return output.semanticPredictions
		}
}
The image is 60px square jpg, very common file type. This problem only occurs on my iPhone7 Plus, not on my iPhoneXS. I think it only happens on old devices.
Updated:
under iOS13, I found only on iPhone7 Plus (not on XS), it calls -[CUIStructuredThemeStore _canGetRenditionWithKey:isFPO:lookForSubstitutions:] which is a hight cost API.
Any information about that?
Under iOS12, the call stack is as below
	+[UIImage imageNamed:inBundle:withConfiguration:]
	-[_UIAssetManager imageNamed:configuration:]
	-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]
	-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke
	-[_UIAssetManager _lookUpObjectForTraitCollection:withAccessorWithAppearanceName:]
	-[UITraitCollection _enumerateThemeAppearanceNamesForLookup:]
	-[_UIAssetManager _lookUpObjectForTraitCollection:withAccessorWithAppearanceName:]_block_invoke
	-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke_2
	-[CUICatalog namedVectorGlyphWithName:scaleFactor:deviceIdiom:layoutDirection:glyphSize:glyphWeight:glyphPointSize:appearanceName:]
	-[CUICatalog _resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:deviceSubtypeFallBackOrder:adjustRenditionKeyWithBlock:]
	-[CUICatalog _private_resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:deviceSubtypeFallBackOrder:localizationIdentifier:adjustRenditionKeyWithBlock:]
	-[CUIStructuredThemeStore copyLookupKeySignatureForKey:]
it's much faster than iOS13
Finally I found what is actually leaking, it's the MTLTexture. I profiled the app via Game Performance, checked what actually was happening when the leaking code was executing. I found that in the GPU section, a 48M MTLTexture was created, obviously it's the leak object.
But how can I release the MTL texture created internally by the CoreML model. I have found a method called "CVMetalTextureCacheFlush", seems it may work from the naming, but how to retrieve the texture cache then? (there is no related method for the model to get a texture or texture cache)
Sorry, what I mean is that the MLModel object is released, but the MTLIOAccelResource it has created during initialization leaks. I have also tried Xcode Memory Debugger, run the potential leaking code for several times. The result in the memory graph shows that the count of VM:IOAccelerator is not increasing, but the number of MTLIOAccelResource object is increasing. MTLIOAccelResource object is held by objects of class like AGXA10FamilyHeap, AGXA10FamilyBuffer, MTLIOMemoryInfo, MTLIOAccelPooledResource. I am not familiar with Metal, maybe I have to call some Metal related method to release the pooled resources, or is it a CoreML issue?