-[WKInterfacePicker setItems:] crash on watchOS beta 5

Originator:gwendal.roue
Number:rdar://42848463 Date Originated:2018/08/02
Status: Resolved:
Product:watchOS Product Version:5.0 beta 5
Classification:crash Reproducible:always
 
Area:
WatchKit

Summary:

-[WKInterfacePicker setItems:] crashes when the new items array has less elements than the previous items array, and the current selection is beyond the new count of items.


Steps to Reproduce:

1. select the last item in a WKInterfacePicker
2. update the picker items with an array that has less elements (1 less is enough to trigger the bug)

I can witness the bug when -[crashingPicker setItems:] is executed from the pickerDidSelect: IBAction callback of another active picker. I don't know if this condition is necessary or not to reproduce the bug.


Expected Results: As the documentation says:

https://developer.apple.com/documentation/watchkit/wkinterfacepicker/1627940-setitems?language=objc

> This method displays the new items in the picker right away. If the previously specified selection index exceeds the number of items in the new array, the picker selects the last item in the array.


Actual Results:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
*** First throw call stack:
(
	0   CoreFoundation                      0x015e6c0a __exceptionPreprocess + 378
	1   libobjc.A.dylib                     0x00b79412 objc_exception_throw + 49
	2   CoreFoundation                      0x01530c2b _CFThrowFormattedException + 98
	3   CoreFoundation                      0x0166a7e9 -[__NSArrayI objectAtIndex:] + 105
	4   SockPuppetGizmo                     0x17041e18 -[SPInterfacePicker pickerView:keylineCaptionForItemAtIndex:] + 51
	...
	26  WatchKit                            0x00350a18 -[WKInterfacePicker setItems:] + 1045
    ...

Version/Build:

Xcode Version 10.0 beta 5 (10L221o)
watchOS Simulator Apple Watch Series 3 - 42mm - 5.0


Configuration:

?

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!