Slow launch time - how to navigate Time Profiler - ios

I am developing my first iOS app and I am almost ready to submit to app store. However, I am having problems with launch time. It is taking ~3 seconds to launch. The app has a ContainerView with three UIViewControllers as Child View Controllers. The middle UIViewController is a camera and the left and right UIViewControllers are mostly made up of UITableViews that make basic network queries (not on main thread) to populate them. Basically, I am trying to figure out why my app takes 3 seconds whereas apps like SnapChat and Instagram take <1 second.
I tried seeing what was taking so long using Time Profiler in Instruments. There were a couple easy fixes but now I am stuck. It says 357ms are from main but when I double click on it, it just takes me to AppDelegate and shows me that AppDelegate is accounting for 100% (of the 357ms? - correct me if this is wrong). But this isn't helpful because I know that main() is to launch the app (?) but it isn't telling me anymore. Whereas when I click on other methods listed it breaks it down for me (i.e. what each part of the code is accounting for). This is my first time using Time Profiler and any help would be greatly appreciated.

Related

Launch screen for iOS

I have read a few posts on this topic about making the launch screen last longer, but I want to make it shorter.
Currently my launch screen takes 4 seconds before loading the login screen, and the app is not even close to being finished yet. Does that mean the launch screen could take longer to load once the app is finished?
Is there any way to make the launch screen appear for 2 seconds?
Xcode, Swift. backend in PHP.
The launch screen loading time depends on how "long" it takes your initial view controller to be prepared.
So, if you want it to "load faster" make your initial view controller more lightweight, do this by:
Reducing the number of interface elements being shown
Do not perform that many operations inside the "view did load" method.
Other than this, theres really not much you can do to control the time.
There isn't really a straightforward way of making the launch screen last shorter, because it depends on how long it takes for the necessities of your app to load.
Remember, the shorter the launch screen, the better, so the users of your app won't think that your app is taking a lot of time to boot up.

why is iOS launch screen very slow?

My iOS app launch screen takes about 3 - 5 seconds. I have a map that will load after the launch screen. My users have to wait for the launch screen to load and then wait another 3 seconds for the map to load.
Is there a way to minimize launch screen time?
Basically this delay means that you are doing something very wrong during launch. Your job is to launch immediately. Indeed, the WatchDog app will kill you dead if you don't.
There are excellent WWDC videos on this topic, and you should watch them. But in general there are two ways to go wrong:
You must do nothing time-consuming on the main thread. If you have a time-consuming thing to do, like loading your map or networking, you must do that on a background thread. You need to get out of the way so that the runtime can launch your app now.
Just the other way around, you must not touch the interface on any other thread but the main thread. Doing this wrong causes just the kind of delay you are reporting. Do your work on a background thread, but then get back on the main thread to talk to your views, view controllers, etc.
Finally, I should point out that you might be able to get some idea what you're doing wrong by using Instruments. Unfortunately it works rather badly against app launch, but it can be worth a try. Above all, watch those videos!

How to successfully Deep Link to a closed app whose target view will take time to load

I have an app in which I handle Deep Links to various navigation targets in the app.
This works fine when the app is running in the background - but if the app has been closed, the views involved in the navigation the Deep Link needs to do may take a couple of seconds to load, especially on older hardware.
Looking for a best practice on how to handle this - I don't want to stall the user by waiting, but I also don't want to give them time to navigate away.
Solution used was - if the view is not loaded to do brief delay with dispatch_after before checking again and navigating further.

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

iOS Launch Screen Animation Time

It seems like the fade animation between the launch screen and my first view is really slow.
I don't think it used to be like that. Is there a way to control the speed of that transitional animation?
I looked at some apps on my phone and the launch screen doesn't fade as slowly as mine. What things could I have done to affect that?
(No I don't have slow animations turned on, only the fade animation is slow)
In WWDC 2012 video iOS App Performance: Responsiveness they enumerate a whole list of issues that have impact on the app startup time, ranging from attaching to unnecessary frameworks, optional linking to frameworks that you really could make required, the use of static initializers, overly complicated initial scenes, too much information stored in preferences, etc.
That video covers a range of topics, like the above, which impact startup time. In the demonstration, they show how one might benchmark the startup time. Unfortunately, in my experience, there's a good chance that you might not be able to do anything to fix this issue (e.g. you need certain features and therefore need certain frameworks), but it's still an illuminating video and it might give you some ideas of things you can try to alleviate the start-up performance issues.
If your app splash screen show more time, so please check following things in your app.
1. AppDelegate.m
in didFinishLaunchingWithOptions method have you called any heavy method which takes more time for finish task if yes then change that method location, basically in appDelegate class don't write any heavy methods.
2. first view of your app.
check viewDidLoad() method, if you call many method or any heavy method from here then your launch image will show still your control not come out from viewDidLoad method, so if you want call any methods at view launch time then call them from viewWillAppear or viewDidAppear method (in viewDidAppear method don't call any UI related methods)
I never figured out what was going on here, but the next day when I started up xCode and the simulator it was back to the normal loading time.

Resources