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

2019-03-25 02:06发布

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条回答
干净又极端
2楼-- · 2019-03-25 02:33

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?

查看更多
Lonely孤独者°
3楼-- · 2019-03-25 02:41

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.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-25 02:43

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.

查看更多
登录 后发表回答