Apps crash when they embed too many custom fonts

Originator:j2b.bayle
Number:rdar://17001060 Date Originated:22-May-2014 10:50 AM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 7.1
Classification:Crash/Hang/Data Loss Reproducible:Always
 
We, developers, have in iOS 7 the possibility to embed custom fonts in our apps. Doing so only requires the `.ttf` files to be copied in the app bundle and their names to be added in the `-Info.plist` file, under the `UIAppFonts` key. The system should then automatically load them and they should be available for use through the `UIFont` API. To my knowledge, no limit in the number of custom fonts that an app can embed is documented.

However, it seems that when an app embeds too many of those it becomes highly unstable and crashes eventually (a crash report from the attached test app `FontOverflow` is attached to this issue).

From what I can see, not all custom fonts are loaded by the system, which then tries to use the fallback font `LastResort`. Unfortunately the latter is not yet included in iOS 7, producing a lot of error logs:

> 2014-05-22 10:34:41.703 FontOverflow[4457:60b] Critical failure: the LastResort font is unavailable.

Then, after a few seconds the app crashes.


Steps to Reproduce:

A simple test app `FontOverflow` is attached so you can easily reproduce the bug. It embeds around 100 custom fonts and displays a mere UILabel view; every .1 second a new random string, text font and text color are applied to the label.

1. Open the project in Xcode
2. Run on a device (iPhone)
3. The app crashes after a few seconds

A crash report is also attached to this issue.


Expected Results:
The app should display random fonts, strings and colours without crashing.


Actual Results:
The refresh frequency is lower than it should be – because some fonts are missing.

The app crashes after a few seconds.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!