The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Game Center & Yosemite
campbelljc


Joined: 13 Sep 2015
Posts: 2
I am trying to get Game Center working under SDL in Yosemite. Specifically, to display the achievements window. My code (below) worked fine under Mavericks, but I am pretty sure that it was when Yosemite came out that the code no longer worked properly. Game Center will still authenticate on program launch, but when I open the achievements window, it displays for 1-2 seconds before the program crashes with the error "not running on main (AppKit) thread". Has anyone gotten this error under Yosemite?

It seems like a pretty basic error, unfortunately I am not quite sure how to fix it...

Error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'not running on AppKit (main) thread'.
Assertion failure in void assertRunningOnAppKitThread()(), /SourceCache/ViewBridge/ViewBridge-105/ViewBridgeUtilities.m:535
An uncaught exception was raised
not running on AppKit (main) thread

Code for launching window:

Code:
@implementation GameCenterManager

NSWindow* keyWindow__;
- (void)showAchievementView
{
   keyWindow__ = [NSApp keyWindow];
   
   GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc] init];
   gcViewController.viewState = GKGameCenterViewControllerStateAchievements;
   gcViewController.gameCenterDelegate = self;

   GKDialogController *sdc = [GKDialogController sharedDialogController];
   sdc.parentWindow = keyWindow__;
   [sdc presentViewController: gcViewController];
}

- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
{
   GKDialogController *sdc = [GKDialogController sharedDialogController];
   [sdc dismiss: self];
   [keyWindow__ makeKeyWindow];
}

@end


And this is in the crash log, which I believe shows that some part of Game Center is running in a separate thread from the main one which might be causing the problem, but not sure how to fix that:

Code:
 
Thread 0:: Dispatch queue: com.apple.main-thread
0   com.apple.QuartzCore             0x00007fff97103096 CA::Layer::layout_if_needed(CA::Transaction*) + 524
1   com.apple.QuartzCore             0x00007fff97102e76 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
2   com.apple.QuartzCore             0x00007fff97102612 CA::Context::commit_transaction(CA::Transaction*) + 242
3   com.apple.QuartzCore             0x00007fff971023ae CA::Transaction::commit() + 390
4   com.apple.QuartzCore             0x00007fff97110f19 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 71
5   com.apple.CoreFoundation         0x00007fff92c18127 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
6   com.apple.CoreFoundation         0x00007fff92c18080 __CFRunLoopDoObservers + 368
7   com.apple.CoreFoundation         0x00007fff92c09bf8 CFRunLoopRunSpecific + 328
8   com.apple.HIToolbox              0x00007fff8e81456f RunCurrentEventLoopInMode + 235
9   com.apple.HIToolbox              0x00007fff8e8141ee ReceiveNextEventCommon + 179
10  com.apple.HIToolbox              0x00007fff8e81412b _BlockUntilNextEventMatchingListInModeWithFilter + 71
11  com.apple.AppKit                 0x00007fff99da78ab _DPSNextEvent + 978
12  com.apple.AppKit                 0x00007fff99da6e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
13  org.libsdl.SDL2                  0x0000000100b1cf18 Cocoa_PumpEvents + 264 (SDL_cocoaevents.m:376)
14  org.libsdl.SDL2                  0x0000000100b02140 SDL_PumpEvents_REAL + 48 (SDL_events.c:405)
15  org.libsdl.SDL2                  0x0000000100b021d8 SDL_WaitEventTimeout_REAL + 56 (SDL_events.c:437)
16  org.libsdl.SDL2                  0x0000000100b02197 SDL_PollEvent_REAL + 23 (SDL_events.c:418)
17  org.libsdl.SDL2                  0x0000000100bd4974 SDL_PollEvent + 36 (SDL_dynapi_procs.h:157)
18  com.company.name                    0x000000010013d717 C_Screen::frame() + 135
19  com.company.name                    0x00000001001452f0 C_UI::start() + 64
20  com.company.name                    0x000000010000828c C_Game::start() + 28
21  com.company.name                    0x000000010000743c main + 684
22  com.company.name                    0x0000000100007184 start + 52

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib           0x00007fff97d3b232 kevent64 + 10
1   libdispatch.dylib                0x00007fff8d588a6a _dispatch_mgr_thread + 52

Thread 2:
0   libsystem_kernel.dylib           0x00007fff97d3a94a __workq_kernreturn + 10
1   libsystem_pthread.dylib          0x00007fff96e8d3dd start_wqthread + 13

...

Thread 8 Crashed:: Dispatch queue: com.apple.root.utility-qos
0   libsystem_kernel.dylib           0x00007fff97d3a286 __pthread_kill + 10
1   libsystem_c.dylib                0x00007fff8fce99b3 abort + 129
2   libc++abi.dylib                  0x00007fff8c36aa21 abort_message + 257
3   libc++abi.dylib                  0x00007fff8c3929d1 default_terminate_handler() + 267
4   libobjc.A.dylib                  0x00007fff967937d6 _objc_terminate() + 103
5   libc++abi.dylib                  0x00007fff8c3900a1 std::__terminate(void (*)()) + 8
6   libc++abi.dylib                  0x00007fff8c390113 std::terminate() + 51
7   libobjc.A.dylib                  0x00007fff967935ff objc_terminate + 9
8   libdispatch.dylib                0x00007fff8d585c27 _dispatch_client_callout + 28
9   libdispatch.dylib                0x00007fff8d58888f _dispatch_root_queue_drain + 935
10  libdispatch.dylib                0x00007fff8d596fe4 _dispatch_worker_thread3 + 91
11  libsystem_pthread.dylib          0x00007fff96e8fa9d _pthread_wqthread + 729
12  libsystem_pthread.dylib          0x00007fff96e8d3dd start_wqthread + 13