Custom keyboard crashes in App Store, but not in when launched from Xcode - crash

I have found that installing and using custom keyboard works fine for my app when launching from Xcode, but if I release it to TestFlight or the AppStore then it crashes when a user clicks on a textbox and tries to bring up the keyboard. As far as I am aware there is nothing special about any of the textboxes in my app. The stack trace is:
Thread : Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 6512725832 __exceptionPreprocess
1 libobjc.A.dylib 6869942144 objc_exception_throw
2 CoreFoundation 6512725528 +[NSException raise:format:]
3 Foundation 6528403996 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 UIKit 6606881444 -[UIColor encodeWithCoder:]
5 Foundation 6528169072 _encodeObject
6 Foundation 6528197336 +[NSKeyedArchiver archivedDataWithRootObject:]
7 UIKit 6609904352 -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:traitCollection:selectorString:forRemoteProcess:]
8 UIKit 6609884356 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke
9 CoreFoundation 6511594744 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke
10 CoreFoundation 6511594448 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]
11 UIKit 6609883592 +[_UIAppearance _recordersExcludingSource:withWindow:]
12 UIKit 6611900724 UIViewServiceCurrentAppearanceSerializedRepresentations
13 UIKit 6610654700 +[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:]
14 UIKit 6610654160 +[_UIRemoteViewController requestViewControllerWithService:connectionHandler:]
15 UIKit 6609355772 __117-[NSExtension(UIViewControllerAdditions) instantiateViewControllerWithInputItems:listenerEndpoint:connectionHandler:]_block_invoke_2
16 libdispatch.dylib 6878402280 _dispatch_call_block_and_release
17 libdispatch.dylib 6878402216 _dispatch_client_callout
18 libdispatch.dylib 6878424496 _dispatch_main_queue_callback_4CF
19 CoreFoundation 6512427512 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
20 CoreFoundation 6512418912 __CFRunLoopRun
21 CoreFoundation 6511561888 CFRunLoopRunSpecific
22 GraphicsServices 6701891720 GSEventRunModal
23 UIKit 6602887164 UIApplicationMain
24 MyApp 4296179280 main (main.m:16)
25 libdyld.dylib 6878603448 start
Looking at the live device console I see the following messages:
Dec 8 15:22:11 cjhills-iPhone poc[371] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
*** First throw call stack:
(0x18244cf48 0x1978f7f80 0x18244ce18 0x183340a1c 0x187e182a4 0x183307470 0x18330e2d8 0x1880fa2e0 0x1880f54c4 0x182338cf8 0x182338bac 0x1880f51c8 0x1882e1934 0x1881b15ec 0x1881b13d0 0x1880743fc 0x1981096e8 0x1981096a8 0x19810edb0 0x1824041f8 0x182402060 0x182330ca0 0x18d8b4088 0x187a48ffc 0x10014e434 0x19813a8b8)
Dec 8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Dec 8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Dec 8 15:22:11 cjhills-iPhone SwiftKey[337] <Warning>: host connection <NSXPCConnection: 0x14ce60290> connection from pid 371 invalidated
Dec 8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: UNNotificationRegistrarConnectionListener connection invalidated
Dec 8 15:22:11 cjhills-iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.cjhill.myapp[0x5a38][371]) <Notice>: Service exited due to signal: Abort trap: 6
Dec 8 15:22:11 cjhills-iPhone diagnosticd[85] <Error>: unable to find offset 0x9812fa5c in shared cache for arch 'arm64'
Dec 8 15:22:11 cjhills-iPhone ReportCrash[372] <Notice>: platform_thread_get_unique_id matched 66610
Dec 8 15:22:11 cjhills-iPhone ReportCrash[372] <Notice>: Formulating report for corpse[371] myapp
Dec 8 15:22:11 cjhills-iPhone ReportCrash[372] <Warning>: saved type '109_myapp' report (2 of max 25) as /var/mobile/Library/Logs/CrashReporter/myapp_2015-12-08-152211_cjhills-iPhone.ips
Dec 8 15:22:11 cjhills-iPhone SpringBoard[58] <Warning>: Application 'UIKitApplication:com.cjhill.myapp[0x5a38]' crashed.
Dec 8 15:22:11 cjhills-iPhone UserEventAgent[26] <Warning>: 549612077011: id=com.cjhill.myapp pid=371, state=0

It appears from the stack trace that you use UIAppearance proxies to set up your App's appearance.
An interesting quirk of iOS extensions is that the customizations made in the other apps using this API are actually passed to extensions contained in the app (at least in the case of keyboard extensions).
To ensure security, all objects passed must be encoded using NSSecureCoding, which therefore requires that any objects you use in UIAppearance must conform to this protocol (and actually fulfill what it promises), as long as a user is using a keyboard extension in your app.
It appears that your app in this case is attempting to pass a color which can't be archived. Perhaps you are using an image as a color using +[UIColor colorWithPatternImage:], which would fit the error -- an image probably has no color in the sense UIColor means.
I recommend you audit your app's code for any instances where a UIAppearance is used to set a color, particularly when exotic calls like colorWithPatternedImage: are used, and remove them. Perhaps swizzle all UIAppearance calls to no-ops, push up an internal beta in TestFlight, and see if the problem is solved to confirm that this is the issue.
Regardless of which of these it is: File a bug with Apple. Apps should not crash just because they can't encode their UIAppearance correctly, especially when doing something that is, frankly, undesirable.
EDIT: it is possible to reproduce this issue without using TestFlight, whilst running an app in release (you can turn this on by going to product->scheme->edit scheme) by adding a line of code to set the background color of a UIButton to a UIColor which is a patterned color, then invoking a keyboard extension.

Related

Custom macOS login Plugin crashes on Catalina ("not in immutable memory")

I am using the Apple NameAndPassword Xcode example to customize the macOS login experience. My goal is authenticate a user against Active Directory. I am using the NameAndPassword example as a jumping board to understanding the macOS login process. I don't particularly need a custom UI, but from looking at several threads, the example can also work with PAM authentication.
I am running the NameAndPassword plugin which I built on Catalina. I am performing local code signing. When I log out, the loginwindow app should call the invoke method of my plugin and show a custom SFAuthorizationView, which does not appear. I see the following error in the system.log...
Jan 24 11:20:48 Kolyas-Mac SecurityAgentHelper[890]: objc[890]: CLASS: class 'EXAuthorizationPlugin' 0x104fb7d58 small method list 0x104fb1ec8 is not in immutable memory
Jan 24 11:20:48 Kolyas-Mac com.apple.xpc.launchd[1] (com.apple.security.agent.login.00000000-0000-0000-0000-0000000186E3[883]): Service exited due to SIGILL | sent by exc handler[883]
and see that the SecurityAgentHelper crashes with the following...
Application Specific Information:
dyld3 mode
CLASS: class 'EXAuthorizationPlugin' 0x104fb7d58 small method list 0x104fb1ec8 is not in immutable memory
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6d368ad6 __abort_with_payload + 10
1 libsystem_kernel.dylib 0x00007fff6d36a3df abort_with_payload_wrapper_internal + 80
2 libsystem_kernel.dylib 0x00007fff6d36a38f abort_with_reason + 19
3 libobjc.A.dylib 0x00007fff6c070820 _objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114
4 libobjc.A.dylib 0x00007fff6c0707ae _objc_fatal(char const*, ...) + 135
5 libobjc.A.dylib 0x00007fff6c063e13 realizeClassWithoutSwift(objc_class*, objc_class*) + 2184
6 libobjc.A.dylib 0x00007fff6c0636a0 realizeClassWithoutSwift(objc_class*, objc_class*) + 277
7 libobjc.A.dylib 0x00007fff6c0634bb realizeClassMaybeSwiftMaybeRelock(objc_class*, mutex_tt<false>&, bool) + 317
8 libobjc.A.dylib 0x00007fff6c062ff4 initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 104
9 libobjc.A.dylib 0x00007fff6c053d45 lookUpImpOrForward + 1072
10 libobjc.A.dylib 0x00007fff6c053399 _objc_msgSend_uncached + 73
11 com.apple.securityAgentPlugin.NameAndPassword 0x0000000104faee74 AuthorizationPluginCreate + 148 (main.m:66)
Any suggestions on how to resolve this error? Would this be a compiler issue? Maybe a directive for memory?
This is the offending code:
OSStatus AuthorizationPluginCreate(const AuthorizationCallbacks *callbacks,
AuthorizationPluginRef *outPlugin,
const AuthorizationPluginInterface **outPluginInterface)
{
os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "AuthorizationPluginCreate");
*outPlugin = [[EXAuthPlugin alloc] initWithCallbacks:callbacks pluginInterface:outPluginInterface];
return noErr;
}
I got the same error when porting my iPad app to Mac using Catalyst. My app needed access to AppKit specific methods, and I added a bundle plugin following this guide. The program worked fine on my MacBook Air M1 running Monterey, but crashed on my 2012 MacBook Pro running Catalina with the error:
CLASS: class 'AppKitBridge.AppKitBridge' 0x11668c388 small method list
0x116687508 is not in immutable memory
After I changed the bundle identifier in the plugin bundle from $(PRODUCT_BUNDLE_IDENTIFIER).AppKitBridge to $(PRODUCT_BUNDLE_IDENTIFIER), and set the plugins deployment target to 10.15, the problem went away.

My Xcode version 8.0 crashes

My Xcode crashes, After crash occur, I updated it to the latest version, i.e 8.0
But it doesn't stop crashing.
Process: Xcode [528]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 8.0 (11246)
Build Info: IDEFrameworks-11246000000000000~3
App Item ID: 497799835
App External ID: 818744938
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [528]
User ID: 501
Date/Time: 2016-10-08 14:08:34.396 +0500
OS Version: Mac OS X 10.11.6 (15G1004)
Report Version: 11
Anonymous UUID: 844112AA-C988-B86A-8002-19E0765599D4
Time Awake Since Boot: 180 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:ProductBuildVersion: 8A218a
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks- 11246/IDEKit/Application/IDEWindowMenuController.m:101
Details: itemName should be a non-empty string, but it's an empty string
Object: <IDEWindowMenuController>
Method: +titleForItemWithURL:name:image:parentLocations:presentedParentLocationCount:includeIconInTitles:
Thread: <NSThread: 0x7fc74ad179f0>{number = 1, name = main}
Hints: None
Following is the Back Trace Report:
Backtrace:
0 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
1 _DVTAssertionHandler (in DVTFoundation)
2 _DVTAssertionFailureHandler (in DVTFoundation)
3 +[IDEWindowMenuController titleForItemWithURL:name:image:parentLocations:presentedParentLocationCount:includeIconInTitles:] (in IDEKit)
4 __90+[IDEWindowMenuController _createAttributedTitlesForItemDictionaries:includeIconInTitles:]_block_invoke (in IDEKit)
5 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke (in CoreFoundation)
6 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] (in CoreFoundation)
7 +[IDEWindowMenuController _createAttributedTitlesForItemDictionaries:includeIconInTitles:] (in IDEKit)
8 -[IDEWindowMenuController _windowMenuItemsWithIconInTitles:] (in IDEKit)
9 -[IDEApplicationController applicationDockMenu:] (in IDEKit)
10 -[NSApplication _createDockMenu:] (in AppKit)
11 __44-[NSApplication _copyPublicPersistentUIInfo]_block_invoke (in AppKit)
12 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
13 __CFRunLoopDoBlocks (in CoreFoundation)
14 __CFRunLoopRun (in CoreFoundation)
15 CFRunLoopRunSpecific (in CoreFoundation)
16 RunCurrentEventLoopInMode (in HIToolbox)
17 ReceiveNextEventCommon (in HIToolbox)
18 _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
19 _DPSNextEvent (in AppKit)
20 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit)
21 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit)
22 -[NSApplication run] (in AppKit)
23 NSApplicationMain (in AppKit)
24 start (in libdyld.dylib)
abort() called
Application Specific Signatures:
![(itemName) isEqualToString:#""]
Try with these please :
Open Xcode
Preferences
Locations
The Derived Data option will tell you where your directory is
Delete that directory
Try to open your project
And check this thread also:
https://forums.developer.apple.com/thread/39603
This crash occurred due to problem in my project, so i was beginner, and I assumed that problem is in my X-Code.
The Project loaded automatically and causes crash to occur.
After opening some one previous project, and tried to stop this crashed project, Crashing stopped.. :P

Tracking down a SIGSEGV…

So I've got this weird SIGSEGV happening at very few (less than 1%) of my users…
From the stack trace it looks like an over-release
Thread 0 Crashed:
0 libobjc.A.dylib 0x00007fff9a3f916f objc_release + 31
1 libobjc.A.dylib 0x00007fff9a3f7ac4 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 475
2 CoreFoundation 0x00007fff9cc5c102 _CFAutoreleasePoolPop + 49
3 Foundation 0x00007fff96992cb6 -[NSAutoreleasePool drain] + 152
4 AppKit 0x00007fff9138409b -[NSApplication run] + 892
5 AppKit 0x00007fff91306520 NSApplicationMain + 1175
6 RailModeller Pro 0x000000010b60578b main (main.m:30)
7 libdyld.dylib 0x00007fff9a36b5ad start + 0
..but no matter what I try,
even with the very same data,
following the exact same steps as the users,
same OS/patch level,
using Address Sanitizer (Xcode 7.3),
using Zombies instrument,
using Guard Malloc
all appears to be fine.
The function crashing is a pretty common one in the app and I'd be drowning in bug reports (both from the automated bug reporting system as well as users getting in touch) if this were a more common issue.
However, to these (<1%) users the app appears effectively unusable.
Any hints on how to track down this issue much appreciated!

Can't figure out "Unrecognized selector sent to instance" source

So I am at my wit's end on this, I am toggling some sharedprefs back and forth, and eventually it makes my app crash. I thought it was because I wasn't deallocating observers properly, but upon looking at the crash log it says that an unrecognized selector is sent to instance. Does anybody know more about crash logs that can tell me more about what's happening? I can get the basic gist of what's happening out of the log, but I'm still a rookie and a lot of the information is going over my head.
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType _adjustLengthDueToViewFrameChange:]: unrecognized selector sent to instance 0x608000095b80'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8fdcb25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff92afae75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8fdce12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8fd29272 ___forwarding___ + 1010
4 CoreFoundation 0x00007fff8fd28df8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x00007fff8fd99e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6 CoreFoundation 0x00007fff8fc8d82d _CFXNotificationPost + 2893
7 AppKit 0x00007fff915a4003 -[NSView _postFrameChangeNotification] + 434
8 AppKit 0x00007fff915ad6c2 -[NSView setFrameSize:] + 1586
9 AppKit 0x00007fff915ad049 -[NSView setFrame:] + 294
10 AppKit 0x00007fff915acc2b -[NSWindow setContentView:] + 453
11 AppKit 0x00007fff91beeace -[NSStatusItem setView:] + 224
12 MyAppHelper 0x00000001000775f5 -[NSStatusItem(BCStatusItem) setupView] + 85
13 MyAppHelper 0x000000010000cdbb -[MyAppHelperCapHelperServer createStatusBarItem] + 299
14 MyAppHelper 0x000000010000cf5b -[MyAppHelperCapHelperServer insertCaptureMenu] + 43
15 MyAppHelper 0x000000010000fe3d -[MyAppHelperHelperServer observeValueForKeyPath:ofObject:change:context:] + 733
16 Foundation 0x00007fff927e8f28 NSKeyValueNotifyObserver + 387
17 Foundation 0x00007fff927e80f8 NSKeyValueDidChange + 453
18 Foundation 0x00007fff927ecbe6 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 118
19 MyAppHelperHelper 0x0000000100109a3d __57-[RMSharedUserDefaults __applyBaselineAndNotify:updates:]_block_invoke + 349
20 CoreFoundation 0x00007fff8fd086df __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 111
21 CoreFoundation 0x00007fff8fd085ee -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 222
Primarily, I have no idea what it means in the exception information: [__NSCFType _adjustLengthDueToViewFrameChange:]. I cannot seem to find any information anywhere.
Thanks in advance!
First, I assume you are manually managing the memory, if so, I'll Highly recommend you to migrate to ARC (Automatic Reference Counting) it will manage the memory for you and you wont have this type or errors anymore. There are plenty of tutorials on Google of how to do this.
You can read more here: Transitioning to ARC Release Notes
Second, without ARC, this kind of error is often caused because you are calling a method/selector on an already released object, that's why the method/selector is not recognized.
This assuming you take care of clearing all the warnings on your project, if not, first go and check if there isn't a warning already pointing that you are trying to call a method/selector that doesn't exist for some object in your app. You can use the Analyze option as mentioned on the comments of this answer. To do that just Cmd+Shift+b, select the Analyze option from the Product Menu or Press and Hold the "Play" button you use to build the app and you will see the Analyze option as well.
Finally, I see you are using User Defaults. I'll recommend making sure you are retaining the values you are receiving from the User Defaults as they came with autorelease. This will explain why the compiler is not able to show the exact line of code where this error is happening, because it happens until the objet is autoreleased.
If is not the User Defaults I'll go and check all my autoreleased variables, is most likely that the problem is with one of them.

NSEvent charactersIgnoringModifiers randomly throws "TSMProcessRawKeyCode failed" exception

Our Mac cocos2d app (http://deepworldgame.com) has been randomly throwing "TSMProcessRawKeyCode failed" exceptions for some time now, and I'm wondering if anyone has experienced this error or knows how to prevent it.
It always happens via the [NSEvent charactersIgnoringModifiers] call within ccKeysDown or ccKeysUp (it also happens for [NSEvent characters] without the modifiers). I don't think it's related to specific keys. Sometimes it only happens one time and the app continues to function afterward (if the exception is caught), but other times it essentially locks up keyboard input indefinitely and continues to cause exceptions with all future keypresses (again, when these exceptions are caught).
I've found little on the internets regarding this issue, unfortunately. One place I did find was in the Adium source code (https://bitbucket.org/adium/adium/src/6d1f9b903525/Source/AIExceptionController.m), which catches this exception with the comments:
//Ignore various known harmless or unavoidable exceptions (From the system or system hacks)
...
// [TSMProcessRawKeyCode] May be raised by -[NSEvent charactersIgnoringModifiers]
It is indeed harmless when thrown once, but when the occasion happens that it continuously fires, it's a real problem - especially when you're in fullscreen mode and can't use cmd-F to escape!
So, if anyone has any thoughts or experience, I would be HIGHLY grateful. This is pretty much the one remaining superbug in our application, and I would love to squash it into dust.
Thanks!
Here is the typical stack trace (MacManager.m is our object which implements the cocos2d keyboard delegate protocol):
Crashed Thread: 7 CVDisplayLink
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Application Specific Information:
objc[28871]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'TSMProcessRawKeyCode failed (-192)'
*** Call stack at first throw:
(
0 CoreFoundation 0x95b27d87 __raiseError + 231
1 libobjc.A.dylib 0x9315a149 objc_exception_throw + 155
2 CoreFoundation 0x95a8f619 +[NSException raise:format:arguments:] + 137
3 CoreFoundation 0x95a8f589 +[NSException raise:format:] + 57
4 AppKit 0x9ac01c1f _convertEventRefToString + 300
5 AppKit 0x9ab23b5e -[NSEvent charactersIgnoringModifiers] + 880
6 Deepworld 0x0001fd8a -[MacManager ccKeyDown:] + 65
7 CoreFoundation 0x95a7d091 -[NSObject performSelector:withObject:] + 65
8 Deepworld 0x0006bc95 -[CCEventDispatcher keyDown:] + 80
9 CoreFoundation 0x95a7d091 -[NSObject performSelector:withObject:] + 65
10 Deepworld 0x0006c014 -[CCEventDispatcher dispatchQueuedEvents] + 143
11 Deepworld 0x0006a9a4 -[CCDirectorDisplayLink getFrameForTime:] + 155
12 Deepworld 0x0006aaf1 MyDisplayLinkCallback + 40
13 CoreVideo 0x9b44a5e1 _ZN13CVDisplayLink9performIOEP11CVTimeStamp + 489
14 CoreVideo 0x9b4494e4 _ZN13CVDisplayLink11runIOThreadEv + 876
15 CoreVideo 0x9b449161 _ZL13startIOThreadPv + 160
16 libsystem_c.dylib 0x968a4ed9 _pthread_start + 335
17 libsystem_c.dylib 0x968a86de thread_start + 34
)
I don't think sending events in general is thread-safe, not to mention from a thread that has been created not within +[NSThread detachNewThreadSelector:toTarget:withObject:] (a thread created using the Objective-C run-time has __NSThread__main__ in the backtrace).
I guess your app is the Deepworld binary part - when dispatching events, try using -[NSObject performSelectorOnMainThread:waitUntilDone:] instead, dispatching the events on the main thread.