Instruments

RSS for tag

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

Instruments Documentation

Posts under Instruments tag

87 Posts
Sort by:
Post not yet marked as solved
3 Replies
2.4k Views
Hi all,I've been digging into Instruments lately to investigate some potential performance wins for my app. I'm really enjoying the level of detail in the System Trace template, and the os_signpost stuff is perfect to get a high-level view of where to focus attention - great job!I'm using the latest Xcode Version 11.4.1 (11E503a) on Catalina, and an iPod Touch 7th Gen on the latest iOS - 13.4 (17E255).I'm measuring the app in a steady state where the workload is pretty constant and low (should be no issue hitting 60FPS rendering) but Xcode's CPU meter is pretty jumpy and it drops a frame every couple of seconds, which then seems to coincide with a reduction of CPU usage shown in Xcode.My suspicion is the device thinks it can maintain the required framerate and use less energy by reducing the CPU frequency. This is not quite true for my app - the main thread is sleeping for a significant period but it is awaiting a result on the run loop before the frame rendering can be completed. I can see why the OS might think downclocking is possible here, but then kick up the frequency again when it sees a frame is dropped.I did however once seem to get the device into a state where it was running at (I assume) full speed - the CPU meter in Xcode stayed steady as a rock at 15% or so (with "other processes" at a similar number). I haven't been able to figure out exactly how I managed that - Instruments was running a windowed tracing session and I app switched away and back to the app, but that method doesn't seem to work every time.So the Instruments-related questions arising from this:1) Is there a way to record and visualize the CPU frequency scaling in Instruments? If the frequency of the CPU is changing and unknown, then the timings coming out of Instruments are not really telling the whole story.2) Is there an officially supported method to prevent CPU frequency scaling whilst Instruments is recording data?Thanks for any help!Simon
Posted
by
Post marked as solved
7 Replies
7.2k Views
I have a swift 5.4 package manager project with an executable target I want to profile in Instruments. I Cmd+I to profile which launches instruments. I pick allocations. then push the record button. im asked to authorise and doesn’t matter whether I use fingerprint or password I always get the error: (before run started) Failed to gain authorization any ideas? instruments 12.5 xcode 11.5 swift 5.4 2020 M1 MBP 13”
Posted
by
Post not yet marked as solved
5 Replies
6.0k Views
I'd like to confirm the battery usage of an app I am developing on iOS, specifically on Xcode 13 and iOS 15. (Note: This app previously showed no issues with battery usage on previous versions of iOS.) Previously, it seems that there were two ways to gather energy usage information: #1. On the device under Settings > Developer > Logging As per Apple's documentation described in the section titled "Log Energy Usage Directly on an iOS Device". However, on iOS15, I can't find any options for logging under Developer or anywhere under settings even when searching. #2. Profiling via Instruments using the "Energy Log" template As per the same documentation from Apple described in the section "Use the Energy Diagnostics Profiling Template". While it is still available in Xcode 12, this template is missing in Xcode 13. Naturally, it's also not possible to profile an iOS15 device with Xcode 12. Digging through the Xcode 13 release notes, I found the following: Instruments no longer includes the Energy template; use metrics reporting in the Xcode Organizer instead. (74161279) When I access the Organizer in Xcode (12 or 13), select an app and click "Energy" for all versions of the app, it shows the following: Apple's documentation for "Analyzing the Performance of Your Shipping App" says: "In some cases the pane shows “Insufficient usage data available,” because there may not be enough anonymized data reported by participating user devices. When this happens, try checking back in a few days." Well over a year into production and having sufficient install numbers, I have a feeling that waiting a few days might not do much. I would like to determine if this is a bug in my app or a bug in iOS15. How can energy usage data be gathered using Xcode 13 on iOS 15?
Posted
by
Post marked as solved
23 Replies
5.5k Views
When trying to profile any process with the Instruments CPU Profiler I get this message: (Before run started) No allocated PMI record. Not sure what to do here. I tried other instruments like time profile and that works fine so not sure what to do here... Didn't find any people having similar issues when googling so I'm hoping someone here can help me out. Im using a m1 max 14 inch macbook pro with macOS 12.3 and instruments 13.0 (13A1030d)
Posted
by
Post not yet marked as solved
3 Replies
2.4k Views
The Leaks instrument is suddenly giving me the error "Required kernel recording resources are in use by another document." I see this has come up with Xcode 12 on iOS, but now it's happening when profiling a Mac application on Monterey 12.3.1 and Xcode 13.3. I get the same behaviour on a debug or release build. The Allocations instrument on its own also gives the same error. The Time Profiler intrument launches without issue. Regardless of the (useless) error, it's possible this is a signing issue, since Intruments is also constantly asking for a password when launching the process. Does anyone have any insight into what is causing this?
Posted
by
dwn
Post not yet marked as solved
4 Replies
2.5k Views
Hi, I'm a new owner of Apple laptop since I always using PC. I'm an experienced perf user but now I'm happy having my MBP2021 laptop so I need to learn new tools. I found that xctrace is the new way to capture profiles on Apple devices so I've installed one and ran on my app. Unfortunately, I didn't manage to make it work. Here is my script: ❯ xctrace record --template 'CPU Counters' --launch -- ./target/release/deps/flower-b0a05df673ad26db tests::test_run Starting recording with the CPU Counters template. Launching process: flower-b0a05df673ad26db. Ctrl-C to stop the recording Target app exited, ending recording... Recording completed. Saving output file... Output file saved as: Launch_flower-b0a05df673ad26db_2022-05-09_21.02.47_4E6DC3F7.trace. ❯ xctrace import --template 'CPU Counters' --input Launch_flower-b0a05df673ad26db_2022-05-09_21.02.47_4E6DC3F7.trace Import failed with error: Cannot find matching importer for url: Launch_flower-b0a05df673ad26db_2022-05-09_21.02.47_4E6DC3F7.trace/ -- file:///Users/pzixel/Documents/Repos/flower/ I tried to find any information about to how to make it work but failed. I hope I can find some support here.
Posted
by
Post not yet marked as solved
4 Replies
2.2k Views
My watchOS app crashes when I accept/change the microphone or Bluetooth permission from its companion iOS app. It crashes with the following message in the console. Message from debugger: Terminated due to signal 9 Please let me know a way to identify and fix the exact problem. here are my device logs: Device logs and crash report
Posted
by
Post not yet marked as solved
2 Replies
1.7k Views
When trying to use the Allocations Instrument I get the following error when pressing record: Unable to issue sandbox extension for path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/liboainject.dylib Longer story: I can not get Xcode to launch a simulator with 15.5 so I downloaded the 15.2 runtime and created a simulator with that. Is there a step I missed downgrading to the older runtime? I'm trying to debug the 15.5 failure separately.
Posted
by
Post not yet marked as solved
3 Replies
1.4k Views
Hello, When exporting a time CPU profiling .trace with xctrace export --output foo.xml --input PATH/TO/TRACE/FILE.trace --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-sample"] , I am unable to reconstruct the full callstack/backtrace, despite the GUI doing so. Sample row: <row> <sample-time id="22" fmt="00:00.039.455">39...</sample-time> <thread ref="2"/> <process ref="4"/> <core ref="14"/> <thread-state ref="8"/> <weight ref="9"/> <backtrace id="23" fmt="test::test::foo ← (11 other frames)"> <process ref="4"/> <text-addresses id="24" fmt="frag 1732">4331406713 4331406716</text-addresses> <process ref="4"/> <text-addresses id="25" fmt="frag 1733">4331403 ...</text-addresses> </backtrace> </row> As you can see the backtrace is cropped "(11 other frames)", but according to the backtrace documentation: In extended views, the entire symbolicated backtrace is listed. So how to export that extended view? Alternatively, is it possible to symbolicate the backtrace using the text-addresses list? That question was asked a year ago without answer so far. Best regards
Posted
by
Post not yet marked as solved
3 Replies
5.1k Views
I've discovered that my app has a memory leak, where when I close a window, it disappears from the screen but it (along with all its views, view controllers, and associated objects) actually doesn't get released. Instruments doesn't register it as a leak. It does show a few unidentified malloc leaks, but nowhere near enough to account for a window full of stuff. Xcode's memory graph doesn't show any leaks either, and I've combed through it looking for retain cycles or unwanted captures in blocks. I've fixed a few, but it hasn't been enough to actually get the window released. What other tactics are there for finding this kind of leak? The project is here for anyone feeling adventurous: https://github.com/Uncommon/Xit
Posted
by
Post not yet marked as solved
3 Replies
2.1k Views
Hi, I use Xcode Instruments to Profile my app, but I don't know why Instruments can not find the right source code path, like the screensh ot shows, the path is wrong, what is ? it looks like a placeholder, is xcode forgetting to replace this placeholder with real file name? anyone know how to fix this? thank you in advance
Posted
by
Post marked as solved
3 Replies
1.4k Views
Since version 14, Instruments cannot find the binary to show disassembly of executable or library. It says: Error - Binary file for selected symbol is expected to be here: /Users/<user>/Library/Developer/Xcode/DerivedData/<project>/Build/Products/Release/<project>. The thing is that the path shown by Instruments is actually the right one, and of course the binary exists in this directory. Am I missing something somewhere ?
Posted
by
Post marked as solved
3 Replies
1.2k Views
As part of a hobby project, I'm working on a 2D game engine that will draw each pixel every frame, using a color from a palette. I am looking for a way to do that while maintaining a reasonable frame rate (60fps being the minimum). Without any game-logic in place, I am updating the values of my pixels with some value form the palette. I'm currently taking the mod of an index, to (hopefully) prevent the compiler from doing some loop-optimisation it could do with a fixed value. My very naive implementation of updating the bytes in the pixel array goes like this. On an iPhone 12 Pro, each run of updating all pixel values takes on average 43 ms, while on a simulator running on an M1 mac, it takes 15 ms. Both unacceptable, as that would leave not for any additional game logic (which would be much more operations than taking the mod of an Int). I was planning to look into Metal and set up a surface, but clearly the bottleneck here is the CPU, so if I can optimize this code, I could go for a higher-level framework. Any suggestions on a performant way to write this many bytes much, much faster (parallelisation is not an option)? struct BGRA { let blue: UInt8 let green: UInt8 let red: UInt8 let alpha: UInt8 } let BGRAPallet = [ BGRA(blue: 124, green: 124, red: 124, alpha: 0xff), BGRA(blue: 252, green: 0, red: 0, alpha: 0xff), // ... 62 more values in my code, omitting here for brevity ] private func test() { let pixelBufferPtr = UnsafeMutableBufferPointer<BGRA>.allocate(capacity: screenWidth * screenHeight) let runCount = 1000 let start = Date.now for _ in 0 ..< runCount { for index in 0 ..< pixelBufferPtr.count { pixelBufferPtr[index] = BGRAPallet[index % BGRAPallet.count] } } let elapsed = Date.now.timeIntervalSince(start) print("Average time per run: \((Int(elapsed) * 1000) / runCount) ms") }
Posted
by
Post not yet marked as solved
5 Replies
1k Views
When using Instruments to capture FIXED_CYCLES and FIXED_INSTRUCTIONS on both an M1 based MacBook and also on an iPhone, the value of these counts is much higher when enabling High Frequency Sampling. Why is the count of Instructions and Cycles higher with Higher Frequency Sampling? Is it due to stack sampling overheads? Which is more accurate to capture FIXED_CYCLES and FIXED_INSTRUCTIONS counts - with High Frequency Sampling or without?
Posted
by
Post marked as solved
10 Replies
1.8k Views
I have a performance issue with a Mac SwiftUI app. Using instruments I see hangs reported. When I zero in on a hang I see that the time profiler reports most of the hang -- in one example 658 out of 687 ms -- being in 'static AppName.$main() [inlined]'. I think that is saying my app is busy, but busy doing what? The "hangs" are related to SwiftUI table processing. User experience is something like this: select an item, see the view changes based upon selection show up a second or two later. The duration of the hang increases with the number of items in the table. I'm testing with 100 ~ 1200 table entries.
Posted
by
Post not yet marked as solved
1 Replies
813 Views
Dear Experts, Where do memory-mapped files appear in the Allocations instrument, if at all? In the screenshot below, the green "all anonymous VM" graph is almost completely explained by the purple "IO Accelerator" graph (GPU buffers, textures etc) - but there are periods at the start of each cycle (such as at the cursor position) where there is some other contribution. I have not been able to find this in the other more-specific graphs. Any ideas anyone? I have been trying to make this app better behaved memory-wise and have made a lot of progress, in particular by removing periods when two large memory allocations co-exist, and by breaking work up into chunks. It now bothers me that there is 150 MB of "anonymous VM" that I cannot explain!
Posted
by
Post not yet marked as solved
1 Replies
830 Views
We are facing the below mentioned error frequently while submitting the different apps in the App Store. When we are uploading the first build, we are receiving the below mentioned error and if we increment the build version, and on re submitting we are not facing the same issue again. Could you please guide us on what caused this issue? Xcode Version: 14.2 Error : ITMS-90338: Non-public API usage - The app contains one or more corrupted binaries. Rebuild the app and resubmit.. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed.
Posted
by
Post not yet marked as solved
1 Replies
693 Views
i have an apple m1 macbook pro. Recently I updated to the new Ventura 13.4 and afte the update my track pad refuses to be clicked, rebooted but the problem remains...
Posted
by
Post not yet marked as solved
1 Replies
884 Views
I'm using Instruments to profile a C program that prints to stdout via printf but the program output does not appear in the Detail Area of the stdout/stderr instrument I added. The program is launched by Instruments itself when I click the Record button and it appears to run correctly – I just can't see the stdout output. I'm using Version 14.3.1 (14E300c) of Instruments on a MacBook Pro 16" (2019) running macOS 13.4 (22F66).
Posted
by