Crash because NSToolbarFlexibleSpaceItem doesn't have a view

Originator:SaagarJha28
Number:rdar://34167199 Date Originated:30-Aug-2017 11:25 AM
Status:Open Resolved:
Product:Safari Technology Preview Product Version:Release 38 (Safari 11.1, WebKit 13605.1.3.1)
Classification:Crash/Hang/Data Loss Reproducible:
 
Summary:
Safari Technology Preview crashes for me since Release 37 because you've changed -[BrowserWindowController _updateKeyboardLoopIfReady] to query the BrowserWindowController's _toolbarController's lastVisibleItem's view. This will crash if the item is a NSFlexibleSpaceItem, since its view will return nil; this causes -[NSArray addObject:atIndex:] to throw an exception when this nil view is added. See (second) attached screenshot for disassembly of Safari Technology Preview.app/Contents/Frameworks/Safari.framework/Safari and analysis of the issue (the first screenshot is the original Safari.framework from /System/Library/Frameworks, which doesn't have this issue).

Steps to Reproduce:
1. Quit Safari Technology Preview, if it's running.
2. Open ~/Library/Preferences/com.apple.SafariTechnologyPreview.plist.
3. In "NSToolbar Configuration BrowserToolbarIdentifier-v2/TB Item Identifiers" add "NSFlexibleSpaceItem" to the end of the array.
4. Relaunch Safari Technology Preview.
5. Crash.

Expected Results:
No crash, Safari Technology Preview just launches with the funky toolbar layout.

Observed Results:
Crash because NSFlexibleSpaceItem's view is nil.

Version:
Release 38 (Safari 11.1, WebKit 13605.1.3.1)

Notes:
Continuation from rdar://problem/33815640, which was not resolved even though it was marked that it was.

Workaround:
For end users: Remove "NSFlexibleSpaceItem" from the end of the preferences array mentioned above.
For Apple: Check for "NSFlexibleSpaceItem" before adding its view to an array.

Configuration:
MacBook Pro (Retina, 13-inch, Early 2015) running macOS High Sierra 10.13 Beta (17A358a)

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!