We have to support iOS 11 because of our business. Our app launches very slow on an iPhone 6 Plus with iOS 11.2.2(12C202).
The app integrates PushKit/CallKit/VoIP. When PushKit notification arrives, the system will wake up the app and the app will be launched from background. But the launching process is so slow that the watchdog kills the app.
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, scene-create watchdog transgression: com.***.*** exhausted CPU time allowance of 1.92 seconds |
| ProcessVisibility: Background
| ProcessState: Running
| WatchdogEvent: scene-create
| WatchdogVisibility: Background
| WatchdogCPUStatistics: (
| "Elapsed total CPU time (seconds): 12.400 (user 12.400, system 0.000), 60% CPU",
| "Elapsed application CPU time (seconds): 5.859, 28% CPU"
| )
Triggered by Thread: 0
I use Xcode 15 Instrument’s App Launch template to profile the app. Here is the result:
Start Duration Narrative
00:00.000.000 10.42 s The system took 10.42 s to create the process.
00:10.416.163 76.91 ms Launching â UIKit Initialization
00:10.493.071 105.46 ms Launching â UIKit Scene Creation
00:10.598.535 1.46 s Launching â didFinishLaunchingWithOptions()
00:12.062.475 13.54 ms Launching â UIKit Scene Creation
00:12.076.015 1.16 s Launching â Initial Frame Rendering
00:14.953.028 5.07 s Currently running in the foreground...
The didFinishLaunchingWithOptions
takes 1.46s, and because of the poor hardware of iPhone 6 Plus, maybe that’s ok?
However, at the very beginning of the launching, there is a stage called “Initializing – Process Creation”, which takes 10.42s. There are lots of Blocked
State on Main Thread.
I know that it’s important to improve the performance of didFinishLaunchingWithOptions
function, but what is happening with the <Initializing – Process Creation> and what can I do with all these state.