3

We have an iOS game on the AppStore and some users are reporting problems since they've upgraded to iOS 7. We've updated the game to work on iOS 7 and have tested it extensively with several devices. However, we have some users reporting crashes, sometimes in the exact same devices we've tested and re tested the game on. The crash log, after being symbolicated, reads as follows:

Thread 0 Crashed:
0   CoreGraphics                    0x2d4ec9ca CGColorSpaceGetModel + 10
1   QuartzCore                      0x2f893842 CA_CGColorGetRGBComponents + 30
2   QuartzCore                      0x2f95a142 -[NSObject(CAAnimatableValue) CA_distanceToValue:] + 86
3   UIKit                           0x2fe10c72 _UIViewLayerAnimationCanBeConsideredFinished + 250
4   UIKit                           0x2fe10ae2 __22-[UIWindow sendEvent:]_block_invoke + 10
5   CoreFoundation                  0x2d3c4022 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 50
6   CoreFoundation                  0x2d3bda0a -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 218
7   UIKit                           0x2fc1b556 -[UIWindow sendEvent:] + 522
8   UIKit                           0x2fbf0a20 -[UIApplication sendEvent:] + 192
9   UIKit                           0x2fbef21c _UIApplicationHandleEventQueue + 7092
10  CoreFoundation                  0x2d446188 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
11  CoreFoundation                  0x2d445656 __CFRunLoopDoSources0 + 202
12  CoreFoundation                  0x2d443e4a __CFRunLoopRun + 618
13  CoreFoundation                  0x2d3aece2 CFRunLoopRunSpecific + 518
14  CoreFoundation                  0x2d3aeac6 CFRunLoopRunInMode + 102
15  GraphicsServices                0x320cf27e GSEventRunModal + 134
16  UIKit                           0x2fc50a3c UIApplicationMain + 1132
17  MyGame                          0x00104382 main (main.m:13)
18  MyGame                          0x0010435c ___lldb_unnamed_function455$$MyGame + 36

I have absolutely no idea where to go from here, any suggestions will be greatly appreciated.

4

3 回答 3

1

我建议这是问题所在

5 CoreFoundation 0x2d3c4022 __53- [__NSArrayI enumerateObjectsWithOptions:usingBlock:] _block_invoke + 50

我将块枚举器用于交错动画,它导致我的应用程序崩溃,并显示消息“

[UIViewAnimationState release]:消息发送到已释放的实例

我正在使用 ARC 和静态方法调用,所以不知道为什么会这样。

但是,将此循环更改为 foreach 样式循环解决了该问题。块内的块在 iOS5 和 6 中运行良好,但给出了奇怪的结果,然后在 iOS7 中崩溃

于 2013-10-03T19:05:26.080 回答
1

There are some things missing from your crash report, mainly the exception (deallocated instance? missing selector?), however we can still deduce some things:

[UIWindow sendEvent:]

This is a call coming from event handling, probably a touch made by the user.

I guess the UIKit code then checks if the event can be delireved by checking whether there is some active animation _UIViewLayerAnimationCanBeConsideredFinished.

I am also guessing it's some animation in the window layer. Are you creating your own windows or adding views directly to UIWindow? Or maybe changing the root view controllers with an animation?

Anyway, go to try touching the screen during animations, always trying both the view the is appearing and the view that is dissappearing.

于 2013-10-03T19:19:01.637 回答
0

enumerateObjectsWithOptions:usingBlock 使用后台线程。如果这些后台线程之一确实在 GUI 对象上工作(当然动画也算在内),它将崩溃。

当崩溃发生时,转到 Xcode 的左侧并选择调试导航器。您很可能会在线程 x 不相等的线程 1 中看到崩溃。仅允许作为 GUI 线程的线程 1 使用 GUI。

要解决您的问题,您至少有两种选择:

a) 将您所做的动画 GUI 工作放在 dispatch_async 或 dispatch_sync 块中,例如

    …enumerateObjectsWithOptions:usingBlock … {

        // non GUI stuff    

        dispatch_async(dispatch_get_main_queue(), ^{ 
            // GUI work
            // non GUI stuff is also okay here
        });

        // non GUI stuff  

} // end of enumerateObjectsUsingBlock  

b) 使用快速枚举而不是 enumerateObjectsWithOptions:usingBlock 并以这种方式避免后台线程。

我猜 iOS 7 使用了更多的内部线程,也许 iOS 6 无法在这些调用中使用后台线程,因此在 6 上并没有在 7 上造成问题。

玩得开心!

于 2013-12-13T10:52:42.020 回答