macOS SDK: NSAttributedString containing only an image attachment measures as having zero size

Originator:igeek1
Number:rdar://28639290 Date Originated:05-Oct-2016 05:12 PM
Status:Open Resolved:
Product:macOS SDK Product Version:Xcode 8.1 beta (8T46g)
Classification:Serious Bug Reproducible:Always
 
Summary:
NSAttributedString.boundingRect(with:options:context:) returns {x 0 y 0 w 0 h 0} when called on an attributed string containing only the attachment character (0xFFFC) and an associated image. This happens on macOS, but not on iOS.

Steps to Reproduce:
1. Open one of the attached playgrounds. There is one for Xcode 7.3.1 and one for Xcode 8 or 8.1 beta, and the bug reproduces the same on either one.
2. Set the playground to run on iOS. Observe that the last line produces a resulting rect of {x 0 y 0 w 108 h 108}. This is correct and expected.
3. Set the playground to run on macOS.

Expected Results:
The last line produces {x 0 y 0 w 108 h 108}

Actual Results:
The last line produces {x 0 y 0 w 0 h 0} (the degenerate rectangle).

Regression:
not a regression as far as I can tell.

Notes:
Does not reproduce on iOS. Reproduces on the 10.11 and 10.12 machines where I’ve tried it, in Xcode 7.3.1, 8.0, and 8.1 beta 2.

Attached playgrounds also uploaded at https://cl.ly/hftI

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!