はじめに
iOSアプリの起動(アプリプロセスを起こすこと)に時間がかかる場合、iOSはそのアプリにEXC_CRASH (SIGKILL)を送り、アプリを強制終了する。
以下はアプリ強制終了のクラッシュレポートの抜粋だ。19.97 seconds という数字の通り、アプリ起動がおおよそ20秒かかると強制終了の対象となる。
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-create watchdog transgression: app<com.hiroakit.AppPlayground1(E45319F4-4216-43EF-A72C-A899B7230DFB)>:4612 exhausted real (wall clock) time allowance of 19.97 seconds
サンプルコード
AppDelegate.swiftを追加する。アプリ起動時に25秒のsleepを入れる。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// AppDelegate.swift
import UIKit
import os
class MyAppDelegate: NSObject {
private let logger = Logger(subsystem: "com.hiroakit.AppPlayground1", category: "Launch")
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
logger.log("Start didFinishLaunchingWithOptions")
sleep(25)
logger.log("End didFinishLaunchingWithOptions")
return true
}
}
|
XcodeでProduct > Runした場合にはWatchdogタイマーは作動しない。
アプリをiPhoneにインストールできたら、Xcodeのデバッガーのアタッチを止めてから、アプリを動かすとWatchdogタイマーが動作してアプリプロセスをキルする。
クラッシュレポート
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: 556FE78A-C58C-422B-815B-4C2D77779A0A
CrashReporter Key: 6d90d78f5c7dd0d6c190d36604deee3ba4b1bc3a
Hardware Model: iPhone17,3
Process: AppPlayground1 [4612]
Path: /private/var/containers/Bundle/Application/F592CC68-C4ED-4822-8B5D-71EF7ABAEAE4/AppPlayground1.app/AppPlayground1
Identifier: com.hiroakit.AppPlayground1
Version: 1.0 (1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.hiroakit.AppPlayground1 [2421]
Date/Time: 2025-03-02 10:28:29.0745 +0900
Launch Time: 2025-03-02 10:28:08.0605 +0900
OS Version: iPhone OS 18.3.1 (22D72)
Release Type: User
Baseband Version: 1.40.03
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-create watchdog transgression: app<com.hiroakit.AppPlayground1(E45319F4-4216-43EF-A72C-A899B7230DFB)>:4612 exhausted real (wall clock) time allowance of 19.97 seconds
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: scene-create
WatchdogVisibility: Foreground
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 22.100 (user 11.320, system 10.780), 18% CPU",
"Elapsed application CPU time (seconds): 0.009, 0% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>
Triggered by Thread: 0
|
資料
- Addressing watchdog terminations