WWDC2019 - Optimizing App Launch

2019-08-03  本文已影响0人  Longshihua

目录

1、What is launch

Why Launch Is Important

Example: Involves a lot of CPU work and a lot of memory work.

Launch Type

屏幕快照 2019-08-02 下午5.51.53.png

Cold launch

Cold launches occur after reboot, or when your app has not been launched for very long time. In order to launcher app, we need to bring it from disk into memory, startup system-side services that support your app, and then spawn your process.

Warm launch

Once it's happened once, you'll experience a warm launch. In this case, your app still needs to be spawned, but we've already brought your app into memory and started up some of those system-side services.

So, this will be a little bit faster and a little bit more consistent.

Resume

This occurs when a user reenters your app from either the home screen or the app switcher.

Phases of App Launch(App运行阶段)

屏幕快照 2019-08-03 下午12.08.00.png

As you know, launch generally starts when the user taps your icon on your home screen.Then over the next 100 or so milliseconds, iOS will do the necessary system-side work in order to initialize your app.

That leaves you as developers about 300 milliseconds to create your views, load your content, and generate your first frame.

These six phases cover everything from system initialization to the app initialization to view creation and layout, and then depending on your app, potentially a asynchronous loading phase for your data, the extended phase.

屏幕快照 2019-08-02 下午5.53.20.png

System Interface

DYLD3

App Startup Time: Past, Present, and Future WWDC 2017

Some steps to optimizing for DYLD3

For libSystem Init

Static Runtime Initialization

Steps to do:

Ways to optimizing:

UIKit Initialization

Steps to do:

Ways to optimizing:

Lifecycle Callbacks

Invokes UIApplicationDelegate app lifecycle callbacks

application:willFinishLaunchingWithOptions:
application:didFinishLaunchingWithOptions:

Invokes UIApplicaitonDelegate UI lifecycle callbacks

applicationDidBecomaActive:

Invokes UIScreenDelegate UI lifecycle callbacks for each scene

scene:willConnectToSession:options:
scene:willEnterForeground:
sceneDidBecomeActive:

Ways to optimizing:

by either pushing it to the background queues or just doing it later entirely

First Frame Render

Creates, performs layout for, and draws views
Commits and renders first frame

loadView
viewDidLoad
layoutSubviews

Ways to optimizing:

Extended

Measuring Performance Using Logging WWDC 2018

2、How to properly measure your launch

Trading Representativeness for Consistency

Test in a Clean and Consistent Environment

Measuring Launch with XCTest

屏幕快照 2019-08-02 下午6.07.29.png

Improving Battery Life and Performance WWDC 2019

3、Use Instruments to profile your launch

Tips and Tricks

屏幕快照 2019-08-02 下午6.08.49.png

Minimize work

Prioritize work

Modernizing Grand Central Dispatch Usage WWDC 2017

Optimize work

4、Track Your Launch Over Time

Make performance a development-time priority
Plot it and have a target

Monitor Customer Launches with Xcode Organizer

屏幕快照 2019-08-02 下午6.11.24.png

Adopt MetricKit for More Statistics

Summary

Optimizing App Launch

上一篇下一篇

猜你喜欢

热点阅读