Skip to content

Commit cd776d8

Browse files
committed
Change the timeout for Apple Events
Change the timeout for waiting for response for Apple Events sent to external apps (like Finder) from default 60 sec to 5 sec. I ran into into an issue in Finder in macOS 26 with something that looked like a hang in OMC contextual menu when waiting for response from Finder for the query: `OSErr err = MoreAETellAppToGetAEDesc('MACS', pInsertionLoc, typeWildCard, &outFinderObj);` After a minute it went back alive though so digging through the code and documentation for kAEDefaultTimeout it became apparent it was blocking for 60 secs before timing out. I could not reproduce the issue under debugger despite multiple tries so the mitigation for now is change timeout from 60 secs to 5 secs. From user perspective worst case it will look like a hiccup, not a hang. In most cases it does seem to work just fine so even if there is some issue, it is not completely broken in macOS 26. Below is the sampling log from Activity Monitor when the 60 sec wait happened: ``` Call graph: 2572 Thread_12989008: Main Thread + 2572 start (in dyld) + 7184 [0x19c401d54] + 2572 NSApplicationMain (in AppKit) + 880 [0x1a0c31694] + 2572 -[NSApplication run] (in AppKit) + 408 [0x1a0c45748] + 2572 -[NSApplication _handleEvent:] (in AppKit) + 60 [0x1a11986ec] + 2572 -[NSApplication(NSEventRouting) sendEvent:] (in AppKit) + 1244 [0x1a169e48c] + 2572 SendEventToEventTarget (in HIToolbox) + 40 [0x1a924e50c] + 2572 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) (in HIToolbox) + 316 [0x1a9260264] + 2572 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) (in HIToolbox) + 2336 [0x1a924fa2c] + 2572 ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) (in HIToolbox) + 492 [0x1a925f578] + 2572 SendEventToEventTargetWithOptions (in HIToolbox) + 44 [0x1a93e2114] + 2572 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) (in HIToolbox) + 316 [0x1a9260264] + 2572 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) (in HIToolbox) + 1268 [0x1a924f600] + 2572 ShortcutEventHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) (in ShortcutObserver) + 180 [0x104c5af4c] ShortcutsObserverDelegate.mm:207 + 2572 -[ShortcutsObserverDelegate handleShortcutEvent:] (in ShortcutObserver) + 208 [0x104c5bd98] ShortcutsObserverDelegate.mm:694 + 2572 -[ShortcutsObserverDelegate executeCMPlugin:submenuPath:itemName:prefersText:] (in ShortcutObserver) + 344 [0x104c5c3dc] ShortcutsObserverDelegate.mm:959 + 2572 ACMPluginProxyExamineContext(void*, AEDesc const*, AEDesc*) (in OnMyCommandCM) + 84 [0x10500ca80] ACMPluginProxy.cp:211 + 2572 OnMyCommandCM::CommonContextCheck(AEDesc const*, void const*, AEDesc*, int) (in Abracode) + 1328 [0x1170a3ef8] OnMyCommand.cp:402 + 2572 CMUtils::IsClickInOpenFinderWindow(AEDesc const*, unsigned char) (in Abracode) + 300 [0x11707fab8] CMUtilsFinder.cp:169 + 2572 GetInsertionLocationAsAliasDesc(AEDesc&, AEDesc&) (in Abracode) + 56 [0x11707fbe8] CMUtilsFinder.cp:24 + 2572 MoreAETellAppToGetAEDesc (in Abracode) + 68 [0x11708b368] MoreAppleEvents.cp:266 + 2572 MoreAETellAppObjectToGetAEDesc (in Abracode) + 240 [0x11708b4a8] MoreAppleEvents.cp:507 + 2572 MoreAESendEventReturnAEDesc (in Abracode) + 100 [0x11708b1ec] MoreAppleEvents.cp:239 + 2572 aeSend (in AE) + 320 [0x1a4a3e564] + 2572 AESendMessage (in AE) + 5444 [0x1a4a34c8c] + 2572 ??? (in AE) load address 0x1a4a1c000 + 0x3c66c [0x1a4a5866c] + 2572 _CFRunLoopRunSpecificWithOptions (in CoreFoundation) + 532 [0x19c91c898] + 2572 __CFRunLoopRun (in CoreFoundation) + 1188 [0x19c85e5d8] + 2572 __CFRunLoopServiceMachPort (in CoreFoundation) + 160 [0x19c85fc80] + 2572 mach_msg (in libsystem_kernel.dylib) + 24 [0x19c77dfb4] + 2572 mach_msg_overwrite (in libsystem_kernel.dylib) + 484 [0x19c78698c] + 2572 mach_msg2_internal (in libsystem_kernel.dylib) + 76 [0x19c790028] + 2572 mach_msg2_trap (in libsystem_kernel.dylib) + 8 [0x19c77dc34] ```
1 parent 9736a3f commit cd776d8

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

AbracodeFramework/CMUtils/CMUtilsSendAE.cp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ CMUtils::SendAEWithThreeObjToRunningApp( FourCharCode appSig, AEEventClass theAE
108108
}
109109

110110
StAEDesc theAEReply;
111+
SInt32 timeout = 60 * 5; //wait no longer than 5 secs. kAEDefaultTimeout is 60 secs
111112
theErr = ::AESend( appleEvent, theAEReply, theMode,
112-
kAENormalPriority, kAEDefaultTimeout, theUpp, NULL);
113+
kAENormalPriority, timeout, theUpp, NULL);
113114

114115
if(theUpp != NULL)
115116
{
@@ -234,8 +235,9 @@ CMUtils::SendAEWithThreeObjToRunningApp( const char * inAppBundleIDCStr, AEEvent
234235
}
235236

236237
StAEDesc theAEReply;
238+
SInt32 timeout = 60 * 5; //wait no longer than 5 secs. kAEDefaultTimeout is 60 secs
237239
theErr = ::AESend( appleEvent, theAEReply, theMode,
238-
kAENormalPriority, kAEDefaultTimeout, theUpp, NULL);
240+
kAENormalPriority, timeout, theUpp, NULL);
239241

240242
if(theUpp != NULL)
241243
{

AbracodeFramework/MoreAppleEvents/MoreAppleEvents.cp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ OSErr MoreAEOCreateSelectionObject( const DescType pSelectionAEDesc,
236236
AESendMode sendMode = kAEWaitReply;
237237

238238
StAEDesc theReply;
239-
OSErr anErr = AESend(pAppleEvent, &theReply, sendMode, kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
239+
SInt32 timeout = 60 * 5; //wait no longer than 5 secs. kAEDefaultTimeout is 60 secs
240+
OSErr anErr = AESend(pAppleEvent, &theReply, sendMode, kAENormalPriority, timeout, NULL, NULL);
240241
// [ Don't dispose of the event, it's not ours ]
241242
if (noErr == anErr)
242243
{

Common/OmcVersion.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OMC_BUNDLE_VERSION = 4.3.0
1+
OMC_BUNDLE_VERSION = 4.3.1
22

33
//2 digits per version point : 3.2.0 = 03 02 00
44
OMC_VERSION_DEFINITIONS = CURRENT_OMC_VERSION=40300 MIN_OMC_VERSION=30200 MIN_MAC_OS_VERSION=110000 MAX_MAC_OS_VERSION=999999

0 commit comments

Comments
 (0)