Uiview SpriteKit在转换WithView时崩溃

Uiview SpriteKit在转换WithView时崩溃,uiview,sprite-kit,uiviewanimationtransition,skview,Uiview,Sprite Kit,Uiviewanimationtransition,Skview,我有几个崩溃报告,集合在枚举时发生了变异。然而,在我的测试中,我无法重现错误 当我转换到另一个视图时,这似乎是通过一系列事件触发的 [UIView transitionWithView:window duration:0.8 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{

我有几个崩溃报告,集合在枚举时发生了变异。然而,在我的测试中,我无法重现错误

当我转换到另一个视图时,这似乎是通过一系列事件触发的

[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:]会导致子节点被添加或删除,而且在其他线程中似乎也没有发生这种情况的迹象

全堆栈跟踪


可能没有什么帮助,但我怀疑[SKNode setPaused:]正在发现变异状态,而不是导致它。我会从其他代码片段中查找在该场景中添加/删除节点的任何内容。这是逻辑结论,我查看了所有addChild:调用。在回调[SKTextureAtlas Preload WithCompletionHandler:]期间,我似乎在调用addChild:,而[SKTextureAtlas Preload WithCompletionHandler:]似乎没有在主线程上运行。我已经更改了代码,将addChild:调用分派到主线程,所以现在只有时间会告诉我们这是否解决了问题。
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