Xib taking long time (>1s) to load. UIFont cache seems to blame

888 views Asked by At

I have a UIVC loading from a Storyboard which, in turn, loads a Xib. This inner load is causing the VC to take more than a second to load. There is some fancy footwork going on in the inner xib (it loads another xib which has dynamic drawing) but this doesn't appear to be the bottleneck.

According to Instruments, UIFont -initWithCoder is the culprit. (If you drill down further TBaseFont::CopyLocalizedName() is the deepest entry that accounts for the majority of the 1s time)

I'm a bit stumped as the custom font I use occurs all throughout the app with no problems. Any ideas?

Screenshot from Instruments

3

There are 3 answers

1
Hari Honor On BEST ANSWER

Ok the problem was that the custom font was no longer embedded in the app. I had switched to another similar one which looked the same. Weird though as I'd have expected those offending labels to revert back the System font on the device but they did not. Is it possible they were being pulled from the Macbook?

0
hbk On

Had the similar problem - in my case another dev in team just use one more type of font so after merge system cant figure out font and change it for default one - it's take from 1200ms to 2300ms.

Solution - re-setup all fonts on ViewController that cause some freeze.

0
KPM On

Similar issue here — Hari and gbk hinted me on the right direction.

I found we were using Lucida Grande in one little hidden place (thank you grep), but Lucida Grande is NOT embedded in iOS. I just replaced Lucida Grande with Helvetica Neue, and I gained 3+ seconds at launch time. Impressive.