NSLayoutManager performance degradation when editing large (>10kb) Arabic text

Number:rdar://37607929 Date Originated:February 16 2018, 9:38 PM
Status:Open Resolved:
Product:macOS + SDK Product Version:
Classification:Performance Reproducible:Yes

Editing a large amount of Arabic text (>10kb) in TextEdit (or any app that utilizes NSLayoutManager) will exhibit notable lag (between keystroke and change of text on screen) and higher CPU utilization.

Steps to Reproduce:
1. Open attached "slowtext.txt" file in TextEdit.
2. Type continuously somewhere in the middle of the text.

Expected Results:
1. No lag.
2. Normal CPU utilization.

Actual Results:
Notable lag between keystroke and change of text on screen, and really high CPU utilization as typing continues.

macOS 10.12.6 
TextEdit 1.12 (329)


slowtext.txt https://pastebin.com/2Kfu1bgN


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!