12

我的网站在 Mobile Safari 上崩溃,但在桌面上运行良好。

我如何确定它为什么会崩溃?

4

2 回答 2

22

当 Safari 意外退出显示您的网站时,您可以采取的措施:

1.Safari调试控制台

使用 Safari 的调试控制台。在 iPhone 中打开:设置->Safari->高级->调试控制台=on。

对我来说它说

  • 第 6 行出现 2 个 HTML 错误 (无法识别键“width”的视口参数值“device-width”,无法识别键“user-scalable”的视口参数值“no”。)
  • 第 6 行还有 2 个 HTML 提示。

下次您使用 Safari 检查网页时,将显示调试控制台。

2. Web Inspector(来自 iOS 6.0)

如果在您的网页中找出问题变得越来越复杂,请使用 Web Inspector 来调试 Mobile Safari。这是一个很棒的教程。

使用 IOS 模拟器,我发现对于这个特定的网站,我拥有的所有 iOS 版本,5.0、5.1 和 6.1,都可以正确运行页面并导致页面崩溃,但在设备(iOS 5.0.1)上仍然崩溃。

我的设备在 iOS 5 上运行,因此我无法访问 Web Inspector,但下一步肯定是在设备上检查您的站点并在您的机器上检查 Web Inspector。

3. 使用 iPhone 配置实用程序的控制台

您可以下载 Apple 的iPhone 配置实用程序,然后您可以在 Safari 测试期间访问您手机的控制台。

检查您的网站,我看到了一些内存警告,最终导致 Safari 崩溃。

4a。使用 Xcode 的调试工具

使用 Xcode 您还可以访问设备的控制台(Window->Organizer->Devices tab->Console)。

您的案例在控制台上报告了以下内容:

Apr 30 10:15:18 unknown kernel[0] <Debug>: launchd[2489] Builtin profile: MobileSafari (sandbox)   
Apr 30 10:15:38 unknown MobileSafari[2489] <Warning>: Received memory warning. 
Apr 30 10:15:39 unknown SpringBoard[15] <Warning>: Received memory warning. 
Apr 30 10:15:50 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created 
Apr 30 10:15:50 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilephone[0xb2a4]) Exited: Killed: 9
Apr 30 10:15:50 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilesafari[0xf755]) Exited: Killed: 9
Apr 30 10:15:50 unknown SpringBoard[15] <Warning>: Application 'Phone' exited abnormally with signal 9: Killed: 9
Apr 30 10:15:50 unknown SpringBoard[15] <Warning>: Application 'Safari' exited abnormally with signal 9: Killed: 9
Apr 30 10:15:52 unknown ReportCrash[2491] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2013-04-30-101552.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

4b。使用 Xcode 的调试工具 Instruments

检查正在发生的事情的另一种复杂方法是​​使用 Instruments。

再次检查您的站点,我看到 Safari 在退出之前报告了许多低内存警告。遗憾的是,它并不能直接帮助您发现网站问题,但可能有助于查找 Safari 打开的错误报告。

于 2013-04-29T19:09:08.073 回答
3

通过执行以下操作,我成功调试了崩溃:

  1. 使用 xcode 连接到手机控制台
  2. 在控制台中找到崩溃,在我的情况下是这样的:

    9 月 2 日 17:16:21 Edwards-iPhone ReportCrash[7093]:将报告保存到 /Library/Logs/CrashReporter/JetsamEvent-2015-09-02-171621.ips

  3. Then go to Diagnostics in settings (settings > privacy > diagnostics & usage data - that's on ios 8.4. It's in a different place on other versions) and find the crash file.

This removes the need to guess at which crash reports the one you experienced.

于 2015-09-02T17:31:06.423 回答