Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify scroll view frame drops using Instruments

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).

like image 986
Sea Coast of Tibet Avatar asked Sep 25 '22 04:09

Sea Coast of Tibet


1 Answers

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.

like image 164
Danny Bravo Avatar answered Dec 23 '22 00:12

Danny Bravo