我有几个崩溃报告Collection <__NSArrayM: 0x12345678> was mutated while being enumerated.
但是在我的测试中我无法重现该错误。
当我转换到不同的 SKView 时,这似乎是通过一系列事件触发的。
[UIView transitionWithView:window
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[UIView setAnimationsEnabled:NO];
[fromView removeFromSuperview];
[window addSubview:toView];
window.rootViewController = nextViewController;
[UIView setAnimationsEnabled:YES];
}
completion:NULL];
我已经读过,当您在枚举子节点期间从其父节点中删除节点时可能会发生此错误,但我不相信我在这里这样做,并且下面的完整堆栈跟踪似乎也没有表明它。
我不知道为什么[SKNode setPaused:]
会导致添加或删除子节点,而且似乎也没有任何迹象表明其他线程中会发生这种情况。
完整的堆栈跟踪
0 CoreFoundation 0x2f896fd3 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x3a37bccf objc_exception_throw + 36
2 CoreFoundation 0x2f896ad1 __NSFastEnumerationMutationHandler + 126
3 SpriteKit 0x31fb926b -[SKNode setPaused:] + 792
4 SpriteKit 0x31f95309 -[SKScene setPaused:] + 134
5 SpriteKit 0x31fa7b63 -[SKView renderCallback:] + 648
6 SpriteKit 0x31fa9301 -[SKView layoutSubviews] + 474
7 UIKit 0x320b2d79 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 378
8 QuartzCore 0x31d3062b -[CALayer layoutSublayers] + 140
9 QuartzCore 0x31d2be3b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 348
10 QuartzCore 0x31d5acdd -[CALayer layoutIfNeeded] + 138
11 UIKit 0x3212f183 -[UIViewController window:setupWithInterfaceOrientation:] + 240
12 UIKit 0x3212d7a3 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3496
13 UIKit 0x3212c9f3 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 44
14 UIKit 0x3212c97b -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 92
15 UIKit 0x3212c913 -[UIWindow _setRotatableViewOrientation:duration:force:] + 40
16 UIKit 0x32124f89 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 106
17 UIKit 0x320b9127 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 380
18 UIKit 0x3212c661 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 694
19 UIKit 0x3212c125 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 162
20 UIKit 0x320be065 -[UIWindow addRootViewControllerViewIfPossible] + 458
21 UIKit 0x32124133 -[UIWindow setRootViewController:] + 760
22 the-app 0x000baf0d 0x000b2000 + 36621
23 UIKit 0x320e83c5 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 494
24 UIKit 0x3234c3f9 +[UIView(UIViewAnimationWithBlocks) transitionWithView:duration:options:animations:completion:] + 58
25 the-app 0x000bae67 0x000b2000 + 36455
26 the-app 0x000bacf7 0x000b2000 + 36087
27 UIKit 0x320e8057 -[UIApplication sendAction:to:from:forEvent:] + 88
28 UIKit 0x320e7ff7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 28
29 UIKit 0x320e7fd1 -[UIControl sendAction:to:forEvent:] + 42
30 UIKit 0x320d3737 -[UIControl _sendActionsForEvents:withEvent:] + 372
31 UIKit 0x320e7a4f -[UIControl touchesEnded:withEvent:] + 588
32 UIKit 0x320e7721 -[UIWindow _sendTouchesForEvent:] + 526
33 UIKit 0x320e26eb -[UIWindow sendEvent:] + 756
34 UIKit 0x320b78ed -[UIApplication sendEvent:] + 194
35 UIKit 0x320b5f97 _UIApplicationHandleEventQueue + 7100
36 CoreFoundation 0x2f86225b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
37 CoreFoundation 0x2f86172b __CFRunLoopDoSources0 + 204
38 CoreFoundation 0x2f85ff1f __CFRunLoopRun + 620
39 CoreFoundation 0x2f7caf0f CFRunLoopRunSpecific + 520
40 CoreFoundation 0x2f7cacf3 CFRunLoopRunInMode + 104
41 GraphicsServices 0x346c4663 GSEventRunModal + 136
42 UIKit 0x3211616d UIApplicationMain + 1134
43 the-app 0x000b9267 0x000b2000 + 29287
44 libdyld.dylib 0x3a888ab7 start + 0