Using SDKs? Here’s How They Could Slow Your App Start Time

Post on 09-Apr-2017

88 views 0 download

Transcript of Using SDKs? Here’s How They Could Slow Your App Start Time

Using SDKs? Here’s how they could Slow your App Start Time

TABLE OF CONTENTS

App launch time definition

The onCreate complexity

Waiting for the other shoe to drop

The good, the bad and the unzipped

Check yourself before you wreck yourself

What should you do?

APP LAUNCH TIME DEFINITION

There is a time frame between the app’s class’s onCreate and the launcher activity’s onStart.

onStart

(Opening

screen seen)

App launch timeonCreate

This time frame can be a few milliseconds

BUT…

It can also get to as much as several seconds!

THE onCreate COMPLEXITY

Most SDKs aim to be placed in the application’s onCreate to get into gearat the earliest possible time

However, those SDKs might block the main UI, which forces your users to wait longerwithout any indication that your app is responding…

WAITING FOR THE OTHER SHOE TO DROP

The longest potential task is

pre-loading data from a server

Thankfully, Android doesn’t allow network communicationon the main UI thread

WAITING FOR THE OTHER SHOE TO DROP

And still, Some SDKs make sure their data has been received from theserver by waiting for a callback before ‘releasing’ the main thread back to the application itself.

When the amount of work done by an SDK depends on network

connection, the best thing to do is NOT to place it in the onCreate

When the 65K limit was an issue, SDKs were trying to avoid it by loading additional code during Runtime

Even though the 65K issue was resolved, some SDKs never changed the way they work

THE GOOD, THE BAD AND THE UNZIPPED

The result: a long duration of app’s start time due to theadditional code loading

Real-life scenario: The app code is only responsible for a third of its start time! The rest is spent on SDKs.

Why? SDKs unzip and load dex files dynamically when the app is launched

The following chart displays the distribution of an app start time by its SDKs

THE GOOD, THE BAD AND THE UNZIPPED

CHECK YOURSELF BEFORE YOU WRECK YOURSELF

The following chart displays the same app’s start time distribution, this time after several usages

Why did one SDK start time shrink while another didn’t?

Look at the difference between the Orange SDK and the Blue one

CHECK YOURSELF BEFORE YOU WRECK YOURSELF

The Orange SDK first checks if it has already unzipped the file. If so, it only loads the dex file.

However, the Blue SDK unzips the file every single time the app is loaded.

EVERY SINGLE TIME….

1. Move the entire SDK’s initialization code to a splashscreen or alike

WHAT SHOULD YOU DO?

SafeDK’s Marketplace is just the place to look for the optimal SDK for you

Replace that SDK with a similar one that offers the same functionality but with less consequences to the user experience.

WHAT SHOULD YOU DO?

2.

.

3. Not sure why it takes your app so long to launch? Suspect it might be one of the 3rd

party tools you are using but not sure which?

Sign up for SafeDK’s In-App Protection andget SDK-oriented live data and real time alerts for any increase in SDK start time orother issues.

WHAT SHOULD YOU DO?