Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nib files loading extremly slow

Tags:

ios

nib

Good day friends!

I have very strange performance results on loading Nib files. Here is a screen from TimeProfiler:

enter image description here

Overall it sometimes takes more than 1200 ms to load a simple viewController that has 2 nibs. Nibs are very simple. Here is an example. As you can see from screenshot above, it takes 311 ms to be loaded:

enter image description here

The code I use to load nibs:

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    setupXib()
}

func setupXib() {
    NSBundle.mainBundle().loadNibNamed("TimeSaver", owner: self, options: nil)
    bounds = view.bounds
    addSubview(view)
    setup()
}

func setup() {
    slider.maximumValue = 30.0
    slider.minimumValue = 1.0
    slider.value = 5.0
    timeLabel.text = "\(sliderValue.format(format)) min"
}

I don't know if it might cause a problem, but this app uses App Groups (for WatchExtension). As you see I call nibs from mainBundle as they all are in main target. May it be the reason?

Thank you!

like image 762
Aleksandr Shcherbakov Avatar asked Jul 19 '15 22:07

Aleksandr Shcherbakov


1 Answers

So the problem was not in nib files at all. It was about custom font that was not installed properly. It was in list in Storyboard, but it was not a member of correct target. So the app was looking through everywhere to find a damn font - and that was the performance issue.

like image 127
Aleksandr Shcherbakov Avatar answered Oct 06 '22 17:10

Aleksandr Shcherbakov