Posts

Post not yet marked as solved
10 Replies
2.8k Views
I have a persistent "crash" with at least one of my apps, which appears to be a case of the app either quitting or being force-quit without generating a crash log. The app doesn't subscribe to any sudden termination compatibility or similar. I have a good friend who is a developer who is able to reproduce the issue within minutes, so I've captured a trove of information from him including a complete sysdiagnose. Unfortunately nothing is jumping out at me, and the only things that show up that seem like they might be related are keys like ApplicationWouldBeTerminatedByTAL and NSCanQuitQuietlyAndSafelyKey. I am kind of grasping at straws and would welcome any inspiration anybody can share. What is TAL and is it something the system could be imposing on my app? If there are circumstances where macOS will preemptively terminate a running app, what are they, and how can I figure out which one is causing the quits in these situatoins? I'd love to be able to reproduce the behavior on my own Mac. If it's something I can prevent, great, if it's not, it would be good to know how to distinguish it from a regular crash for reporting purposes. Thanks for any help!
Posted
by jalkut.
Last updated
.
Post not yet marked as solved
4 Replies
831 Views
I'm debugging an odd situation wherein my app MarsEdit, which is sandboxed but has entitlements to send Apple events to BBEdit, is blocking from sending those events only with the newest version of BBEdit (13.5). For example, sending events to BBEdit 13.1 I have debugged the problem enough to learn that the failure occurs in the Apple events infrastructure, attempting to locate and open a port for the delivery of events. In the working case, I witness the following debug console message: SUCCESSFULLY found another process by bundleID using the new appleeventsd server, "com.barebones.bbedit", port=( port:124783/0x1e76f rcv:0,send:2,d:0 limit:0) Whereas in the broken case, I see: debug 22:57:10.873976-0400 MarsEdit Couldn't find a process with pid 11325 SUCCESSFULLY found another process by bundleID using the new appleeventsd server, "com.barebones.bbedit", port=(null machport) My best guess is that BBEdit 13.5 is being made "invisible" to MarsEdit based on a failure to apply the entitlement MarsEdit has to send Apple events to "com.barebones.bbedit", when targeting BBEdit 13.5. I have confirmed that disabling the sandbox for my app causes the event delivery to succeed. I have also reproduced the error, which culminates in a -600 OSStatus error from AESend, in a trivial sandboxed test app which just tries to send an event to BBEdit. Anybody have any ideas why BBEdit 13.5 might cause the system to exhibit this nuanced difference in behavior? It kind of smells like a "linked on or after" behavioral difference, which might make sense given the BBEdit 13.5 release seems to have been built on and linked with a newer SDK than previous releases. Here is the complete source code for a sample app's App Delegate that exhibits the bug. Create a new, sandboxed Mac app with this as the app delegate source if you interested to reproduce the problem. Make sure to add a com.apple.security.temporary-exception.apple-events entitlement for com.barebones.bbedit. (NSAppleEventDescriptor*) targetDescriptorAppWithIdentifier:(NSString*)bundleIdentifier { // Prefer a running instance NSRunningApplication* runningApp = [NSRunningApplication runningApplicationsWithBundleIdentifier:bundleIdentifier].firstObject; if (runningApp == nil) { NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; NSURL* targetURL = [workspace URLForApplicationWithBundleIdentifier:bundleIdentifier]; if (targetURL != nil) { NSDictionary* launchConfig = @{}; NSError* launchError = nil; runningApp = [workspace launchApplicationAtURL:targetURL options:0 configuration:launchConfig error:&launchError]; } } if (runningApp != nil) { return [NSAppleEventDescriptor descriptorWithProcessIdentifier:runningApp.processIdentifier]; } return nil; } (NSAppleEventDescriptor*) appleEventForOpeningFileAtPath:(NSString*)filePath withApplicationBundleID:(NSString*)appBundleID displayingCustomPathString:(NSString*)customPathString { NSAppleEventDescriptor* targetDescriptor = [self targetDescriptorAppWithIdentifier:appBundleID]; NSAppleEventDescriptor* openFileEvent = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass eventID:kAEOpenDocuments targetDescriptor: targetDescriptor returnID: kAutoGenerateReturnID transactionID:kAnyTransactionID]; // Dont need actual file parameters to exhibit the connection return openFileEvent; } (void)applicationDidFinishLaunching:(NSNotification *)aNotification { AEDesc reply = {typeNull, NULL}; NSAppleEventDescriptor* openFileEvent = [self appleEventForOpeningFileAtPath:@"/tmp/hello" withApplicationBundleID:@"com.barebones.bbedit" displayingCustomPathString:@"HI"]; OSStatus status = AESend([openFileEvent aeDesc], &reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL); NSLog(@"Got AESend status %d", status); } If you launch BBEdit 13.5 so that it is running while the test app runs, you will see a -600 error from AESend, whereas if you launch BBEdit 13.1 so that it is running, you will see a noErr.
Posted
by jalkut.
Last updated
.
Post not yet marked as solved
0 Replies
560 Views
Just in case it's affecting anybody else, I have filed a feedback FB7834896 detailing the fact that Big Sur crashes in AppKit's toolbar-based title view code, when I change the fileURL of my document. This is the head of a typical crash log: 0	 CoreFoundation											0x00007fff2a9e66a3 __exceptionPreprocess + 242 1	 libobjc.A.dylib										 0x00007fff70324837 objc_exception_throw + 48 2	 CoreFoundation											0x00007fff2aa0f34e +[NSException raise:format:arguments:] + 88 3	 Foundation													0x00007fff2d545519 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191 4	 AppKit															0x00007fff277e5baf -[NSStackView insertArrangedSubview:atIndex:] + 924 5	 AppKit															0x00007fff27fa3f0d -[NSToolbarPrimaryTitleContainerView _configureWithRepresentedURL:] + 97 6	 AppKit															0x00007fff27fa3d68 -[NSToolbarPrimaryTitleContainerView updateTitleProperties:] + 217 7	 AppKit															0x00007fff27fa5ac8 -[NSToolbarTitleView _updateTitleProperties:] + 1103
Posted
by jalkut.
Last updated
.