iOS崩溃无日志情形总结

3,699 阅读4分钟

为什么我找不到我的崩溃日志?


当我正在努力工作(划水)的时候,总有同事上来就滴我一下:同学,我打开首页的时候崩溃了,你帮我看下为什么手机上没有崩溃日志了?这时,我总想来一句WTF?当然,说归说,闹归闹,该说得我还是得说,对于找不到崩溃日志的情形,且听我慢慢道来


怎么拿到我的崩溃日志

通常情况下,我们能够在系统设置->隐私->分析->分析与数据(各个iOS系统会有名称差异)里面找到与我们APP二进制文件名字匹配的,如下图所示当微信发生崩溃的时候,其对应的崩溃日志文件名称如下,点击进去,右上角就可以把崩溃日志分享出来给给我们的开发小哥哥调试解决了😯。但是,不幸的事总是会如期发生,并不是每次你都能找到崩溃日志,下面我仔细说说拿不到日志的几种情况。 !

没有蛛丝马迹的情况

  • 隐私里面的共享iPhone分析和与应用开发者共享的开关没有开启。你都不同意了,找毛线啊,找!

  • 当天同一个APP崩溃了25次(阈值可能会不同系统有差异,但作者目前遇见的基本都是25次)以上。这个时候你可以把你的iPhone设备连上电脑,打开控制台应用,崩溃的时候会有崩溃次数超限的提示😯。

  • APP发布证书过期之后,会发生启动崩溃并且无日志情况。包括但不限于TF版本过期,和企业证书安装的APP证书过期,不过现在在高版本iOS系统上,证书过期一般点击开启APP会有提示。下图是贴吧TF版本过期后我再控制台后台捕获到的日志。

  • 后台保活超过30秒;通常 iOS程序会执行后台任务时,通常会使用APIUIApplication.beginBackgroundTask(expirationHander)UIApplication.endBackgroundTask(_:)来执行后台任务,但当你在30s内你的后台任务仍然不结束的话,你的APP就会悄悄的和你Say Bye了😯。

有点蛛丝马迹

  • OOM崩溃,当程序使用的内存超过阈值的时候,此时Apple的Jestems机制就会发生作用(前台和后台的阈值有所不同,但是都会触发);通常情况下你可以在系统设置->隐私->分析->分析与数据里面找到JetsamEvent格式的日志,如下图所示
  • 各种系统资源限制引发的崩溃
    • 线程在短时间内切换过多引发的崩溃
    • cpu长时间超负荷运转引发的崩溃
    • IO(磁盘写操作)一定时间内写过多引发的崩溃
    • Fence-hang:一种iOS14系统之后苹果增加的崩溃,暂无更多信息。

市面上部分SDK无法捕获的崩溃

  • SIGKILL崩溃

    • 0x8badf00d:看门狗(watch dog)崩溃
    • 0xc00010ff:设备过热
    • 0xdead10cc:死锁
    • 0xbaadca11:The operating system terminated the app for failing to report a CallKit call in response to a PushKit notification.
    • 0xbad22222:Voip功能调用太频繁
    • 0xc51bad01:watchOS CPU资源占用过多
    • 0xc51bad02:watchOS terminated the app because it failed to complete a background task within the allocated time. Decrease the amount of work that the app performs while running in the background to resolve this crash.
    • 0xc51bad03:watchOS terminated the app because it failed to complete a background task within the allocated time, but the system was sufficiently busy overall that the app may not have received much CPU time to perform the background task. Although you may be able to avoid the issue by reducing the amount of work your app performs in background tasks, 0xc51bad03 doesn’t indicate that the app did anything wrong. More likely, the app wasn’t able to complete its work because of overall system load.
  • SIGQUIT: 一般是因为其他进程的优先级高于当前进程引起的。通常不认为是崩溃

  • EXC_GUARD:对一些保护性文件的不合法操作引发的崩溃

    • CLOSE. The process attempted to invoke close() on a guarded file descriptor.
    • DUP. The process attempted to invoke dup(), dup2(), or fcntl() with the F_DUPFD or F_DUPFD_CLOEXEC commands on a guarded file descriptor.
    • NOCLOEXEC. The process attempted to remove the FD_CLOEXEC flag from a guarded file descriptor.
    • SOCKET_IPC. The process attempted to send a guarded file descriptor through a socket.
    • FILEPORT. The process attempted to obtain a Mach send right for a guarded file descriptor.
    • WRITE. The process attempted to write to a guarded file descriptor.
  • 栈溢出:stack overflow

    • 在栈上申请太大内存

      当我们定义的数据所需要占用的内存超过了栈的大小时,就会发生栈溢出。

    • 递归调用函数多次

      一个函数调用自身就叫做递归。当递归层次过高时,程序就会发生栈溢出。

参考资料