Instruments

RSS for tag

Instruments is a performance-analysis and testing tool for iOS, iPadOS, watchOS, tvOS, and macOS apps.

Posts under Instruments tag

88 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Memory leak issue. Is this a bug or am I doing something wrong?
I've been developing an app for macOS for some time. As I've been approaching the app's final development stages, I decided to try Instruments as I've suspected a memory leak was occurring, since my app's memory usage slowly grows over time. Instruments has found one leak, and I've spent considerable time trying to find the cause. Long story short, I've ended up with just an EmptyView() and Instruments were still showing a leak. I've tried creating a new project with a placeholder "Hello, world!" text, and Instruments were still detecting a leak. Am I doing something wrong here? Maybe I'm not using Instruments correctly? Or is this a bug? My Instruments version is 16.0, macOS Sequoia 15.1.
1
0
59
3d
Discrepancy between Xcode Memory Report and Xcode Instruments Memory Profiler
Hi Apple Engineers, I am encountering an issue where the memory usage reported by the Xcode memory report and the Xcode Instruments memory profiler are not aligned. Specifically: Xcode Memory Report: After implementing autoreleasepool, URLSession reading a zip file, and moving the task inside DispatchQueue.global().async, the memory usage goes down from 900MB to 450MB, indicating a potential memory leak. Xcode Instruments Memory Profiler: The memory usage goes down from 900MB to 100MB, suggesting that the memory has been properly released and there is no significant memory leak. Could you please help me understand the discrepancy between these two tools and provide guidance on the appropriate way to interpret the memory usage in my application? Which result I should rely on it? I would greatly appreciate your insights and expertise on this matter. Thank you in advance for your assistance.
2
0
112
3d
CPU use increases over time with simple animation
I created a simple animation of a circle that changes sizes. The circle pulses like a heartbeat in the center of the screen. My expectation was for the CPU use to be very low, but that is not the case. In addition, even if the CPU use isn't as low as I would expect, I did not expect the CPU use to increase over time because nothing else is happening in the app. Here is the code: import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { SplashScreenView() } } } import SwiftUI struct SplashScreenView: View { var body: some View { ZStack { SplashNucleusView(minSize: 50, maxSize: 100) } } } import SwiftUI struct SplashNucleusView: View { let minSize: Double let maxSize: Double @State private var nucleusColor: Color = .primary @State private var nucleusRadius: Double = 10 @State private var nucleusOpacity: Double = 1.0 private var nucleusAnimation: Animation { .easeInOut(duration: 0.25) .repeatForever(autoreverses: true) } let timer = Timer.publish(every: 0.5, on: .main, in: .common).autoconnect() var body: some View { Circle() .fill(nucleusColor) .frame(width: nucleusRadius) .opacity(nucleusOpacity) .onReceive(timer) { _ in withAnimation(nucleusAnimation) { nucleusRadius = Double.random(in: minSize...maxSize) } } } } This is how the animation looks: The animation is snappy until the CPU use reaches 95%, at which point there is visible stuttering. Here is how the CPU looks when the animation duration value is 0.5 seconds and the timer publishing interval is 3 seconds: Changing the animation duration value to 0.25 seconds and the timer publishing interval to 0.5 seconds changes the CPU use as follows: The complete view has many other moving parts, which make the issue much worse. The issue is evident with only the circle view. I spent hours working with the debugger, reading about animations, and testing new approaches, but the result is always the same. Why is this happening?
2
0
191
3w
Unable to run test in devices with MDM Profiles
Requirement : We wanted to run UI Automation using xcuitest in devices with MDM profiles. Steps : We have created a test target for our app and signed with MDM profile (in-house) Generated app and testbundle-Runner along with xctestrun files using “xcodebuild build-for-testing -scheme “App-TestRelease" -configuration “Release” -derivedDataPath "${CURDIR}/derivedData" -workspace "${PROJECT_NAME}.xcworkspace" -sdk iphoneos” Tried running “xcodebuild test-without-building -destination platform=iOS,id=000842883-**** -xctestrun App-TestRelease_iphoneos17.5-arm64.xctestrun -derivedDataPath /derived/“ Facing below issues xcodebuild[35481:3588352] IDELaunchReport: e2934a094f300d40:e2934a094f300d40: Finished with error: Unable to launch com.org.mdm.XCTest.xctrunner Domain: com.apple.platform.iphoneos Code: -12 User Info: { IDERunOperationFailingWorker = IDELaunchiPhoneLauncher; } -- Request to launch com.org.mdm.XCTest.xctrunner failed. Domain: com.apple.dt.deviceprocesscontrolservice Code: 2 Failure Reason: The request to open "com.org.mdm.XCTest.xctrunner" failed. : Failed to launch process with bundle identifier 'com.org.mdm.XCTest.xctrunner'. -- The request to open "com.org.mdm.XCTest.xctrunner" failed. Domain: FBSOpenApplicationServiceErrorDomain Code: 1 Failure Reason: The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user"). User Info: { BSErrorCodeDescription = RequestDenied; FBSOpenApplicationRequestID = 0x9f9; } -- The operation couldn’t be completed. Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. Domain: FBSOpenApplicationErrorDomain Code: 3 Failure Reason: Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. User Info: { BSErrorCodeDescription = Security; }
1
0
204
3w
Production Issue - MetricKit is not generating daily metric payloads as expected since iOS 18
I'm a big fan of MetricKit. I decided to see how my apps are performing with iOS 18 and well, I'm not getting any metric payloads from those devices. Metric payloads received from my test devices adopting iOS 18 has pretty much bottomed out to zero. Is anyone getting MetricKit MXMetricPayloads from iOS 18 devices? FB15461298 - MetricKit: Production issue / regression with iOS 18 - Significant dropout or metric payloads being generated since 18.0 - nearly no reports To demonstrate the issue, I decided to graph the metric payloads my infrastructure receives for all of my apps across all of my devices over the last 16 months starting with WWDC23 timeframe. This data is grouped by count per month. A trend can easily be seen starting in June 2024 where I started to adopt iOS 18 betas. Zooming in since WWDC24, grouped by week, it is much easier to see the decline. Note, the second screenshot shows data collected from Xcode builds, TestFlight, and App Store. The last data point from today was a manual creation from Xcode's Debug window, so at least that triggering mechanism works and I can confirm all of my code to upload off device works as expected. On the bright side, I guess I will ship this 'payload received over time' feature in my MetricKit payload analyzer app with a scrolling window and group by features that make up these screenshots.
1
0
252
Oct ’24
RealityKit Metrics - 3D Render vertex and triangle measurement attributes clarification needed
What exactly is included/calculated in the following metrics within RealityKit Trace - RealityKit Metrics - 3D render attributes: 3D Mesh Triangles Total Triangles Submitted 3D Mesh Vertices Total Vertices Submitted As the second part of the question, what differentiates between: 3D Mesh Triangles vs Total Triangles Submitted 3D Mesh Vertices vs Total Vertices Submitted
0
0
178
Oct ’24
Xcode Instruments: Mismatch Time Profiler results vs. CPU Cycles
Recently, we reworked a crucial part of our app and managed to half the amount of CPU cycles our app requires (according to Xcode Instruments). Nonetheless, when using the Time Profiler component in instruments, it shows that the CPU time spent was either higher or the same (depending on execution). The main time-consuming factor here: libsystem_pthread.dylib - the amount of CPU time spent by this library has doubled from original implementation to reworked implementation. Therefore, I'm having a few questions: How should I interpret this result? How is this even possible if the CPU clock cycles halved? What is the better metric here, the CPU cycles or the time profiler? How can I reduce the impact of that said library? What does that library do and how can I influence its performance? Thanks in advance.
2
0
263
Oct ’24
[Xcode Instruments][Allocations] Chart not showing any data
Hi there, In a project that I am working on, whenever I try running instruments for allocations to see the memory allocations that are happening under the hood, I see the statistics, and the traces updating, however the chart never updates. I have made new projects on the machine, and I have tried different Xcode versions, and they all show the chart just fine. I have tried running the project on other machines with no success. I have double checked the arguments and options on the active schema I am trying to profile with the schema of a new project and they are identical. Here is a picture of how it looks: My questions are as follows: What properties and settings can disable the chart from showing up? What diagnostic steps recommended that I should take? I can not share a reproducible as this is the only project I have with this problem and it is not mine, but please tell me if there is anything else I can provide in order to debug this. All the best Parsa
1
0
227
Sep ’24
Issue with Pivot Points of Primitive Shapes in Reality Composer Pro for visionOS App
Hi everyone, I'm developing a visionOS app using SwiftUI and RealityKit, and I'm encountering an issue with the pivot points of primitive shapes created in Reality Composer Pro. Scenario: When I use Reality Composer Pro within Xcode to add primitive shapes (such as cubes, capsules, etc.) to my scene, the pivot points for these objects seem to be set incorrectly. The pivot is located far from the actual object, which affects transformations and positioning. Question: Is there a way to correct or adjust the pivot point for primitive shapes created in Reality Composer Pro? Additional Information: I’ve attached a screenshot illustrating the issue with the pivot point being misaligned. Any guidance on how to resolve this would be greatly appreciated. Thanks in advance for your help! Best, Siddharth
1
0
323
Sep ’24
Instruments "Failed to split user provided arguments: working directory doesn't exist"
Trying to examine performance issues in Xcode Instruments using the Animation Hitches instrument in Xcode 16.0 beta 6 (16A5230g). When connected to my iPhone 15 Pro Max and I try to start a run with my app, it has an error “Failed to split user provided arguments: working directory doesn't exist” with timestamp “(Before Run Started)”. When running the app on an iOS simulator, the instrument runs fine—but I want to profile on a real device.
 Instruments > Settings, Recording Location set to Default and that directory does exist.
3
1
439
Sep ’24
Security Framework: unreleased memory
I'm writing software that uses the security framework to get signing information from applications. I noticed that over time memory consumption goes up. After checking with Instruments, I saw an accumulation of objects coming from the internals of the security framework. These allocated objects don't seem to go away. Following is a standalone code sample that seems to cause the problem in my env. Running it by itself creates a big number of objects that are not released. I also attached a screenshot from Instruments. #include <Foundation/Foundation.h> #include <Security/Security.h> #include <unistd.h> OSStatus get_signing_info(const char* path) { SecStaticCodeRef codeRef = NULL; OSStatus status; NSString* str = [NSString stringWithUTF8String:path]; NSURL* url = [NSURL fileURLWithPath:str]; status = SecStaticCodeCreateWithPath((__bridge CFURLRef)url, kSecCSDefaultFlags, &codeRef); CFDictionaryRef _info = NULL; status = SecCodeCopySigningInformation(codeRef, kSecCSSigningInformation, &_info); NSDictionary* info = (__bridge_transfer NSDictionary *)_info; int flags = [[info objectForKey:(NSString *)kSecCodeInfoFlags] intValue]; NSLog(@"%d", flags); CFRelease(codeRef); return status; } int main(int argc, const char * argv[]) { @autoreleasepool { for (int i = 0; i < 1000; ++i) { @autoreleasepool { OSStatus status = get_signing_info(argv[1]); NSLog(@"i=%d, status=%d", i, status); } } sleep(100); } return 0; } Is there a way to get rid of these objects that clog up the memory? Or perhaps use the framework differently to avoid this issue?
1
0
380
Aug ’24
App Thinning Size Report for App as App Store build
Hello! Is it possible to make App Thinning Size Report for app store distribution with command "xcodebuild -exportArchive -archivePath iOSApp.xcarchive -exportPath Release/MyApp -exportOptionsPlist ExportOptions.plist" ? https://developer.apple.com/documentation/xcode/reducing-your-app-s-size#Automate-the-generation-of-the-app-size-report I tried to do this by specifying "method": "app-store" in ExportOptions.plist, but it doesn't work. I get an empty app-thinning.plist as output. But when I specify "method": "enterprise", it works correctly. Is it true that App Thinning Size Reports are only generated when the archive is exported for Ad Hoc or Enterprise distribution (not for App Store) ?
1
0
526
Aug ’24
sysdiagnose: format of lsaw.csstoredump
Hi, Trying to convert the lsaw.csstoredump file in a sysdiagnose directory in to a human readable format. The readme file in sysdiagnose indicates ".csstoredump files: sysdiagnose generates the output of lregister/lsaw in a binary form. To convert these .csstoredump files to text files, use the following command: lsaw dump --file "PATH TO DUMP FILE" > lsaw.txt These files can also be opened in CSStore Viewer." But no such command lsaw exists, at least not on macOS 14. No CSStore viewer either. Any ideas where I can find this utility or convert the file? I know it's in .gz format so have also tried just decompressing it but it is still in a binary format. Also tried running strings on it but not useful. Thanks!
2
0
539
Aug ’24