gpt4 book ai didi

ios - Corona SDK 应用程序异常退出,信号为 10 : Bus Error: 10. 设备崩溃

转载 作者:行者123 更新时间:2023-11-29 12:50:22 30 4
gpt4 key购买 nike

我有一个应用程序在 Corona 模拟器中运行良好,但在设备本身上崩溃,并且它在 iOS 设备控制台中返回以下错误:

Mar 20 22:56:26 tmacs-iPhone backboardd[28] <Warning>: Application 'UIKitApplication:HappyShaker[0x9cf9]' exited abnormally with signal 10: Bus error: 10
Mar 20 22:56:26 tmacs-iPhone backboardd[28] <Warning>: BKSendGSEvent ERROR sending event type 23: (ipc/send) invalid destination port (0x10000003)

根据我的研究,我发现这个错误是由这两个问题引起的:

  1. Accessing memory that doesn't exist
  2. Accessing memory that isn't aligned on a 4 or 8 byte boundary

根据 Corona 的运作方式,这很可能是第一个原因。

在调试过程中,我发现了一些可以缩小问题搜索范围的东西。

下面所述的代码会导致应用程序崩溃。这是一个启动物理、设置其比例、添加物理对象、启动计时器以及在按下按钮后移除按钮的按钮。它有点初始化物理。

local playButton = nil
local function handleButtonEvent( event )
if "ended" == event.phase then
physics.start()
physics.setScale(60)
physics.addBody( red, "dynamic",redBody )
physics.addBody( borderTop, "static", borderBodyElement )
physics.addBody( borderBottom, "static", borderBodyElement )
physics.addBody( borderLeft, "static", borderBodyElement )
physics.addBody( borderRight, "static", borderBodyElement )
timer.performWithDelay(1000, fn_counter, number)
playButton:removeSelf()
playButton = nil
end
return true
end
playButton = widget.newButton {
left = _W/2-53,
top = 400,
width = 105,
height = 39,
defaultFile = "start.png",
overFile = "start_pressed.png",
label = "",
onEvent = handleButtonEvent,
}
playButton.isActive = true
group:insert(playButton)

当我注释掉代码的按钮小部件部分时,它工作正常并且不会崩溃。被注释掉的部分在下面的代码中说明。

    -- local playButton = nil
-- local function handleButtonEvent( event )
-- if "ended" == event.phase then
physics.start()
physics.setScale(60)
physics.addBody( red, "dynamic",redBody )
physics.addBody( borderTop, "static", borderBodyElement )
physics.addBody( borderBottom, "static", borderBodyElement )
physics.addBody( borderLeft, "static", borderBodyElement )
physics.addBody( borderRight, "static", borderBodyElement )
timer.performWithDelay(1000, fn_counter, number)
-- playButton:removeSelf()
-- playButton = nil
-- end
-- return true
-- end
-- playButton = widget.newButton {
-- left = _W/2-53,
-- top = 400,
-- width = 105,
-- height = 39,
-- defaultFile = "start.png",
-- overFile = "start_pressed.png",
-- label = "",
-- onEvent = handleButtonEvent,
-- }
-- playButton.isActive = true
-- group:insert(playButton)

以前有人在使用按钮小部件时遇到过这个问题吗?

我还应该提到这段代码位于 Storyboard的 createScene() 函数中。

最佳答案

我找到了解决方案。它与 physics.start() 在监听器函数内部有关。我做了以下调整:

physics.start()
physics.setScale( 60 )
physics.addBody( borderTop, "static", borderBodyElement )
physics.addBody( borderBottom, "static", borderBodyElement )
physics.addBody( borderLeft, "static", borderBodyElement )
physics.addBody( borderRight, "static", borderBodyElement )

-- local startButton = nil
local function handleButtonEvent( event )
if "ended" == event.phase then

physics.addBody( red, "dynamic",redBody )
timer.performWithDelay(1000, fn_counter, number)
startButton:removeSelf()
startButton = nil
end
return true
end

通过将 physics.start() 函数放置在监听器事件函数之外使其工作。但是,我仍然对为什么这会导致段错误感到困惑。谁能给我解释一下?

关于ios - Corona SDK 应用程序异常退出,信号为 10 : Bus Error: 10. 设备崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22554607/

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