Saving during loading will now deadlock on Lion, since you're trying to do a 
coordinated write while NSDocumentController still has a coordinated read on 
your file. Don't save while loading.

Does -takkeEvent: happen in response to NSUndoManager notifications? Something 
could be poking the NSUndoManager.

--Kyle Sluder

On Aug 28, 2011, at 11:44 PM, "Gerriet M. Denkmann" <gerr...@mdenkmann.de> 
wrote:

> I have a document based app which collects data and updates its document.
> Works fine in Snow Leopard, hangs in Lion.
> 
> At start it blocks (see sample at end of post). 
> This initial hang can be avoided, if for the first 3 seconds  after launch no 
> saves are allowed. (Rather a crude hack).
> But even then, it usually will hang some time later (maybe a long time later 
> - hard to reproduce).
> 
> I guess that Lion tries to restore some windows which interferes with my own 
> calls to saveDocument:.
> 
> 
> MyDocument is a subclass of NSDocument.
> Overridden NSDocument methods are:
> - (id)init
> - (id)initWithType:(NSString *)typeName error:(NSError **)outError
> - (void)dealloc
> - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
> error:(NSError **)outError
> - (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
> forSaveOperation:(NSSaveOperationType)saveOperation 
> originalContentsURL:(NSURL *)absoluteOriginalContentsURL error:(NSError 
> **)outError
> - (BOOL)writeToURL:(NSURL *)absoluteURL  ofType:(NSString *)typeName  
> error:(NSError **)outError
> - (void)close
> all of these contain log statements.
> some more:
> - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel
> - (NSString *)windowNibName
> - (void)windowControllerDidLoadNib:(NSWindowController *) aController
> 
> The ap starts like this:
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
>    // ....
>    NSDocumentController  *sDC = [ NSDocumentController 
> sharedDocumentController ];
>    NSError *outError ;
>    activeDoc = [ sDC openDocumentWithContentsOfURL: absoluteURL  display: YES 
>  error: &outError ];
>    if ( activeDoc == nil )    //    error handling (no error did happen)
> }
> 
> creates these logs:
> 2011-08-29 13:00:38.396 EnTeP[4982:707] -[MyDocument init] self <MyDocument: 
> 0x1005278f0>
> 2011-08-29 13:00:38.399 EnTeP[4982:707] -[MyDocument 
> readFromURL:ofType:error:] self <MyDocument: 0x1005278f0>
> 2011-08-29 13:00:38.402 EnTeP[4982:707] -[MyDocument 
> readFromURL:ofType:error:] done
> 
> 
> Then something happens and this code gets executed:
> 
> - (BOOL)takkeEvent: (EvenT *)eve ; 
> {
>    //    do something then:
>    NSLog(@"%s will save",__FUNCTION__);
>    [ self saveDocument: nil ]; 
>    NSLog(@"%s did save",__FUNCTION__); ← Note: never gets to here
> }
> 
> which writes this log line, and then hangs forever:
> 2011-08-29 13:00:41.417 EnTeP[4982:707] -[MyDocument takkeEvent:] will save 
> 
> 
> How do I debug this (I'm rather new to Lion)?
> 
> 
> And here is the sample, taken by Activity Monitor:
> 
> OS Version:      Mac OS X 10.7.1 (11B26)
> Report Version:  7
> 
> Call graph:
>    2678 Thread_175770   DispatchQueue_1: com.apple.main-thread  (serial)
>    + 2678 start  (in EnTeP) + 52  [0x100001464]
>    +   2678 main  (in EnTeP) + 34  [0x100001492]  main.m:13
>    +     2678 NSApplicationMain  (in AppKit) + 867  [0x7fff9234652a]
>    +       2678 -[NSApplication run]  (in AppKit) + 463  [0x7fff920c83d6]
>    +         2678 -[NSApplication 
> nextEventMatchingMask:untilDate:inMode:dequeue:]  (in AppKit) + 135  
> [0x7fff920cba95]
>    +           2678 _DPSNextEvent  (in AppKit) + 1247  [0x7fff920cc3dd]
>    +             2678 AEProcessAppleEvent  (in HIToolbox) + 102  
> [0x7fff8f9cb12d]
>    +               2678 aeProcessAppleEvent  (in AE) + 250  [0x7fff9381e857]
>    +                 2678 _ZL25dispatchEventAndSendReplyPK6AEDescPS_  (in AE) 
> + 38  [0x7fff9381e963]
>    +                   2678 aeDispatchAppleEvent(AEDesc const*, AEDesc*, 
> unsigned int, unsigned char*)  (in AE) + 200  [0x7fff9381ea85]
>    +                     2678 _NSAppleEventManagerGenericHandler  (in 
> Foundation) + 105  [0x7fff8e30afdc]
>    +                       2678 -[NSAppleEventManager 
> dispatchRawAppleEvent:withRawReply:handlerRefCon:]  (in Foundation) + 283  
> [0x7fff8e30b14e]
>    +                         2678 __-[NSAppleEventManager 
> setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_1  (in 
> Foundation) + 101  [0x7fff8e30c1c7]
>    +                           2678 -[NSObject 
> performSelector:withObject:withObject:]  (in CoreFoundation) + 65  
> [0x7fff98ceaf51]
>    +                             2678 -[NSApplication(NSAppleEventHandling) 
> _handleCoreEvent:withReplyEvent:]  (in AppKit) + 330  [0x7fff920cefb1]
>    +                               2678 -[NSApplication(NSAppleEventHandling) 
> _handleAEOpenEvent:]  (in AppKit) + 242  [0x7fff920cf250]
>    +                                 2678 -[NSApplication 
> _sendFinishLaunchingNotification]  (in AppKit) + 78  [0x7fff920d04df]
>    +                                   2678 -[NSApplication 
> _postDidFinishNotification]  (in AppKit) + 212  [0x7fff920d0779]
>    +                                     2678 -[NSNotificationCenter 
> postNotificationName:object:userInfo:] (in Foundation) + 65  [0x7fff8e2d59cb]
>    +                                       2678 _CFXNotificationPost  (in 
> CoreFoundation) + 2634  [0x7fff98ca151a]
>    +                                         2678 __-[NSNotificationCenter 
> addObserver:selector:name:object:]_block_invoke_1  (in Foundation) + 47  
> [0x7fff8e2e9716]
>    +                                           2678 -[FeuchtDel 
> applicationDidFinishLaunching:]  (in EnTeP) + 3264  [0x100002570]  
> FeuchtDel.m:778
>    +                                             2678 -[FeuchtDel takeEvent:] 
>  (in EnTeP) + 59  [0x1000035fb]  FeuchtDel.m:1597
>    +                                               2678 -[MyDocument 
> takkeEvent:]  (in EnTeP) + 1654  [0x1000196e6]  MyDocument.m:1063
>    +                                                 2678 -[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]  (in AppKit) + 92  
> [0x7fff9246ae33]
>    +                                                   2678 -[NSDocument 
> performActivityWithSynchronousWaiting:usingBlock:]  (in AppKit) + 82  
> [0x7fff924834b6]
>    +                                                     2678 __-[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]_block_invoke_1 (in 
> AppKit) + 192  [0x7fff9246aef9]
>    +                                                       2678 -[NSDocument 
> _commitEditingWithDelegate:didSomethingSelector:contextInfo:thenContinue:]  
> (in AppKit) + 91  [0x7fff924762ab]
>    +                                                         2678 
> -[NSDocument _commitEditingThenContinue:]  (in AppKit) + 337  [0x7fff9247a5e0]
>    +                                                           2678 
> __-[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]_block_invoke_2 (in 
> AppKit) + 527  [0x7fff9246b170]
>    +                                                             2678 
> __-[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]_block_invoke_6 (in 
> AppKit) + 290  [0x7fff9246b439]
>    +                                                               2678 
> -[NSDocument _checkForFileChangesThenSave:saveAs:orCancel:]  (in AppKit) + 
> 797  [0x7fff924803cf]
>    +                                                                 2678 
> __-[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]_block_invoke_7 (in 
> AppKit) + 114  [0x7fff9246b5c0]
>    +                                                                   2678 
> -[NSDocument continueActivityUsingBlock:]  (in AppKit) + 42  [0x7fff92467823]
>    +                                                                     2678 
> __-[NSDocument 
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]_block_invoke_8 (in 
> AppKit) + 194  [0x7fff9246ba13]
>    +                                                                       
> 2678 -[NSDocument 
> saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:]  (in 
> AppKit) + 112  [0x7fff9246c2cc]
>    +                                                                         
> 2678 -[NSDocument performActivityWithSynchronousWaiting:usingBlock:]  (in 
> AppKit) + 82  [0x7fff924834b6]
>    +                                                                          
>  2678 __-[NSDocument 
> saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:]_block_invoke_1
>   (in AppKit) + 344  [0x7fff9246c42a]
>    +                                                                          
>    2678 -[NSDocument 
> _commitEditingWithDelegate:didSomethingSelector:contextInfo:thenContinue:]  
> (in AppKit) + 91  [0x7fff924762ab]
>    +                                                                          
>      2678 -[NSDocument _commitEditingThenContinue:]  (in AppKit) + 337  
> [0x7fff9247a5e0]
>    +                                                                          
>        2678 __-[NSDocument 
> saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:]_block_invoke_2
>   (in AppKit) + 131  [0x7fff9246c555]
>    +                                                                          
>          2678 -[NSDocument 
> saveToURL:ofType:forSaveOperation:completionHandler:]  (in AppKit) + 91  
> [0x7fff9246d860]
>    +                                                                          
>            2678 -[NSDocument performAsynchronousFileAccessUsingBlock:]  (in 
> AppKit) + 304  [0x7fff9248316b]
>    +                                                                          
>              2678 -[NSDocument _performFileAccessOnMainThread:usingBlock:]  
> (in AppKit) + 466  [0x7fff92483413]
>    +                                                                          
>                2678 -[NSDocument continueFileAccessUsingBlock:]  (in AppKit) 
> + 227  [0x7fff92468bda]
>    +                                                                          
>                  2678 __-[NSDocument 
> saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_1  (in 
> AppKit) + 845  [0x7fff9246dbb3]
>    +                                                                          
>                    2678 -[NSDocument 
> _fileCoordinator:coordinateReadingContentsAndWritingItemAtURL:byAccessor:]  
> (in AppKit) + 248  [0x7fff9247f6fc]
>    +                                                                          
>                      2678 -[NSFileCoordinator(NSPrivate) 
> _coordinateReadingItemAtURL:options:writingItemAtURL:options:error:byAccessor:]
>   (in Foundation) + 677  [0x7fff8e4c2234]
>    +                                                                          
>                        2678 -[NSFileCoordinator(NSPrivate) 
> _blockOnAccessClaim:]  (in Foundation) + 183  [0x7fff8e4c2bdb]
>    +                                                                          
>                          2678 _dispatch_semaphore_wait_slow  (in 
> libdispatch.dylib) + 109  [0x7fff90f9808e]
>    +                                                                          
>                            2678 semaphore_wait_trap  (in 
> libsystem_kernel.dylib) + 10  [0x7fff910b86b6]
>    2678 Thread_175779   DispatchQueue_2: com.apple.libdispatch-manager  
> (serial)
>    + 2678 _dispatch_mgr_thread  (in libdispatch.dylib) + 54  [0x7fff90f9519e]
>    +   2678 _dispatch_mgr_invoke  (in libdispatch.dylib) + 923  
> [0x7fff90f9660e]
>    +     2678 kevent  (in libsystem_kernel.dylib) + 10  [0x7fff910ba7e6]
>    2678 Thread_175818: com.apple.CFSocket.private
>      2678 thread_start  (in libsystem_c.dylib) + 13  [0x7fff93425b75]
>        2678 _pthread_start  (in libsystem_c.dylib) + 335  [0x7fff934228bf]
>          2678 __CFSocketManager  (in CoreFoundation) + 1355  [0x7fff98cd666b]
>            2678 __select  (in libsystem_kernel.dylib) + 10  [0x7fff910b9df2]
> 
> Total number in stack (recursive counted multiple, when >=5):
> 
> Sort by top of stack, same collapsed (when >= 5):
>        __select  (in libsystem_kernel.dylib)        2678
>        kevent  (in libsystem_kernel.dylib)        2678
>        semaphore_wait_trap  (in libsystem_kernel.dylib)        2678
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kyle.sluder%40gmail.com
> 
> This email sent to kyle.slu...@gmail.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to