EXC_BAD_ACCESS after upgrading to iOS8 SpriteKit g

2019-02-26 05:34发布

SpriteKit game crashes with EXC_BAD_ACCESS after upgrading to iOS8. Happens at random time, for no apparent reason, after playing a while. Exception breakpoint, as well as enabling NSZombie detection in Allocations/Instruments doesn't give any information, so I can't detect the line in my code that causes the error.

Here is the backtrace:

* thread #1: tid = 0x5d267, 0x2fd7c760 SpriteKit`SKCSprite::update(double) + 328, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc)
frame #0: 0x2fd7c760 SpriteKit`SKCSprite::update(double) + 328
frame #1: 0x2fd2cec8 SpriteKit`-[SKScene _update:] + 200
frame #2: 0x2fd4a8ae SpriteKit`-[SKView(Private) _update:] + 686
frame #3: 0x2fd47a44 SpriteKit`-[SKView renderCallback:] + 748
frame #4: 0x2fd4485c SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 116
frame #5: 0x2fd75fcc SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 248
frame #6: 0x2f91ad7a QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 98
frame #7: 0x2f91abe2 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 366
frame #8: 0x341ca82e IOMobileFramebuffer`IOMobileFramebufferVsyncNotifyFunc + 90
frame #9: 0x2d94a51c IOKit`IODispatchCalloutFromCFMessage + 256
frame #10: 0x2c9dcbe4 CoreFoundation`__CFMachPortPerform + 132
frame #11: 0x2c9ed022 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #12: 0x2c9ecfbe CoreFoundation`__CFRunLoopDoSource1 + 346
frame #13: 0x2c9eb5e0 CoreFoundation`__CFRunLoopRun + 1608
frame #14: 0x2c938db0 CoreFoundation`CFRunLoopRunSpecific + 476
frame #15: 0x2c938bc2 CoreFoundation`CFRunLoopRunInMode + 106
frame #16: 0x33cc4050 GraphicsServices`GSEventRunModal + 136
frame #17: 0x2ff04a30 UIKit`UIApplicationMain + 1440
* frame #18: 0x001073cc p01g01`main(argc=1, argv=0x00456bd4) + 116 at main.m:16

Apparently, the issue is somehow linked to SpriteKit.

On iOS7, though, game works without any problems.

Is there any other method to locate and eliminate the problem?

2条回答
爷的心禁止访问
2楼-- · 2019-02-26 05:53

So, apparently the problem was in removeFromParent.

After changing:

SKAction *remove = [SKAction removeFromParent];
[self runAction:[SKAction sequence:@[wait, remove]]];

to:

[self runAction:wait completion:^{
    [self removeFromParent];
}];

the error has gone, but another one appeared:

SpriteKit`SKCShapeSprite::getAccumulatedBounds()

Please head to SpriteKit: EXC_BAD_ACCESS SpriteKit`SKCShapeSprite::getAccumulatedBounds() crash for details.

UPDATE: It turned out that I got ahead of myself: error popped up again after several hours. Now I have two kinds of unsolvable issues, and thinking of rewriting the game from the ground up specifically for iOS8.

查看更多
老娘就宠你
3楼-- · 2019-02-26 06:00

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.

查看更多
登录 后发表回答