Subject: 30.0.50; Abort with NSInvalidArgumentException on macOS Big Sur

From: Gerd Möllmann <[email-masked]>
Date: Fri, 08 Sep 2023 09:01:06 +0200

In GNU Emacs 30.0.50 (build 1, x86_64-apple-darwin20.6.0, NS
 appkit-2022.70 Version 11.7.9 (Build 20G1426)) of 2023-09-08 built on
 Pro.fritz.box
Repository revision: dd818ed821f7a9a35253e39374ee5f0aaae669bb
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.7.9

This is a 10 year old Mac.  I can't reproduce it at will.  Below is what
was printed to the terminal, then Emacs aborted.

emacs[29331:353519] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSViewBackingLayer getContext]: unrecognized selector sent to instance 0x11cc693a0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2076fbdb __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff204a8d92 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff207f270d -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff206d7c2b ___forwarding___ + 1448
	4   CoreFoundation                      0x00007fff206d75f8 _CF_forwarding_prep_0 + 120
	5   emacs                               0x000000010033d481 -[EmacsView lockFocus] + 49
	6   emacs                               0x000000010032ee27 ns_focus + 87
	7   emacs                               0x000000010033df80 ns_clear_frame_area + 400
	8   emacs                               0x000000010033dda1 -[EmacsView drawRect:] + 321
	9   AppKit                              0x00007fff2306ddab _NSViewDrawRect + 139
	10  AppKit                              0x00007fff2379fcdf -[NSView _recursive:displayRectIgnoringOpacity:inContext:stopAtLayerBackedViews:] + 2115
	11  AppKit                              0x00007fff2306d3c5 -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] + 967
	12  QuartzCore                          0x00007fff26e89271 CABackingStoreUpdate_ + 219
	13  QuartzCore                          0x00007fff26ef084d ___ZN2CA5Layer8display_Ev_block_invoke + 53
	14  QuartzCore                          0x00007fff26e88787 -[CALayer _display] + 2247
	15  AppKit                              0x00007fff2306cf35 -[_NSBackingLayer display] + 475
	16  AppKit                              0x00007fff22fd8022 -[_NSViewBackingLayer display] + 555
	17  QuartzCore                          0x00007fff26e876f3 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 863
	18  QuartzCore                          0x00007fff26fd2bee _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 666
	19  QuartzCore                          0x00007fff26e68b6f _ZN2CA11Transaction6commitEv + 713
	20  AppKit                              0x00007fff22f500a5 NSPerformVisuallyAtomicChange + 154
	21  AppKit                              0x00007fff2314c06f -[NSWindow addChildWindow:ordered:] + 640
	22  emacs                               0x000000010033fe08 -[EmacsWindow setParentChildRelationships] + 696
	23  emacs                               0x000000010033f2ad -[EmacsWindow initWithEmacsFrame:fullscreen:screen:] + 1485
	24  emacs                               0x000000010033ecd0 -[EmacsWindow initWithEmacsFrame:] + 48
	25  emacs                               0x000000010033ace5 -[EmacsView initFrameFromEmacs:] + 1045
	26  emacs                               0x00000001003579a1 Fx_create_frame + 7937