user4806509
user4806509

Reputation: 3011

How to debug intermittent slow iOS iPhone app load times in Xcode?

I have an iOS Xcode project that previously would load fast, but from time to time, now will hang for five seconds or more during loading. When the app is run on an iPhone, the launch screen displays instantly, but sometimes, not always, and unpredictably, the app just hangs for around 5 seconds or more until the actual interface is displayed. It occurs both on the simulator and device across different iOS versions 7, 8, 9.

Recently, a UIView's class that contains a drawRect function was changed slightly, it has an outlet connection to one of the ViewControllers, but no significant changes made overall. One ViewController has code in the ViewDidLoad, ViewWillAppear, ViewDidAppear functions. All these things I'm investigating if they are impacting the load time.

When I terminate the app, the next time I try running it, it loads super fast without issue. I have no idea what to make of this load behaviour.

Questions

1 - What methods can I use in Xcode to debug an app that loads slowly at irregular and unpredictable times?

2 - What obvious items should I be on the look out in the project that typically cause slow or prolonged load times?

3 - Does Xcode include tools to monitor the processes operating live while loading occurs?

4 - Is it possible to print output for load processes I can review?

Any experienced advice really appreciated. Thanks.

Upvotes: 1

Views: 2450

Answers (1)

carlos
carlos

Reputation: 2624

Not sure if you have looked instrumentation. It is the best way to determine this kind of issues with your app.

https://developer.apple.com/library/watchos/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/index.html

When I terminate the app, the next time I try running it, it loads super fast without issue. I have no idea what to make of this load behavior.

Do you mean exiting the app? Or actually killing it? Cause if it is the former, then the reason is the app was just launched from a suspended state.

I would suggest take a closer look at didFinishLaunchingWithOptions:, and check if you are doing something that takes more time than needed. Run your app with the time profiler instrument, it will tell you where is your bottleneck.

Upvotes: 2

Related Questions