应用程序在 Xcode 中运行良好,但从主屏幕加载时崩溃

发布于 2024-11-30 00:49:17 字数 538 浏览 3 评论 0原文

正如标题所示,我有一个应用程序,从 Xcode 启动时运行良好,但从主屏幕启动时崩溃。

运行构建和分析显示没有内存泄漏或警告。 (不过,我并不排除它是一种错误的安全感。)

相应的设备日志显示:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0439e000

这让我认为这是一个释放/保留问题,但为什么它没有出现在构建/分析中?为什么从 Xcode 运行时它会运行良好?

编辑

我还应该注意到,应用程序在模拟器中从 Xcode 和主屏幕启动都“运行良好”。我说“运行”,因为它使用相机,所以在这种情况下在模拟器上运行并不是很有用。


UPDATE

谢谢大家。所有资源似乎都被正确命名。我正在尝试让 atos 命令正常工作。我不断得到相同的地址,而不是类文件名和行号。

As the title suggests, I have an app that runs fine when launched from Xcode, but crashes when launched from the home screen.

Running build and analyze shows no memory leaks or warnings. (Although, I'm not ruling it out as a false sense of security.)

The corresponding Device Log shows:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0439e000

Which makes me think this is a release/retain issue, but why didn't it show up in Build/Analyze? And why would it run fine when running from Xcode?

EDIT

I should also note that the app "runs" fine in the simulator both from Xcode and from a home screen launch. I say "runs," because it uses the camera, so running on the simulator isn't all that useful in this case.


UPDATE

Thanks, all. All resources seem to be properly named. I'm trying to get the atos command to work properly. I keep getting the same address back instead of the class file name and line number.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独享拥抱 2024-12-07 00:49:17

有时(也许在您的情况下)当应用程序首次从 XCode 启动时,它会作为应用程序的新实例进行构建和运行。当您停止它并尝试从主屏幕运行它时,它可能会从后台启动。如果您在应用程序从后台启动时没有正确管理内存,则分析器将不会发现内存问题。
要查明是否是这种情况,请尝试双击主页按钮并退出您的应用程序(如果出现该按钮)。然后从主屏幕再次启动它。您也可以尝试使用仪器进行调试。

Sometimes (maybe in your case) when an app is first launched from the XCode it is build and run as a new instance of the application. When you then stopp it and try to run it from the home screen it might launch from background. If you didn't manage your memory properly for a state when your app launches from the background the analyzer will not pick up memory problems.
To find out if that is the case, try to double click on the home button and quit your app if it appears there. Then launch it again from the home screen. You can also try to debug it with the instruments.

日裸衫吸 2024-12-07 00:49:17

忘记阿托斯。我意识到设备日志列出了崩溃发生的线程、文件和行号。它始终在我的 AVCaptureSession 委托 captureOutput 方法中。

当“拔掉插头”运行时,我得到的 CVPixelBufferGetBaseAddress 值大约高出 200 倍。我还发现,当我在其中一个循环中运行简单的诊断 NSLog 时,崩溃停止了(但它阻止了主线程上的某些内容被调用,因此这不是永久修复)。

在此过程中,我进行了一次暗中调整,删除了对基地址的操作。为了尝试保存循环迭代,我正在执行类似的操作来跳过缓冲区中的所有其他像素:

byteIndex   += (bytesPerPixel * 2);

下降到以下位置完全解决了问题:

byteIndex   += (bytesPerPixel);

Forget atos. I realized the Device Logs list which thread, file, and line number the crash occurred at. It's consistently in my AVCaptureSession delegate captureOutput method.

I was getting CVPixelBufferGetBaseAddress values on the order of 200 times higher when run "unplugged". I also discovered that when I ran a simple diagnostic NSLog in one of the loops, the crashing stopped (but it prevented something on the main thread from being called, so this was not a permanent fix).

In the process, I made a stab in the dark tweak, removing an operation on the base address. In attempt to save loop iterations, I was doing something like this to skip every other pixel in the buffer:

byteIndex   += (bytesPerPixel * 2);

Dropping down to the following fixed the problem completely:

byteIndex   += (bytesPerPixel);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文