So I just installed the 26.4 update and unfortunately I have to debug this newly introduced issue (that may work its way into a separate thread).
In my debugging steps I'm testing something related to files and I used -activateFileViewerSelectingURLs: to show the file in Finder. Now I am off the main thread.
I added this line for testing purposes and I get a crash:
NSWindow should only be instantiated on the main thread!' terminating due to uncaught exception of type NSException.
So apparently - NSWorkspace is calling through to NSServices APIs and for some reason the system wants to present an NSError, which is a subtopic and other bug on its own because the 'Show in Finder" functionality actually WORKS but it crashed my app!
#22in +[NSAlert alertWithError:] ()
#23in -[NSApplication(NSErrorPresentation) presentError:] ()
#24 +[NSServicesMenuHandler _performServiceFromEntry:withPasteboard:withRequestor:withInvocationSourceType:withCarbonFocus:withSendTypes:withReturnTypes:canReleasePasteboardImmediately:] ()
#25 +[NSServicesMenuHandler _performServiceWithoutAlternatesFromEntry:withPasteboard:withRequestor:withInvocationSourceType:] ()
#26 +[NSServicesMenuHandler _performServiceFromEntry:withPasteboard:withRequestor:withInvocationSourceType:] ()
#27 [NSWorkspace activateFileViewerSelectingURLs:]
What error it is trying to present.. I have no idea. I'm not sure if I actually have a code path that calls this method off the main thread but I guess I'll have to check. This clearly goes against the documentation. NSWorkspace documentation clearly states:
-activateFileViewerSelectingURLs:
Discussion You can safely call this method from any thread of your app.
Is this new in 26.4? I'm not sure but I just noticed.
I definitely use other NSWorkspace methods off the main thread in areas of my app. Like -activateFileViewerSelectingURLs: the documentation for those other methods claims you can safely call them off the main thread. So now I'm concerned.