Deadlock in CGContextDrawPDFPage in iOS8

Originator:constantine
Number:rdar://18778790 Date Originated:27-Oct-2014
Status:Open Resolved:
Product:iOS Product Version:iOS 8
Classification: Reproducible:Always
 
Steps to Reproduce:
1. Add custom font to XCode project.
2. in application:didFinishLaunchingWithOptions: draw a pdf file into some context.
3. Deadlock.

Sample project:
https://www.dropbox.com/s/6xuhl2myi03clp6/PDFDeadlock.zip?dl=0

Summary:
When project has custom font, application is deadlocked  in CGContextDrawPDFPage with following stack:

#0	0x38d57540 in semaphore_wait_trap ()
#1	0x38de2434 in _os_semaphore_wait ()
#2	0x0018a6fa in dispatch_once_f ()
#3	0x2b1d1e4e in CGFontCreate ()
#4	0x2b1d1dbe in CGFontCreateFontsWithPath ()
#5	0x2b21047e in CGFontCreateFontsWithURL ()
#6	0x3227df4e in AddFontsFromURLOrPath ()
#7	0x32281a3a in __Initialize_block_invoke ()
#8	0x0018a630 in dispatch_once_f ()
#9	0x3227d7a2 in Initialize ()
#10	0x001899c6 in _dispatch_client_callout ()
#11	0x0018a630 in dispatch_once_f ()
#12	0x2b1d1e4e in CGFontCreate ()
#13	0x2b20ab4a in CGFontCreateWithDataProviderAndData ()
#14	0x2b23a87e in CGPDFFontCIDType2Load ()
#15	0x2b29cb76 in load_font ()
#16	0x2b29cb4c in load_font ()
#17	0x2b29cc3c in CGPDFFontGetMutator ()
#18	0x2b24f372 in draw_glyphs ()
#19	0x2b2330ee in cid_draw ()
#20	0x2b232f84 in CGPDFTextLayoutDrawGlyphs ()
#21	0x2b269074 in op_Tj ()
#22	0x2b24d4e0 in pdf_scanner_handle_xname ()
#23	0x2b24d084 in CGPDFScannerScan ()
#24	0x2b29ce8c in CGPDFDrawingContextDrawPage ()
#25	0x2b2193fa in pdf_page_draw_in_context ()
#26	0x2b20840c in CGContextDrawPDFPage ()
#27	0x00061e36 in -[AppDelegate deadlockWithURL:]
#28	0x00047d74 in -[AppDelegate application:didFinishLaunchingWithOptions:] 



Notes:
It only happens on iPhone 5 (Maybe 5S).
Calling [UIFont systemFontOfSize:12]; before drawing PDF fixes the problem.

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!