Instruments

RSS for tag

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

Posts under Instruments tag

57 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Regarding the issue of Xcode not displaying Apple Watch devices
My version is iOS 18.6.2 (22G100), watchOS 10.6.1 (21U580), macOS 15.3.1 (24D70), Xcode Version 16.4 (16F6). My iPhone can connect to Xcode and complete app installation testing. I have connected the iPhone to Xcode via USB, and both the iPhone and Apple Watch have been set to trust this device. The iPhone has Developer Mode enabled, but I cannot find Developer Mode in the Privacy & Security settings on the Apple Watch. As shown in the image, the Devices section in Xcode's Developer Documentation displays my iPhone but not the Apple Watch. However, the Open Console for the displayed iPhone shows my Apple Watch—actually two of them, though I only have one Apple Watch (the other might be from a previous backup). The iPhone app installs and tests normally, but the Apple Watch app cannot select a target device and fails to start installation. How can I resolve this issue?
1
0
151
3d
RealityKit / visionOS – Memory not released after dismissing ImmersiveSpace with USDZ models
Hi everyone, I’m encountering a memory overflow issue in my visionOS app and I’d like to confirm if this is expected behavior or if I’m missing something in cleanup. App Context The app showcases apartments in real scale using AR. Apartments are heavy USDZ models (hundreds of thousands of triangles, high-resolution textures). Users can walk inside the apartments, and performance is good even close to hardware limits. Flow The app starts in a full immersive space (RealityView) for selecting the apartment. When an apartment is selected, a new ImmersiveSpace opens and the apartment scene loads. The scene includes multiple USDZ models, EnvironmentResources, and dynamic textures for skyboxes. When the user dismisses the experience, we attempt cleanup: Nulling out all entity references. Removing ModelComponents. Clearing cached textures and skyboxes. Forcing dictionaries/collections to empty. Despite this cleanup, memory usage remains very high. Problem After dismissing the ImmersiveSpace, memory does not return to baseline. Check the attached screenshot of the profiling made using Instruments: Initial state: ~30MB (main menu). After loading models sequentially: ~3.3GB. Skybox textures bring it near ~4GB. After dismissing the experience (at ~01:00 mark): memory only drops slightly (to ~2.66GB). When loading the second apartment, memory continues to increase until ~5GB, at which point the app crashes due to memory pressure. The issue is consistently visible under VM: IOSurface in Instruments. No leaks are detected. So it looks like RealityKit (or lower-level frameworks) keeps caching meshes and textures, and does not free them when RealityView is ended. But for my use case, these resources should be fully released once the ImmersiveSpace is dismissed, since new apartments will load entirely different models and textures. Cleanup Code Example Here’s a simplified version of the cleanup I’m doing: func clearAllRoomEntities() { for (entityName, entity) in entityFromMarker { entity.removeFromParent() if let modelEntity = entity as? ModelEntity { modelEntity.components.removeAll() modelEntity.children.forEach { $0.removeFromParent() } modelEntity.clearTexturesAndMaterials() } entityFromMarker[entityName] = nil removeSkyboxPortals(from: entityName) } entityFromMarker.removeAll() } extension ModelEntity { func clearTexturesAndMaterials() { guard var modelComponent = self.model else { return } for index in modelComponent.materials.indices { removeTextures(from: &modelComponent.materials[index]) } modelComponent.materials.removeAll() self.model = modelComponent self.model = nil } private func removeTextures(from material: inout any Material) { if var pbr = material as? PhysicallyBasedMaterial { pbr.baseColor.texture = nil pbr.emissiveColor.texture = nil pbr.metallic.texture = nil pbr.roughness.texture = nil pbr.normal.texture = nil pbr.ambientOcclusion.texture = nil pbr.clearcoat.texture = nil material = pbr } else if var simple = material as? SimpleMaterial { simple.color.texture = nil material = simple } } } Questions Is this expected RealityKit behavior (textures/meshes cached internally)? Is there a way to force RealityKit to release GPU resources tied to USDZ models when they’re no longer used? Should dismissing the ImmersiveSpace automatically free those IOSurfaces, or do I need to handle this differently? Any guidance, best practices, or confirmation would be hugely appreciated. Thanks in advance!
3
0
1k
1d
Where is the instruments command line tool?
I was reading through this documentation about instruments command line tool https://help.apple.com/instruments/mac/current/#/devb14ffaa5 and how it can be launched from the command line. However, unlike what the documentation states, there's no such instruments command anywhere on my macos M1 (OS version 15.6). That command gives: $> instruments zsh: command not found: instruments I do have XCode installed which has the Instruments.App (GUI app) but not the command line utility: $> ls Xcode.app/Contents/Applications/ ... Instruments.app Is that linked documentation up-to-date (it does say "latest" in the URL)? Is there some other way to install this command line utility?
3
0
102
5d
How do I capture localhost traffic in instruments?
I'm currently exploring Instruments for profiling and tracing on macOS 15.6.1. I know there is the "network connections" instrument which records TCP/UDP information, however it seems to not include the "lo0" (loopback) interface. Is there a way to configure it so that localhost traffic is included in the recording? as the application I'm tracing uses that and I want that information to be included in traces. The documentation for network-interface-detection schema makes no mention of how it detects interfaces. Thanks in advance.
5
0
112
1w
Instruments Failure in Xcode 16.4
Updated Xcode from 16.2 to 16.4, running Time Profile in Instruments, it launches the trace, but does not install or load on connected device, breaks the functionality. I am unable to debug... ERROR: Connection with the remote side was unexpectedly closed : <dictionary: 0x1f3c8b6d0> { count = 1, transaction: 0, voucher = 0x0, contents = "XPCErrorDescription" => <string: 0x1f3c8b850> { length = 22, contents = "Connection interrupted" } } Domain: IXRemoteErrorDomain Code: 6 User Info: { DVTErrorCreationDateKey = "2025-08-09 00:47:53 +0000"; } -- Connection with the remote side was unexpectedly closed : <dictionary: 0x1f3c8b6d0> { count = 1, transaction: 0, voucher = 0x0, contents = "XPCErrorDescription" => <string: 0x1f3c8b850> { length = 22, contents = "Connection interrupted" } } Domain: IXRemoteErrorDomain Code: 6 IOS 18.5
1
0
123
3w
Request for Device Temperature Monitoring and Thermal Attribution Analysis APIs
Background: During daily usage of iOS devices, devices experience noticeable thermal issues. This heating not only affects user experience, but may also lead to device performance throttling, shortened battery life, and other problems. We need better understanding and monitoring of device thermal states to optimize application performance and user experience. Issues Encountered: Insufficient thermal monitoring capabilities: Unable to obtain real-time accurate temperature data from devices Difficult power consumption analysis: Hard to determine which specific modules or threads cause high power consumption and heating Requested Solutions: Temperature Monitoring API: Provide accessible device temperature reading interfaces Thermal Attribution Analysis Capability: During heating events, we expect to receive more detailed power consumption monitoring data, such as CPU, GPU, network, location services, display, high power consumption thread stacks and other information to help developers identify high energy consumption operations
2
0
40
4w
Widget Memory Limit - Per Widget Kind/Size or Per Target?
I am building a widget that supports 2 different widget kinds, each supporting systemSmall, systemMedium, and systemLarge size families. My widget does download and display images so I expect memory usage to be on the higher end, but in debugging some memory issues, I notice that when I build my widget scheme to a physical device, things start off reasonable at ~12MB of memory usage. But as I change the widgets intent, add the other widget kind, or add different widget size families, this memory usage grows until it ultimately hits the 30MB cap. My question is, is the 30MB memory limit spread across all my supported widget kinds/sizes? Or does each individual widget get its own 30MB cap? i.e., if I have systemMedium Widget A and systemLarge Widget B, are they sharing that 30MB memory limit?
1
0
70
4w
Question about Metrics Analysis in Xcode 26
Hello, I have recently been using the new Power Profiler tool introduced in Xcode 26 to analyze the power consumption of my app. My app primarily operates in the background. During a profiling session of 5 hours and 30 minutes, I observed that the app was active in the background for 2 hours and 30 minutes, while it remained in a suspended state for the remaining 3 hours. While the Power Profiler allows me to identify spikes in CPU, networking, and other resource usage at specific points, it is difficult to determine whether these values are objectively considered high. For example, in my case, the total QoS Execution Time of CPU Impact recorded during the 5 hours and 30 minutes was 12.18 seconds. I am wondering whether this is considered a good metric. Could you please advise on the following points? 1. Is there a commonly accepted or recommended ratio between app active time and CPU time that developers should aim for? 2. Are there any guidelines or reference materials on how to interpret CPU usage and other resource metrics for apps that primarily run in the background? Any insights or advice would be greatly appreciated. Thank you.
1
0
107
Aug ’25
React native app crash on TestFlight
Good day everyone. I have a react native app which works on dev mode on my device - Iphone 13 pro version: 18.5, but when deployed to TestFlight and installed on same device it crashes when ever I click on any TextInput. I downloaded the crash file but finding it difficult to pinpoint the problem. I want to know what the problem is, if it's related to an installed package or code base or any other. Any help will be appreciated!!! Thanks. crashlog.crash
3
0
73
Jul ’25
Datadog Mobile Vitals equivalent in Instruments
Hello We use Datadog Mobile Vitals in our app and I'm trying to run some tools in Instruments for comparison. I'm not sure what tool should I use for some of those metrics: Slow Renders Description: With slow renders data, you can monitor which views are taking longer than 16ms or 60Hz to render. Instruments equivalent: Hangs including microhangs (?) CPU ticks per second Description: RUM tracks CPU ticks per second for each view and the CPU utilization over the course of a session. The recommended range is <40 for good and <80 for moderate. Instruments equivalent: CPU Profiler (?) Frozen Frames - Description: Frames that take longer than 700ms to render appear as stuck and unresponsive in your application. These are classified as frozen frames. Instruments equivalent: Hangs with > 500ms (?) Memory Utilization Description: The amount of physical memory used by your application in bytes for each view, over the course of a session. The recommended range is <200MB for good and <400MB for moderate. Instruments equivalent: Allocation (?)
0
0
121
Jul ’25
Request for PMU Counter Support on Context Switches in Instruments
Hi, My name is Hani Nemati, and I work at Microsoft, where we support several macOS applications such as Microsoft Edge and Teams. I’m also the primary contributor to Microsoft Performance Tools for Apple (https://github.com/microsoft/Microsoft-Performance-Tools-Apple), an open-source project aimed at improving trace analysis across platforms. We are exploring ways to enhance our performance tracing capabilities on macOS and are particularly interested in the ability to attach PMU (Performance Monitoring Unit) counters to context switch events during trace collection. For reference, this capability is supported on Linux via LTTng using the add-context option (https://lttng.org/man/1/lttng-add-context/v2.13), and on Windows through Windows Performance Recorder (WPR), which allows PMU counters to be added at the start and end of context switches, enabling delta computation. Would it be possible to introduce similar support in Instruments for macOS? I’d appreciate any guidance or suggestions you might have on this request. Thank you, Hani Nemati Email: hanemati@microsoft
2
0
169
Jul ’25
Using Processor Trace on Non-Xcode Built Binary
Hiya folks! I'm David and I work on rust-analyzer, which is a language server for Rust similar to sourcekit-lsp. I'm using the new Instruments profiling tooling functionality in Xcode 16.3 and Xcode 26 (Processor Trace and CPU Counters) to profile our trait solver/type checker. While I've been able to use the new CPU Counters instrument successfully (the CPU Bottleneck feature is incredible! Props to the team!), I've been unable to make use of the Processor Trace instrument. Instruments gives me the error message "Processor Trace cannot profile this process without proper permissions". The diagnostic suggests adding the com.apple.security-get-task-allow entitlement to the code I'm trying to profile, or ensure that the build setting CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES is enabled in Xcode. Unfortunately, I don't know how I can add that entitlement to a self-signed binary produced by Cargo and I'm not using Xcode for somewhat obvious reasons. Here's some information about my setup: Instruments Version 26.0 (17A5241e) I'm on an 14" MacBook Pro with M4 Pro. It's running macOS Version 26.0 Beta (25A5295e). I've enabled the "Processor Trace" feature in "Developer Tools" and even added the Instruments application to "Developer Tools". As a last-ditch effort before posting this, I disabled SIP on my Mac. Didn't help. To reproduce my issue: Get Rust via https://rustup.rs/. Clone rust-analyzer: git clone https://github.com/rust-lang/rust-analyzer.git. cd rust-analyzer Run cargo test --package hir-ty --lib --profile=dev-rel -- tests::incremental::add_struct_invalidates_trait_solve --exact --show-output. By default, this command will output a bunch of build progress with the output containing something like Running unittests src/lib.rs (target/dev-rel/deps/hir_ty-f1dbf1b1d36575fe). I take the absolute path of that hir_ty-$SOME-HASH string (in my case, it looks like /Users/dbarsky/Developer/rust-analyzer/target/dev-rel/deps/hir_ty-f1dbf1b1d36575fe) and add it to the "Launch" profile. To the arguments section, I add --exact tests::incremental::add_struct_invalidates_trait_solve. I then try to record/profile via Instruments, but then I get the error message I shared above. Below is output of codesign -dvvv: ❯ codesign -dvvv target/dev-rel/deps/hir_ty-f1dbf1b1d36575fe Executable=/Users/dbarsky/Developer/rust-analyzer/target/dev-rel/deps/hir_ty-f1dbf1b1d36575fe Identifier=hir_ty-f1dbf1b1d36575fe Format=Mach-O thin (arm64) CodeDirectory v=20400 size=140368 flags=0x20002(adhoc,linker-signed) hashes=4383+0 location=embedded Hash type=sha256 size=32 CandidateCDHash sha256=99e96c8622c7e20518617c66a7d4144dc0daef28 CandidateCDHashFull sha256=99e96c8622c7e20518617c66a7d4144dc0daef28f22fac013c28a784571ce1df Hash choices=sha256 CMSDigest=99e96c8622c7e20518617c66a7d4144dc0daef28f22fac013c28a784571ce1df CMSDigestType=2 CDHash=99e96c8622c7e20518617c66a7d4144dc0daef28 Signature=adhoc Info.plist=not bound TeamIdentifier=not set Sealed Resources=none Internal requirements=none Any tips would be welcome! Additionally—and perhaps somewhat naively—I think I'd expect the Processor Trace instrument to just work with an adhoc-signed binary, as lldb and friends largely do—I'm not sure that such a high barrier for CPU perf counters is warranted, especially on an adhoc-signed binary.
5
0
340
Jul ’25
What is causing the Freeze in this SwiftUI View?
I made a small project that freezes after the following steps: Run the app Turn on VoiceOver Tap on "Header" once so it is read out loud Turn off VoiceOver Scroll up and down really quickly Using the Time Profiler, the items in the Main Thread followed by significant drops are: 19.11 s 85.1% 0 s closure #2 in closure #1 in ViewRendererHost.render(interval:updateDisplayList:targetTimestamp:) 13.05 s 58.1% 4.00 ms ViewGraph.updateOutputs(async:) 7.97 s 35.5% 83.00 ms AG::Graph::UpdateStack::update() 5.76 s 25.6% 19.00 ms LayoutScrollableTransform.updateValue() 1.73 s  7.7% 2.00 ms specialized NativeDictionary.setValue(:forKey:isUnique:) 579.00 ms  2.6% 58.00 ms 0x100a8c908 311.00 ms  1.4% 165.00 ms __thread_stack_pcs I see the memory usage increase by about 0.6 MB per second while frozen. And there are a few things that prevent the freeze: Changing LazyVStack for VStack Removing the VStack from the Section Removing the header: parameter from the Section Reducing the range of the ForEach Move the Text(verbatim: "Text at same level as ForEach containing Section") outside of the LazyVStack However, these are all things I need to keep for my actual app. So what is causing this hang? Am I using SwiftUI in any way it's not intended to be used? import SwiftUI struct ContentView: View { var body: some View { VStack { VStack(alignment: .leading) { Image(systemName: "pencil.circle.fill") Text("Title") Text("Label") } ScrollView { LazyVStack { Section { VStack { ForEach(0..<70) { _ in Text(verbatim: "A") } } } header: { Text(verbatim: "Header") } Text(verbatim: "Text at same level as ForEach containing Section") } } } } } AppDelegate: @main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { let window = UIWindow(frame: UIScreen.main.bounds) window.rootViewController = UINavigationController(rootViewController: MainViewController()) window.makeKeyAndVisible() self.window = window return true } } MainViewController: import UIKit import SwiftUI final class MainViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let swiftUIView = ContentView() let hostingController = UIHostingController(rootView: swiftUIView) addChild(hostingController) hostingController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(hostingController.view) NSLayoutConstraint.activate([ hostingController.view.topAnchor.constraint(equalTo: view.topAnchor), hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) ]) hostingController.didMove(toParent: self) view.backgroundColor = .white } }
1
0
79
Jun ’25
Instruments Time Profiler Call Stacks & Percentages Differ Between Xcode 16.0 (16A242d) and 16.3 (16E140) – How Can I Get Consistent Metrics?
I’m seeing inconsistent call stacks and usage percentages in the Time Profiler between two Instruments builds: • Xcode 16.0’s Instruments Version 16.0 (16A242d) • Xcode 16.3’s Instruments Version 16.0 (16E140) When I open an old .trace file recorded with the 16A242d profiler in the newer 16E140 Instruments, the call trees and percentage breakdowns no longer match. It looks like the latest Instruments now exposes or collapses different frames (e.g. system libraries, inline code) by default. I rely on these call stacks as a baseline to track performance regressions and verify optimizations over time. Unfortunately, every Xcode/Instruments update changes what I see, making it impossible to compare profiles across versions. My questions: Is there a way in Instruments 16.0 (16E140) to restore the exact call-tree view and percentage calculations that 16A242d produced? Failing that, is there a recommended workflow or tool for capturing CPU profiles in a way that remains stable and comparable, regardless of Xcode or Instruments version? Any guidance on achieving consistent, version-independent performance measurements would be greatly appreciated!
2
0
90
Jun ’25
(iOS 26) - PowerProfiler trace file cannot be opened
I kept CoreLocation’s startUpdatingLocation running for a full day and used Performance trace - PowerProfiler to track the power usage during that time. The trace file was successfully generated on the iOS device, and I later transferred it to my MacBook. However, when I tried to open the .atrc file, I received the following warning: The document cannot be imported because of an error: File ‘/Users/jun/Downloads/PowerProfiler_25-06-16_181049_to_25-06-17_091037_001.atrc’ doesn’t contain any events. Why is this happening? Is there a known issue with PowerProfiler in iOS 26, or am I missing something in the tracing setup? Note: The .aar file and the extracted .atrc file are not attached here, as forum uploads do not support these formats.
1
0
86
Jun ’25
RealityKit Trace Metric Max/Range for VisionOS app
Hi Nathaniel, I spoke with you yesterday in the WWDC lab. Thanks for chatting with me! Is it possible to get a link to a doc that has some key metrics I'd find in a RealityKit trace so I know if that metric is exceeding limits and probably causing a problem? Right now, I just see numbers and have no idea if a metric is high or low :). This is specifically for a VisionOS app. Thanks, Bob
3
0
84
Jun ’25
Cannot get Instruments to profile my apps
Hi, I need help to get Instruments running to profile my application. I tried to profile my main app (Qt-5.15-Framework, c++, Intel-arch only) from Xcode. My app starts and Instruments runs time profiler or Leaks for about 15 seconds and the quits. No crash, no message nothing. This has been happening for a while on my Mac Studio M1 Max running macOS 14.7.6 and Xcode 15.4 IDE with a toolchain from Xcode 14.3 for the qmake (qt) project. However, this also happens if i set up a new vanilla Swift UI project from scratch wihtout any Qt stuff. In addition to the Mac Studio I also have Mac Book Pro M4 running macOS 15.5 and Xcode 16.4. On that machine I get the same results, no matter if I try Instruments on my qt project or a vanilla SwiftUI project. Also it does not make a difference if I change the toolchain with: sudo xcode-select -s /Applications/Xcode_143.app or sudo xcode-select -s /Applications/Xcode_164.app. Same results in either case. I also tried switching to Debug build in the editing the scheme for profiling, but got no better results. I also tried to lauch Instruments from Xcode using the Open Developer Tool menu entry, but got no better results. When I start Instruments first, run my program in Xcode and attach to it, I get the same results. Do you have any advice what to check for or to setup, maybe in signing or such? I am probably missing something basic. Thanks in advance
4
0
163
Jun ’25
Instruments Network: Background URLSession instance appears not to complete
As stated in the title. I am running the following code. Each time I perform an API call, I create a new instance of URLSession and use a background-configured session to allow background API calls. ` Code being executed: import Foundation // Model definitions struct RandomUserResponse: Codable { let results: [RandomUser] } struct RandomUser: Codable { let name: Name let email: String } struct Name: Codable { let first: String let last: String } // Fetcher class class RandomUserFetcher: NSObject, URLSessionDataDelegate { private var receivedData = Data() private var completion: ((RandomUser?) -&gt; Void)? private var session: URLSession! func fetchRandomUserInBackground(completion: @escaping (RandomUser?) -&gt; Void) { self.completion = completion let configuration = URLSessionConfiguration.background(withIdentifier: "com.example.randomuser.bg") session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil) let url = URL(string: "https://randomuser.me/api/" )! let task = session.dataTask(with: url) task.resume() } // Data received func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { receivedData.append(data) } // Completion func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { defer { self.session.finishTasksAndInvalidate() } guard error == nil else { print("Error: \(error!)") completion?(nil) return } do { let response = try JSONDecoder().decode(RandomUserResponse.self, from: receivedData) completion?(response.results.first) } catch { print("Decoding error: \(error)") completion?(nil) } } }` Called in viewDidLoad, etc.: let fetcher = RandomUserFetcher() fetcher.fetchRandomUserInBackground { user in if let user = user { print("Name: \(user.name.first) \(user.name.last), Email: \(user.email)") } else { print("Failed to fetch random user.") } } In Instruments' Network instrument, I focus on my app's process, use 'Command + 3', and switch to 'List: URLSessionTasks'. Even though didCompleteWithError is called and the API call fully completes, the Duration keeps increasing, and the Success column remains '-' (neither 'Yes' nor 'No'). For non-background URLSessions, the session shows up as 'unnamed session', but for background URLSessions, it appears as 'unnamed background session 1 (XXXXXX-XXXXXX-XXXXX)'. Does this mean the session is not actually being completed? I've checked Debug Memory Graph and confirmed there is no NSURLSession memory leak, but is it possible that the app is somehow still retaining session information internally? I also suspect that Instruments may not be able to fully track background URLSession tasks.
3
0
184
Jun ’25
XCode claims that tracking domains are not listed in the Privacy Manifest
Hi, Xcode Instruments shows multiple Points of Interest with the information that the framework is not listed in my Privacy Manifest. However, I have already included them in the Privacy Manifest under the privacy tracking domains. I have this problem with every tracking domain i listed in the Privacy Manifest's Privacy Tracking Domains. Did I make a mistake in my Privacy Manifest declaration?
0
0
77
May ’25