【发布时间】:2021-06-20 13:55:31
【问题描述】:
我的应用在后台运行时正在收集传感器数据(位置、步数、心率等)。
有没有办法从 cpu_resource_fatal 日志 (An App.cpu_resource_fatal-2021-06-19-043941.ips.synced) 中确定我的代码中 cpu 在哪里达到最大值?
我有时间分析了我的应用,但一切看起来都还不错。我遇到的问题是应用程序在 10 分钟到几个小时之间随机终止,因此没有真正的迹象表明是什么原因造成的。
是否有任何工具可以指示我的代码在哪里以及如何继续对其进行解码?
19 ??? (libdyld.dylib + 4416) [0x19ba7e140]
19 ??? (An App + 36856) [0x102a38ff8]
我已经寻找答案,但没有找到任何帮助。
这是日志文件的部分输出:
{"app_name":"An App","timestamp":"2021-06-19 04:39:41.00 +0100","app_version":"1.0","slice_uuid":"6DBBF8FB-861D-388F-B086-B1338485456A","adam_id":0,"build_version":"1","bundleID":"com.msn.dev.An App","share_with_app_devs":1,"is_first_party":0,"bug_type":"206","os_version":"iPhone OS 14.6 (18F72)","incident_id":"18242B71-2C07-43FE-9C86-A9C8BBFD4A16","name":"An App"}
Date/Time: 2021-06-19 04:38:41.398 +0100
End time: 2021-06-19 04:39:41.190 +0100
OS Version: iPhone OS 14.6 (Build 18F72)
Architecture: arm64
Report Version: 32
Incident Identifier: 18242B71-2C07-43FE-9C86-A9C8BBFD4A16
Share With Devs: Yes
Data Source: Microstackshots
Shared Cache: E0420A4C-044A-38AB-81C9-0681ED2C05D7 slid base address 0x19b9b8000, slide 0x1b9b8000
Command: An App
Path: /private/var/containers/Bundle/Application/4CFC1F43-62F5-43FD-9695-27B18E968E74/An App.app/An App
Identifier: com.msn.dev.An App
Version: 1.0 (1)
Beta Identifier: CA71DB36-08E5-48C4-9F3A-A15F652CF1F7
PID: 7087
Event: cpu usage
Action taken: Process killed
CPU: 48 seconds cpu time over 60 seconds (80% cpu average), exceeding limit of 80% cpu over 60 seconds
CPU limit: 48s
Limit duration: 60s
CPU used: 48s
CPU duration: 60s
Duration: 59.79s
Duration Sampled: 17.39s
Steps: 19
Hardware model: iPhone10,6
Active cpus: 6
Heaviest stack for the target process:
19 ??? (libdyld.dylib + 4416) [0x19ba7e140]
19 ??? (An App + 36856) [0x102a38ff8]
19 ??? (SwiftUI + 4401348) [0x1a231b8c4]
19 ??? (SwiftUI + 8918208) [0x1a276a4c0]
19 ??? (SwiftUI + 8918320) [0x1a276a530]
19 ??? (UIKitCore + 11753060) [0x19e6d0664]
19 ??? (UIKitCore + 11731176) [0x19e6cb0e8]
19 ??? (GraphicsServices + 13680) [0x1b24a5570]
19 ??? (CoreFoundation + 604184) [0x19bd9f818]
19 ??? (CoreFoundation + 606548) [0x19bda0154]
19 ??? (CoreFoundation + 605112) [0x19bd9fbb8]
19 ??? (CoreFoundation + 628104) [0x19bda5588]
19 ??? (SwiftUI + 2866992) [0x1a21a4f30]
19 ??? (SwiftUI + 2866676) [0x1a21a4df4]
19 ??? (libswiftObjectiveC.dylib + 8016) [0x1c0548f50]
19 ??? (SwiftUI + 2847996) [0x1a21a04fc]
19 ??? (SwiftUI + 2866704) [0x1a21a4e10]
19 ??? (SwiftUI + 2866856) [0x1a21a4ea8]
19 ??? (SwiftUI + 4575124) [0x1a2345f94]
19 ??? (SwiftUI + 9362096) [0x1a27d6ab0]
19 ??? (SwiftUI + 9356360) [0x1a27d5448]
19 ??? (SwiftUI + 4418488) [0x1a231fbb8]
19 ??? (SwiftUI + 8694596) [0x1a2733b44]
19 ??? (SwiftUI + 8709728) [0x1a2737660]
19 ??? (SwiftUI + 4432724) [0x1a2323354]
19 ??? (SwiftUI + 9356392) [0x1a27d5468]
19 ??? (SwiftUI + 9351292) [0x1a27d407c]
19 ??? (SwiftUI + 9356560) [0x1a27d5510]
19 ??? (SwiftUI + 9345968) [0x1a27d2bb0]
19 ??? (AttributeGraph + 57416) [0x1c3355048]
19 ??? (AttributeGraph + 21784) [0x1c334c518]
19 ??? (AttributeGraph + 20744) [0x1c334c108]
18 ??? (SwiftUI + 3340216) [0x1a22187b8]
16 ??? (SwiftUI + 6473584) [0x1a2515770]
16 ??? (SwiftUI + 3203020) [0x1a21f6fcc]
16 ??? (SwiftUI + 6472548) [0x1a2515364]
16 ??? (SwiftUI + 3229912) [0x1a21fd8d8]
16 ??? (SwiftUI + 5650800) [0x1a244c970]
16 ??? (SwiftUI + 9484856) [0x1a27f4a38]
15 ??? (SwiftUI + 7413264) [0x1a25fae10]
15 ??? (SwiftUI + 2957384) [0x1a21bb048]
15 ??? (SwiftUI + 3618976) [0x1a225c8a0]
15 ??? (SwiftUI + 6647036) [0x1a253fcfc]
13 ??? (SwiftUI + 4110252) [0x1a22d47ac]
12 ??? (libswiftCore.dylib + 2706436) [0x19fa1bc04]
7 ??? (libswiftCore.dylib + 1016760) [0x19f87f3b8]
5 ??? (libswiftCore.dylib + 3025652) [0x19fa69af4]
4 ??? (libswiftCore.dylib + 3137112) [0x19fa84e58]
3 ??? (libswiftCore.dylib + 3186576) [0x19fa90f90]
【问题讨论】:
-
我也遇到了这个问题。请注意,由于后台 CPU 过多,看门狗正在终止应用程序。但是堆栈跟踪中的所有内容看起来都像 SwiftUI。这是我的 100% 的样子。编辑:答案在这一行:19 ??? (An App + 36856) [0x102a38ff8] 你需要对此进行符号化并弄清楚那段特定的代码是什么需要这么长时间。