Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow UIViewController load time (slow ClientState warning)

Since I converted an old app to iOS 6 I've started getting the following message in my console.

WARNING: Slow defaults access for key ClientState took 0.023656 seconds, tolerance is 0.020000

Other than updating my code from iOS 5 to iOS 6, I also switched over to auto-layout. I've run Instruments/Time Profiler and the rootViewController in my appDelegate is the problem. Everytime I switch view controllers it sucks the vast major of the time, (regardless of whether I have to instantiate the view controller or re-using one which already exists).

window.rootViewController = myViewController;

I know what the method does superficially, but I'm not sure what happens under the covers... what would cause it to be slow now and what can I do to speed it up?

EDIT: I've tried taking my storyboard off auto-layout and the problem vanishes (of course my UI layout is in shambles). So the obvious conclusion is, it's something about auto-layout. I've probably just under 70 views all combined on the screen and the various constraints needed to lay them out. I have a hard time believing auto-layout is that much slower (from ~80ms with auto-layout turned off to ~1370ms with auto- layout turned on).

like image 885
DBD Avatar asked Jan 13 '13 03:01

DBD


1 Answers

Having 70 views on-screen sounds like a lot! My proposal is to make it simpler in some way:

  • Do you REALLY need all 70 views at the same time?

  • Check if all views need autolayout, remove it where-ever possible

  • Can some views be replaced by graphics? I've used views e.g. for shadows, might have been images

Can you split storyBoard into several smaller ones e.g. one for login, details, edit mode etc. Part of the slowness might come from system having to deal with (too) big storyBoards.

like image 199
JOM Avatar answered Oct 04 '22 18:10

JOM