5

私たちの Mac cocos2d アプリ (http://deepworldgame.com) は、しばらく前から「TSMProcessRawKeyCode に失敗しました」という例外をランダムにスローしていました。このエラーを経験したことがある人や、それを防ぐ方法を知っている人がいるのだろうかと思っています。

これは常に、ccKeysDown または ccKeysUp 内の [NSEvent charactersIgnoringModifiers] 呼び出しを介して発生します (修飾子のない [NSEvent characters] でも発生します)。特定のキーとは関係ないと思います。場合によっては、1 回だけ発生し、アプリはその後も機能し続けます (例外がキャッチされた場合) が、基本的にキーボード入力が無期限にロックされ、以降のすべてのキー押下で例外が発生し続ける場合もあります (これらの例外がキャッチされた場合)。

残念ながら、この問題に関するインターネット上の情報はほとんど見つかりませんでした。私が見つけた場所の 1 つは、Adium ソース コード (https://bitbucket.org/adium/adium/src/6d1f9b903525/Source/AIExceptionController.m) で、この例外をコメントでキャッチします。

//Ignore various known harmless or unavoidable exceptions (From the system or system hacks) 
...
// [TSMProcessRawKeyCode] May be raised by -[NSEvent charactersIgnoringModifiers]

一度投げられると確かに無害ですが、連続して発火する機会が発生すると、それは本当の問題です-特にフルスクリーンモードでcmd-Fを使用して逃げることができない場合!

だから、誰かが何か考えや経験を持っているなら、私は非常に感謝しています. これは、私たちのアプリケーションに残っている唯一のスーパーバグです。

ありがとう!

以下は典型的なスタック トレースです (MacManager.m は、cocos2d キーボード デリゲート プロトコルを実装するオブジェクトです)。

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
)
4

1 に答える 1

3

+[NSThread detachNewThreadSelector:toTarget:withObject:] (Objective-C ランタイムを使用して作成されたスレッドには __NSThread__main__バックトレースで)。

あなたのアプリは Deepworld バイナリ部分だと思います-イベントをディスパッチするときは、代わりに -[NSObject performSelectorOnMainThread:waitUntilDone:] を使用して、メインスレッドでイベントをディスパッチしてみてください。

于 2012-11-20T22:46:57.170 に答える