gpt4 book ai didi

swift - 应用程序崩溃并显示 EXC_BAD_ACCESS(代码 = 1,地址 = 0x0)

转载 作者:行者123 更新时间:2023-11-30 14:02:19 26 4
gpt4 key购买 nike

我知道有很多这样的问题,所以我尝试提供尽可能多的细节。我用 SpriteKit 开发了游戏和几个场景。当我从一个场景转换到另一个场景时,我收到 EXC_BAD_ACCESS(code = 1,address = 0x0)

使用 bt 我有这个:

(lldb) bt
* thread #1: tid = 0x70119f, 0x0000000107e173b0 libsystem_platform.dylib`_platform_memmove$VARIANT$Nehalem + 112, queue = 'com.apple.spritekit.renderQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000107e173b0 libsystem_platform.dylib`_platform_memmove$VARIANT$Nehalem + 112
frame #1: 0x0000000103c4ce8c SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 1156
frame #2: 0x0000000103c4d9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #3: 0x0000000103c4d9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #4: 0x0000000103c4d9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #5: 0x0000000103c46da1 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&) + 139
frame #6: 0x0000000103c4a951 SpriteKit`SKCRenderer::submitScene(SKScene*, bool) + 393
frame #7: 0x0000000103c4853c SpriteKit`SKCRenderer::renderTransition(SKScene*, SKScene*, float) + 952
frame #8: 0x0000000103be6ece SpriteKit`-[SKView _renderContent] + 847
frame #9: 0x0000000107abd614 libdispatch.dylib`_dispatch_client_callout + 8
frame #10: 0x0000000107aa3002 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 365
frame #11: 0x0000000103be6a80 SpriteKit`-[SKView renderContent] + 96
frame #12: 0x0000000103be3a61 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 56
frame #13: 0x0000000103c0f744 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 256
frame #14: 0x00000001068a310f QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 37
frame #15: 0x00000001068a2fd7 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 315
frame #16: 0x0000000102f9c174 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
frame #17: 0x0000000102f9bd35 CoreFoundation`__CFRunLoopDoTimer + 1045
frame #18: 0x0000000102f5dd3d CoreFoundation`__CFRunLoopRun + 1901
frame #19: 0x0000000102f5d366 CoreFoundation`CFRunLoopRunSpecific + 470
frame #20: 0x0000000106e88a3e GraphicsServices`GSEventRunModal + 161
frame #21: 0x0000000103d808c0 UIKit`UIApplicationMain + 1282
* frame #22: 0x0000000102a0628d MemoryGame`main + 109 at AppDelegate.swift:15
frame #23: 0x0000000107af1145 libdyld.dylib`start + 1
(lldb)

也许这很重要:在下一个场景中didMoveToView我预加载纹理(几个 map 集)。

更新#1

我启用了地址清理程序,现在它在其中崩溃了:

(lldb) bt
* thread #1: tid = 0x705cf2, 0x000000010e36c0b0 libclang_rt.asan_iossim_dynamic.dylib`__sanitizer::internal_memmove(void*, void const*, unsigned long) + 320, queue = 'com.apple.spritekit.renderQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x460)
* frame #0: 0x000000010e36c0b0 libclang_rt.asan_iossim_dynamic.dylib`__sanitizer::internal_memmove(void*, void const*, unsigned long) + 320
frame #1: 0x000000010e3505a7 libclang_rt.asan_iossim_dynamic.dylib`wrap_memcpy + 1095
frame #2: 0x0000000110119e8c SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 1156
frame #3: 0x000000011011a9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #4: 0x000000011011a9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #5: 0x000000011011a9a9 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) + 4001
frame #6: 0x0000000110113da1 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&) + 139
frame #7: 0x0000000110117951 SpriteKit`SKCRenderer::submitScene(SKScene*, bool) + 393
frame #8: 0x000000011011553c SpriteKit`SKCRenderer::renderTransition(SKScene*, SKScene*, float) + 952
frame #9: 0x00000001100b3ece SpriteKit`-[SKView _renderContent] + 847
frame #10: 0x0000000113f8a614 libdispatch.dylib`_dispatch_client_callout + 8
frame #11: 0x0000000113f70002 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 365
frame #12: 0x00000001100b3a80 SpriteKit`-[SKView renderContent] + 96
frame #13: 0x00000001100b0a61 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 56
frame #14: 0x00000001100dc744 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 256
frame #15: 0x0000000112d7010f QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 37
frame #16: 0x0000000112d6ffd7 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 315
frame #17: 0x000000010f469174 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
frame #18: 0x000000010f468d35 CoreFoundation`__CFRunLoopDoTimer + 1045
frame #19: 0x000000010f42ad3d CoreFoundation`__CFRunLoopRun + 1901
frame #20: 0x000000010f42a366 CoreFoundation`CFRunLoopRunSpecific + 470
frame #21: 0x0000000113355a3e GraphicsServices`GSEventRunModal + 161
frame #22: 0x000000011024d8c0 UIKit`UIApplicationMain + 1282
frame #23: 0x000000010e1a928d MemoryGame`main + 109 at AppDelegate.swift:15
frame #24: 0x0000000113fbe145 libdyld.dylib`start + 1
frame #25: 0x0000000113fbe145 libdyld.dylib`start + 1
(lldb)

最佳答案

您添加particleEmitter吗?到第一个场景?您使用 .targetNode的属性(property)particleEmitter

如果是这样,我也遇到了同样的问题。 SpriteKit 中似乎存在一个错误,需要您手动设置 .targetNode属性至nil在改变场景之前。试试particleEmitter?.targetNode = nildeinit函数或类似...

就我而言,我使用了 targetNode只是为了使发射器的粒子出现在背景顶部,但您可以使用 .zPosition 获得相同的行为和.particleZPosition发射器的属性(我将这两个属性设置为高于背景对象的 .zPosition 的数字),从而避免使用 targetNode .

希望这对您有帮助。

关于swift - 应用程序崩溃并显示 EXC_BAD_ACCESS(代码 = 1,地址 = 0x0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32849474/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com