NSAttributedString HTML Parsing shouldn't run the main runloop

Originator:nicolas.bouilleaud
Number:rdar://15803156 Date Originated:2014-01-13
Status:Open Resolved:
Product:iOS SDK Product Version:7.0
Classification:Crash Reproducible:Always
 
# Summary
Using NSAttributedString creating with HTML data (using NSHTMLTextDocumentType) is a lengthy operation, but internally makes the main runloop run in a common mode, which leads to other methods, delegates and notifications being delivered while parsing. 

This in turn leads to serious, hard-to-debug crashes.

# Steps to Reproduce:
See minimal UITableViewController demo at https://gist.github.com/n-b/8397563

Basically, it's a UITableViewController that parses and sets attributed text to each of its cell in -cellForRowAtIndexPath.
 
# Expected Results:
HTML parsing should completely block the thread, or at least run in a specific mode.

For example, in -scrollViewDidScroll, one can expect that -visibleCells and -indexPathsForVisibleRows return coherent results. This is no longer the case, because -scrollViewDidScroll is called while parsing HTML, inside -cellForRowAtIndexPath.

# Actual Results:
During HTML parsing, the rest of the app continues to run as if nothing, but the cell is not returned yet.

# Version:
7.0, 7.1b3

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!