ModelIO Loses Material Property Data when Enumerated with Swift

Originator:iosdeveloperzone
Number:rdar://26486874 Date Originated:25-May-2016 09:56 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 9.x SDK OS X 10.11.x
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
When loading a .mtl file with certain properties (e.g. specularityExponent) a property is dropped when the properties are enumerated using Swift subscripting.

Steps to Reproduce:
1) Run the attached project
2) Notice in the debug log that when the properties are enumerate using Swift the property 'specularExponent' is nil, it is not nil when Objective C is used or when the property is queried by name.

Expected Results:
It should be possible to enumerate the properties successfully and accurately via both Swift and Objective C.

Actual Results:
Objective C finds the following properties:
2016-05-25 21:48:35.821 ModelIOSpecularExponent-iOS[21057:1590476] [15]: ambientOcclusionScale
2016-05-25 21:48:35.821 ModelIOSpecularExponent-iOS[21057:1590476] [16]: specularExponent
2016-05-25 21:48:35.821 ModelIOSpecularExponent-iOS[21057:1590476] [17]: opacity
Swift finds the following:
2016-05-25 21:48:35.823 ModelIOSpecularExponent-iOS[21057:1590476] [15]: Optional("ambientOcclusionScale")
2016-05-25 21:48:35.823 ModelIOSpecularExponent-iOS[21057:1590476] [16]: nil
2016-05-25 21:48:35.824 ModelIOSpecularExponent-iOS[21057:1590476] [17]: Optional("opacity")

Regression:
Occurs in all versions of ModelIO of OS X and iOS. Did not find a working version. But this is a Swift vs. Objective C regression.

Notes:
During debugging it was determined that the culpable routine is `-[MDLMaterial objectAtIndexedSubscript:]`.
MDLMaterial maintains two arrays _builtinProperties and _userProperties.
In the example case specularExponent is the first entry in the _userProperties array. 
The method logic incorrectly looks it up in the _builtinProperties.

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!