本文介绍了SpriteKit:EXC_BAD_ACCESS SpriteKit`SKCShapeSprite :: getAccumulatedBounds()崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到iOS8后,SpriteKit游戏因EXC_BAD_ACCESS而崩溃。在经过一段时间后,在随机时间发生这种情况是没有明显原因的。没有来自异常断点和NSZombie检测的信息,因此无法检测导致错误的代码中的行。
在模拟器和设备上都进行了检查。

After upgrading to iOS8, SpriteKit game crashes with EXC_BAD_ACCESS. It happens for no apparent reason, after playing a bit, at random time. No info from Exception breakpoint and NSZombie detection, so no way to detect the line in the code that causes the error.Checked both on a simulator and a device.

回溯:

* thread #1: tid = 0x13fa2, 0x2b3977f0 SpriteKit`SKCShapeSprite::getAccumulatedBounds() const + 84, queue = 'com.apple.spritekit.renderQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x11)
frame #0: 0x2b3977f0 SpriteKit`SKCShapeSprite::getAccumulatedBounds() const + 84
frame #1: 0x2b3e3086 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 1030
frame #2: 0x2b3e39b4 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 3380
frame #3: 0x2b3ddbe2 SpriteKit`SKCRenderer::preprocessAndSubmitSpriteInternal(std::__1::vector<SKCRenderer::SpriteRenderInfo const*, std::__1::allocator<SKCRenderer::SpriteRenderInfo const*> >&, std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&) + 94
frame #4: 0x2b3e29be SpriteKit`SKCRenderer::preprocessAndSubmitSprite(SKCSprite const*, _GLKMatrix4 const&) + 154
frame #5: 0x2b3e0b32 SpriteKit`SKCRenderer::submitScene(SKScene*, bool) + 530
frame #6: 0x2b3e4b98 SpriteKit`SKCRenderer::renderScene(SKScene*, bool) + 152
frame #7: 0x2b37bf4a SpriteKit`-[SKView _renderContent] + 1098
frame #8: 0x00683abe libdispatch.dylib`_dispatch_client_callout + 22
frame #9: 0x0068b270 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 96
frame #10: 0x2b37bad2 SpriteKit`-[SKView renderContent] + 82
frame #11: 0x2b37885c SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 116
frame #12: 0x2b3a9fcc SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 248
frame #13: 0x005e61b6 libglInterpose.dylib`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 270
frame #14: 0x2af4ed7a QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 98
frame #15: 0x2af4ebe2 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 366
frame #16: 0x2f7fe82e IOMobileFramebuffer`IOMobileFramebufferVsyncNotifyFunc + 90
frame #17: 0x28f7e51c IOKit`IODispatchCalloutFromCFMessage + 256
frame #18: 0x28010be4 CoreFoundation`__CFMachPortPerform + 132
frame #19: 0x28021022 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #20: 0x28020fbe CoreFoundation`__CFRunLoopDoSource1 + 346
frame #21: 0x2801f5e0 CoreFoundation`__CFRunLoopRun + 1608
frame #22: 0x27f6cdb0 CoreFoundation`CFRunLoopRunSpecific + 476
frame #23: 0x27f6cbc2 CoreFoundation`CFRunLoopRunInMode + 106
frame #24: 0x2f2f8050 GraphicsServices`GSEventRunModal + 136
frame #25: 0x2b538a30 UIKit`UIApplicationMain + 1440
* frame #26: 0x000b4f2c p01g01`main(argc=1, argv=0x00418a84) + 116 at main.m:16

此错误仅在我解决 removeFromParent 问题后才出现,导致 SpriteKit'SKCSprite :: update(double)。前往此处参考:

This error appeared only after I solved removeFromParent issue that caused SpriteKit'SKCSprite::update(double). Head here for the reference: EXC_BAD_ACCESS after upgrading to iOS8 SpriteKit game

任何建议都将不胜感激!

Any suggestions will be appreciated!

推荐答案

通过为名称设置唯一名称来尝试此操作属性。某种程度上对我有用。

Try this by setting a unique name for the name property. Somehow worked for me.

static NSInteger count = 0;

@interface Power ()

- (instancetype)init
{
    if (self = [super init]) {
        count++;
        self.name = @(count).stringValue;
    } return self
}

@end

注意对象不止一次解除分配。也许是因为无法将一个对象区分为同一类型的另一个对象。

Notice the objects were deallocating more than once. Maybe because wasn't able to distinguish one object to another of the same type.

这篇关于SpriteKit:EXC_BAD_ACCESS SpriteKit`SKCShapeSprite :: getAccumulatedBounds()崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:39