使用应用程序打开文件非常慢:openFile:返回后

时间:2012-09-01 05:08:49

标签: macos cocoa appleevents

我的应用程序在其app委托中实现NSApplicationDelegate方法-application:openFile :. OS 10.8似乎有一个新问题,在接收到打开文件的apple事件后,在某种内部超时被击中前经过五秒钟,响应被发送到apple事件和调用应用程序(例如,applescript)编辑)继续。

详细说明,这就是我所看到的。应用程序之后:openFile:返回YES,我可以看到 - [NSAppleEventManager suspendCurrentAppleEvent]被调用:

#0  0x00007fff8f07b5ed in -[NSAppleEventManager suspendCurrentAppleEvent] ()
#1  0x00007fff8f90458e in -[NSApplication(NSAppleEventHandling) _handleAEOpenDocumentsForURLs:] ()
#2  0x00007fff8f903b55 in -[NSApplication(NSScripting) handleOpenScriptCommand:] ()
#3  0x00007fff90770cac in __invoking___ ()
#4  0x00007fff90770b47 in -[NSInvocation invoke] ()
#5  0x00007fff90770d19 in -[NSInvocation invokeWithTarget:] ()
#6  0x00007fff8f10121c in -[NSScriptCommand _sendToRemainingReceivers] ()
#7  0x00007fff8f1014c6 in -[NSScriptCommand executeCommand] ()
#8  0x00007fff8f11983a in -[NSScriptingAppleEventHandler handleCommandEvent:withReplyEvent:] ()
#9  0x00007fff8f00635b in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#10 0x00007fff8f0061bd in _NSAppleEventManagerGenericHandler ()
#11 0x00007fff93844f68 in aeDispatchAppleEvent ()
#12 0x00007fff93844dc9 in dispatchEventAndSendReply ()
#13 0x00007fff93844c89 in aeProcessAppleEvent ()
#14 0x00007fff8c141e29 in AEProcessAppleEvent ()
#15 0x00007fff8f6b22a6 in _DPSNextEvent ()
#16 0x00007fff8f6b1862 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#17 0x00007fff8f6a8c03 in -[NSApplication run] ()
#18 0x00007fff8f64d656 in NSApplicationMain ()
#19 0x0000000100001d7c in main (argc=3, argv=0x7fff5fbff7c0) at main.m:23

五秒钟后,调用[NSAppleEventManager resumeWithSuspensionID:]:

#0  0x00007fff8f07b6be in -[NSAppleEventManager resumeWithSuspensionID:] ()
#1  0x00007fff8f90585f in __block_global_1 ()
#2  0x00007fff9073a4b4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#3  0x00007fff90739fcd in __CFRunLoopDoTimer ()
#4  0x00007fff9071f7b9 in __CFRunLoopRun ()
#5  0x00007fff9071edd2 in CFRunLoopRunSpecific ()
#6  0x00007fff8c137774 in RunCurrentEventLoopInMode ()
#7  0x00007fff8c137512 in ReceiveNextEventCommon ()
#8  0x00007fff8c1373a3 in BlockUntilNextEventMatchingListInMode ()
#9  0x00007fff8f6b1fa3 in _DPSNextEvent ()
#10 0x00007fff8f6b1862 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#11 0x00007fff8f6a8c03 in -[NSApplication run] ()
#12 0x00007fff8f64d656 in NSApplicationMain ()
#13 0x0000000100001d7c in main (argc=3, argv=0x7fff5fbff7c0) at main.m:23

显然,由于resumeWithSuspensionID:从计时器调用,并且在我的应用程序之间总是非常接近5秒,因此达到某种超时:openFile:方法返回和resumeWithSuspensionID:被调用。

在此之后,事情正常进行:无论什么Applecript调用“打开文件......”继续下一个声明。似乎没有任何错误 - 只是等待一些事情。

我打开了AEDebugSends和AEDebugReceives。这是我对超时的看法:

Aug 23 21:26:05 mymachine.local iTerm[4819] <Info>: _aeMachPortCallback(), got a message, @ 0x0x7fff5fbfe1f0 size=972 info=0 (_aeMachPortCallback()/AEMach.cp #643) main
Aug 23 21:26:05 mymachine.local iTerm[4819] <Notice>: AE2000 (4819: Received an event:
------oo start of event oo------
aevt('aevt'\'odoc' transactionID=0 returnID=3711 sourcePSN=[0x0,6f06f "AppleScript Editor"] eventSource=3 sourceUID=501 sourceGID=20 sourceEUID=501 sourceEGID=20 sourcePID=3551 auditToken=[501,501,20,501,20,3551,100005,3551]{ '----':obj ('obj '{ 'form':enum('name'), 'want':type('file'), 'seld':utxt('utxt'(TEXT("Macintosh HD:Users:georgen:Library:Application Support:iTerm:version.txt"))), 'from':null() }), &'csig':magn(65536) })
------oo  end of event  oo------
(aeProcessIncomingEvent()/AEMach.cp #1445) main
2012-08-23 21:26:05.451 iTerm[4819:707] Command: NSCoreSuite.Open
Direct Parameter: /Users/georgen/Library/Application Support/iTerm/version.txt
Receivers: (null)
Arguments:     {
        "" = "/Users/georgen/Library/Application Support/iTerm/version.txt";
    }

然后,在超时后我看到了这个(因为我还将NSScriptingDebugLogLevel设置为1而被记录):

2012-08-23 21:26:36.347 iTerm[4819:707] Result: <null>

除了返回YES之外,我的openFile:方法没有做任何事情。我还需要做些什么来让框架变得快乐吗?

0 个答案:

没有答案