Safari "WebKit Build Archives" crashes when opening Preferences

Summary

Safari "WebKit Build Archives" (AKA Safari nighties) crashes when opening Preferences. The Preference window doesn't even pop up before crashing.

Steps to reproduce

  1. Download a nightly build of Safari https://webkit.org/build-archives/#mac-monterey-x86_64
  2. Open run-webkit-archive
  3. Go got Safari > Preferences
  4. Observer crash

Environment

Does crash on:

  • MacBook Pro (15-inch, 2017)
  • macOS 12.2.1 and 12.3.1
  • WebKit Build Archives (249860@main, 249854@main, 249817@main, 292562)
    • Spot checked a few others from Feb to April as well

Do NOT crash on:

  • Safari included with macOS 12.3.1 (Version 15.4 (17613.1.17.1.13))
  • Safari Technology Preview
    • 143 (Safari 15.4, WebKit 17614.1.7.7)
    • 142
    • 141

Crash stack trace

2022-04-21 13:44:00.485 SafariForWebKitDevelopment[13786:133729] *** Assertion failure in -[NSMenuItem initWithTitle:action:keyEquivalent:], NSMenuItem.m:477
2022-04-21 13:44:00.487 SafariForWebKitDevelopment[13786:133729] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: aString != nil'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff8112d81e3 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff811038c13 objc_exception_throw + 48
	2   Foundation                          0x00007ff81217ac23 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 267
	3   AppKit                              0x00007ff813c74759 -[NSMenuItem initWithTitle:action:keyEquivalent:] + 363
	4   Safari                              0x00007ff91e63417a +[NSMenuItem(BrowserExtras) safari_menuItemForFileAtPath:] + 140
	5   Safari                              0x00007ff91e505a0b -[GeneralPreferences _updateDownloadLocationMenu] + 158
	6   libdispatch.dylib                   0x00007ff810fda0cc _dispatch_call_block_and_release + 12
	7   libdispatch.dylib                   0x00007ff810fdb317 _dispatch_client_callout + 8
	8   libdispatch.dylib                   0x00007ff810fe7c78 _dispatch_main_queue_drain + 943
	9   libdispatch.dylib                   0x00007ff810fe78bb _dispatch_main_queue_callback_4CF + 31
	10  CoreFoundation                      0x00007ff81129a9c7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	11  CoreFoundation                      0x00007ff81125b93f __CFRunLoopRun + 2771
	12  CoreFoundation                      0x00007ff81125a7ac CFRunLoopRunSpecific + 562
	13  HIToolbox                           0x00007ff819ee1ce6 RunCurrentEventLoopInMode + 292
	14  HIToolbox                           0x00007ff819ee1a4a ReceiveNextEventCommon + 594
	15  HIToolbox                           0x00007ff819ee17e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	16  AppKit                              0x00007ff813c8153d _DPSNextEvent + 927
	17  AppKit                              0x00007ff813c7fbfa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
	18  Safari                              0x00007ff91e16d8b5 -[BrowserApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 224
	19  AppKit                              0x00007ff813c722a9 -[NSApplication run] + 586
	20  AppKit                              0x00007ff813c46227 NSApplicationMain + 817
	21  Safari                              0x00007ff91e1581c0 SafariMain + 464
	22  dyld                                0x000000011583e51e start + 462
)
libc++abi: terminating with uncaught exception of type NSException
MessageReceiveQueueMap::addImpl - adding duplicate any id receiver 35

Tested on a Mac mini M1 with macOS 12.4 with Safari WebKit Build Archives 251224@main and the error and stack trace is the same. Also tested after creating a new user on this machine (no Apple Id login) so the user settings are not a factor here.

Thanks for the report, filed an investigation here: https://bugs.webkit.org/show_bug.cgi?id=253063

You may have success with following instructions, replacing Safari with SafariForWebKitDevelopment: https://apple.stackexchange.com/questions/429814/how-do-you-programmatically-enable-the-develop-menu-in-safari-15-on-macos-12 Unfortunately at the moment I do not immediately have an environment to reproduce the problem here.

Safari "WebKit Build Archives" crashes when opening Preferences
 
 
Q