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

北战南征 提交于 2020-01-22 13:53:29

问题


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?


回答1:


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?




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/30735005/xib-taking-long-time-1s-to-load-uifont-cache-seems-to-blame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!