I'm looking are some CrashReporter logs for my Cocoa/MacOSX application and it looks like the reason for the crash is that some cleanup I expect to perform in the [applicationShouldTerminate:]
method of the NSApplicationDelete
isn't being performed. However, the app is terminating as evidenced by the following trace:
1 libSystem.B.dylib 0x959a72d4 exit + 33
2 com.apple.AppKit 0x9778ecc2 -[NSApplication terminate:] + 1056
3 com.apple.AppKit 0x977c6c60 -[NSApplication _terminateSendShould:] + 71
4 com.apple.CoreFoundation 0x96d48aad __invoking___ + 29
5 com.apple.CoreFoundation 0x96d48a18 -[NSInvocation invoke] + 136
6 com.apple.Foundation 0x99092970 __NSFireTimer + 141
7 com.apple.CoreFoundation 0x96d0d76b __CFRunLoopRun + 8059
8 com.apple.CoreFoundation 0x96d0b0f4 CFRunLoopRunSpecific + 452
9 com.apple.CoreFoundation 0x96d0af21 CFRunLoopRunInMode + 97
Obviously, my appDelegate implements [applicationShouldTerminate:]
and I see it invoked when developing/debugging. Even in the field there are only a small % of reports which suggest this might not be getting invoked.
Three questions:
- Does anyone know of cases where
[applicationShouldTerminate:]
will not be invoked but the app still be terminated? - Is there any other better method to do cleanup in? The cleanup I do could potentially take some time, so I'm not sure if doing it in
[applicationWillTerminate]
is any different/better than what I have. - Does the stack above imply that
[applicationShouldTerminate:]
was already definitely invoked and that this could be a bug someplace else in my cleanup logic?