Is there any way to identify the exact place in code (e.g. a long-running function, or waiting on a lock) that causes a frame drop, using Instruments and/or Xcode?
I'm trying to make the scrolling of my scroll view as smooth as possible, and the FPS sometimes drops to 59 or even 58, while remaining 60 roughly half of the time, so I'd like to know what exactly is causing this.
I did enable the Record Waiting Threads
flag in the CPU Usage
instrument of the Core Animation
template, and it does show needle-like spikes of 100% usage of each core from time to time (close to the seconds with dropped frames), but I can't seem to figure out a way to identify the exact place in the code causing the drop - all the functions being called are pretty low impact and in single-digit percentages (so this may very well be the main thread waiting for a lock).
Have you tried using the Time Profiler tools in Instruments to see what parts of your code are more active while scrolling?
There's a very good WWDC tutorial video on how to use time profiling to find and fix bottlenecks in your code: https://developer.apple.com/videos/play/wwdc2015/412/
I suggest you watch this video, it might help you find a solution to your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With